Domanda

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 ..

È stato utile?

Soluzione

Found fix. Don't delete by ID, delete now by name.

Altri suggerimenti

I assume the problem comes from

_ID = ?

_ID is an integer yet ? is replaced by a String. Same for your second not working approach.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top