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;
}
If a table has duplicate rows, we can delete it by using the DELETE statement. In the case, we have a column, which is not the part of group used to evaluate the duplicate records in the table.
The DISTINCT clause allows you to remove the duplicate rows in the result set. In this syntax: First, the DISTINCT clause must appear immediately after the SELECT keyword. Second, you place a column or a list of columns after the DISTINCT keyword.
To delete the duplicate rows from the table in SQL Server, you follow these steps: Find duplicate rows using GROUP BY clause or ROW_NUMBER() function. Use DELETE statement to remove the duplicate rows.
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)});
Try this
public boolean favoriteDelete(int id) {
return db.delete(DATABASE_TABLE, KEY_ROWID + "=" + id, null) > 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With