Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple DELETE statement did not work in SQlite [duplicate]

Possible Duplicate:
Android Delete Query

I've db and right now it has 17 records. This is my code:

SQLiteDatabase db=openOrCreateDatabase("mydb", MODE_PRIVATE, null);
c= db.rawQuery("DELETE FROM tbl1 where cat='12'",null);
db.close();

It's a really simple query but every time I run the app on emulator, it's runs perfectly without any error but I doesn't remove anything either.

Could anyone helps me with what is the problem ?

like image 403
Navid Abutorab Avatar asked Jan 14 '23 21:01

Navid Abutorab


2 Answers

db.execSQL("DELETE FROM tbl1 where cat=12");

like image 111
Sanjay Chaudhary Avatar answered Jan 29 '23 11:01

Sanjay Chaudhary


try this

public void deleteContact(Contact contact) {
    SQLiteDatabase db = this.getWritableDatabase();
    db.delete(TABLE_CONTACTS, KEY_ID + " = ?",
            new String[] { String.valueOf(contact.getID()) });
    db.close();
}
like image 20
Zohaib Brohi Avatar answered Jan 29 '23 11:01

Zohaib Brohi