How Can I Create A Code If I Need To Delete Some Record Using In Parameter In Android?
Normally I can use the following code to delete a recod. SQLiteDatabase db = openOrCreateDatabase('test.db', Context.MODE_PRIVATE, null); db.execSQL('DROP TABLE IF EXISTS person'
Solution 1:
public int delete (String table, String whereClause, String[] whereArgs)
delete
method description is quite clear. If you want to delete a row of the given id then it should be something like this:
db.delete("person", "id="+String.valueOf(int_id_to_delete), null);
Futher, if you want to delete multiple rows at once use the following:
db.delete("person", "id"+"=?", new String[]{"6","4"});
Solution 2:
You can use the following code or can execute a raw query as android permits.
db.delete("person", "id"+ "=?", new String[] {"4","6"});
Post a Comment for "How Can I Create A Code If I Need To Delete Some Record Using In Parameter In Android?"