How do I delete a sqlite table row entry by string? How do I delete a sqlite table row entry by string? sqlite sqlite

How do I delete a sqlite table row entry by string?


You should not use the string directly and if you do you need to wrap it in ' since SQLite will consider it a column name otherwise.

The safest way to do it is

public void deleteEntry(String coin) throws SQLException{    String[] whereArgs = new String[] { coin };    ourDatabase.delete(DATABASE_TABLE, KEYNAME + "=?", whereArgs);}

The unsafe way is

ourDatabase.delete(DATABASE_TABLE, KEYNAME + "='" + coin + "'", null);

and that will fail if coin contains a ' so don't use it.