sai sai - 1 year ago 105
Android Question

How to delete a row from a table in SQLite android?

I have done this and it is not working. I am getting

force close

public boolean favoriteDelete(int id) {
return database.delete("FavoriteData", "Google" + "=" + id, null) > 0;

Answer Source

You can simply use sql query to delete.

public void delete(String id) {
        db.execSQL("delete from "+TBL_NAME+" where Google='"+id+"'");

In your query you are passing null in place of whereArgs

db.delete(table, whereClause, whereArgs)

It should be like this

db.delete(TBL_NAME, "Google=?", new String[]{Integer.toString(id)});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download