I had the same problem as you. I managed to find a solution for the request with blob in the where clause, but not for deletion. So at the end, my solution was the first to request the rows that I want to delete, and use the row id to delete it. Here is a sample code. I assume that you have a column named ImageId as the primary key of type int.
public Cursor queryImage(final byte[] data, String[] columns) { return getReadableDatabase().queryWithFactory( new CursorFactory() { @Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { query.bindBlob(1, data); return new SQLiteCursor(db, masterQuery, editTable, query); } }, false, "FavoriteData", columns, "Image = ?", null, null, null, null, null); } public void favoriteDelete(byte[] byteArray){ Cursor cursor = queryImage(byteArray, new String[]{"ImageId"}); while (cursor.moveToNext()) { getReadableDatabase().delete("FavoriteData", "ImageId" + "= ?", new String[] { String.valueOf(cursor.getInt(0))}); } }
If anyone has a better solution, I will be interested too. In any case, if you have a way to avoid using Blob for the query, this would be better because it is not so efficient. You can try to identify the images in some way, for example, using the hash of the hash of the images to search.
source share