0
我的功能對於刪除記錄:無法刪除記錄
public void delete_byID(int uid){
sqLiteDatabase.delete(KK_AIRLINEBOOK, KEY_ID + "= ?", new String[] {String.valueOf(uid)});
}
我的代碼,我正在試圖刪除一條記錄:
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
// set title
alertDialogBuilder.setTitle("Cancel Booking");
// set dialog message
alertDialogBuilder.setMessage("Do You Really Want To Cancel Your Booking!")
.setCancelable(false)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, close
// current activity
Toast.makeText(CancelCabBooking.this, "Your
Booking Is Canceled Now Thank You!!!!!",
Toast.LENGTH_LONG).show();
int uid=myPrefs.getInt("USERID", 0);
mySQLiteAdapter.delete_byID(uid);
Intent submit= new Intent(CancelCabBooking.this,Customerhome.class);
startActivity(submit);
finish();
srno.setText("");
charges.setText("");
seats.setText("");
CancelCabBooking.this.finish();
}
}
)
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
}
);
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
我沒有得到任何錯誤,但記錄不會被刪除。它保持原樣。 請幫助我我已經提到了很多答案,但仍然沒有做到這一點。 謝謝
什麼是你在通過UID?記錄值以查看它是否正確。 – 2013-05-05 20:22:33
也'刪除()'返回int,它顯示影響了多少行。你應該檢查他是否返回> 0 – WarrenFaith 2013-05-05 20:44:47