Deleting Row in SQLite in Android
Solution 1:
You can try like this:
//---deletes a particular title---
public boolean deleteTitle(String name)
{
return db.delete(DATABASE_TABLE, KEY_NAME + "=" + name, null) > 0;
}
or
public boolean deleteTitle(String name)
{
return db.delete(DATABASE_TABLE, KEY_NAME + "=?", new String[]{name}) > 0;
}
Solution 2:
Try like that may you get your solution
String table = "beaconTable";
String whereClause = "_id=?";
String[] whereArgs = new String[] { String.valueOf(row) };
db.delete(table, whereClause, whereArgs);
Solution 3:
it's better to use whereargs too;
db.delete("tablename","id=? and name=?",new String[]{"1","jack"});
this is like useing this command:
delete from tablename where id='1' and name ='jack'
and using delete function in such way is good because it removes sql injections.
Solution 4:
Till i understand your question,you want to put two conditions to select a row to be deleted.for that,you need to do:
public void deleteEntry(long row,String key_name) {
db.delete(DATABASE_TABLE, KEY_ROWID + "=" + row + " and " + KEY_NAME + "=" + key_name, null);
/*if you just have key_name to select a row,you can ignore passing rowid(here-row) and use:
db.delete(DATABASE_TABLE, KEY_NAME + "=" + key_name, null);
*/
}