0
我想在我的android數據庫中存儲值。我能夠存儲值,但我的問題是,當我正在檢查將值存儲在數據庫中時,我的應用程序正在崩潰,在特定的實例中我可以找到錯誤。Android獲取失敗,同時檢查phpresponse
請任何人幫助我解決這個問題。這是我的短代碼。
ResponseHandler<String> responseHandler = new BasicResponseHandler();
final String response = httpclient.execute(httppost, responseHandler);
System.out.println("Response : " + response);
if(response.equalsIgnoreCase("Entered data successfully")){
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(lifequality.this,"Inserted Successully", Toast.LENGTH_SHORT).show();
}
});
myIntent=new Intent(lifequality.this, menu.class);
String uname;
uname=myValues.getString("value").toString();
myIntent.putExtra("value", uname);
startActivity(myIntent);
}else{
showAlert();
startActivity(new Intent(lifequality.this, lifequality.class));
}
}catch(Exception e){
dialog.dismiss();
System.out.println("Exception : " + e.getMessage());
}
}
public void showAlert(){
lifequality.this.runOnUiThread(new Runnable() {
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(lifequality.this);
builder.setTitle("error in inserting.");
builder.setMessage("not inserted.")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
}