Reputation: 27
I try to delete a specific row with where clause in sqlite for android but it not working plz any body help.
public void delete(int p){
SQLiteDatabase db = this.getReadableDatabase();
db.execSQL("delete from "+ TABLE_NAME + " WHERE " + COLUMN_ID + " ="+p);
db.close();}
Upvotes: 0
Views: 4357
Reputation: 352
Try to change this this.getReadableDatabase();
to this.getWritableDatabase();
It should work.
Upvotes: 2
Reputation: 4964
try this :
public void delete(int p){
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM "+ TABLE_NAME + " WHERE " + COLUMN_ID + " = "+p+"");
db.close();
}
Upvotes: 3