I recently updated my database to FTS3 due to that I implented search functionality.
My FTS3 table:
db.execSQL("CREATE VIRTUAL TABLE " + TABLE_FTS + " USING fts3(" + COL_ID + ", " + COL_KEY_NAME + ", "
+ COL_KEY_WEBURL + " , " + COL_KEY_MAINURL + ", " + COL_KEY_CODEC + " " + ");");
I always deletet entrys from my listview with the ContextMenu
. I used a method like this:
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
delete(info.id);
updateList();
public void delete(long id) {
int numDeleted = database.delete("stations" , "_ID = ?", new String[] { Long.toString(id) } );
Log.d(TAG, "delete(): id=" + id + " -> " + numDeleted);
}
public void updateList() {
data.requery();
dataSource.notifyDataSetChanged();
}
The method, info.id
don't get me the position, so I'am changed it to info.position
. Position is right, but delet dont work. Ok, than I tried a simple delete instead of via Android Method.
database.execSQL("DELETE FROM " + DatabaseHelper.TABLE_FTS + " WHERE " + DatabaseHelper.COL_ID + "='" + id + "'");
Don't work, too. It seems that the column, COL_KEY_ID = BaseColumns._ID
with an autoincrementing number don't exists in FTS3 anymore? I figured out, that I could use rowid
but its not working as intended. If I delete my first entry, the entrys below get weird deleted.
How I can get this back working like before? Edit: Found now fix ..
Found fix. Don't delete by ID, delete now by name.