Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法删除记录_Android_Sqlite - Fatal编程技术网

Android 无法删除记录

Android 无法删除记录,android,sqlite,Android,Sqlite,我的删除记录功能: 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 titl

我的删除记录功能:

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();

}
我没有收到任何错误,但记录没有被删除。它保持原样。 请帮助我,我已经参考了很多答案,但仍然没有完成。
谢谢

您正在将ID值转换为字符串。 没有ID为具有该值的字符串的记录

纯整数在格式化或SQL注入方面没有问题,因此可以安全地将其直接嵌入查询字符串:

sqLiteDatabase.delete(KK_AIRLINEBOOK, KEY_ID + " = " + uid);

您传入的uid是什么?记录该值以查看它是否正确。另外,
delete()
返回int,显示影响的行数。你应该检查他是否返回>0