[英]delete a specific row with where clause in sqlite for android
我嘗試刪除適用於Android的sqlite中的where子句的特定行,但是它無法正常工作,請幫忙。
public void delete(int p){
SQLiteDatabase db = this.getReadableDatabase();
db.execSQL("delete from "+ TABLE_NAME + " WHERE " + COLUMN_ID + " ="+p);
db.close();}
嘗試這個 :
public void delete(int p){
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM "+ TABLE_NAME + " WHERE " + COLUMN_ID + " = "+p+"");
db.close();
}
嘗試更改此this.getReadableDatabase();
到this.getWritableDatabase();
它應該工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.