我有下面的代码,但是一旦我插入数据并按下保存它就不会将数据保存到数据库中。我做错了什么?
来自 IMService.java
@Override
public String updateUserDetails(String username, String statusMessage, String presence)
throws UnsupportedEncodingException {
String params = "username=" + URLEncoder.encode(this.username.toString(), "UTF-8")
+ "&password=" + URLEncoder.encode(this.password.toString(), "UTF-8")
+ "&statusmessage=" + URLEncoder.encode(statusMessage, "UTF-8")
+ "&presence=" + URLEncoder.encode(presence, "UTF-8")
+ "&action=" + URLEncoder.encode("updateUserData", "UTF-8") + "&";
Log.i("PARAMS", params);
return socketOperator.sendHttpRequest(params);
}
从主要活动
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.user_profile);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle("My Profile");
statusMsg1 = (EditText) findViewById(R.id.statusMessage);
saveStatusBut = (Button) findViewById(R.id.saveStatus);
saveStatusBut.setOnClickListener(new OnClickListener() {
CharSequence statusMsg;
Handler handler = new Handler();
@Override
public void onClick(View arg0) {
//test
statusMsg = statusMsg1.getText();
Thread thread = new Thread() {
@Override
public void run() {
try {
imService.updateUserDetails(imService.getUsername(),statusMsg.toString(), "online");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
thread.start();
}
});
}