I was looking how to migrate an existing application to Room, from plain Sqlite, and I haven't been able to find how could I migrate a part that uses FTS.
Right now, I have a virtual table that's filled by a trigger every time a row is inserted or updated:
private static final String CREATE_VIRTUAL_TABLE = "CREATE VIRTUAL TABLE " + FTS_VIRTUAL_TABLE +
" using fts4 (content='" + TABLE_NOTIFICATION + "', " + COLUMN_TITLE + ")";
private static void createVirtualTriggers(SQLiteDatabase database){
database.execSQL("CREATE TRIGGER virtual_bu BEFORE UPDATE ON " + TABLE_NOTIFICATION + " BEGIN\n" + " DELETE FROM " + FTS_VIRTUAL_TABLE + " WHERE docid=old.rowid;\n" + "END;");
database.execSQL("CREATE TRIGGER virtual_bd BEFORE DELETE ON " + TABLE_NOTIFICATION + " BEGIN\n" + " DELETE FROM " + FTS_VIRTUAL_TABLE + " WHERE docid=old.rowid;\n" + "END;");
database.execSQL("CREATE TRIGGER virtual_au AFTER UPDATE ON " + TABLE_NOTIFICATION + " BEGIN\n" + " INSERT INTO " + FTS_VIRTUAL_TABLE + "(docid, " + COLUMN_TITLE + ") VALUES(new.rowid, new." + COLUMN_TITLE +");\n" + "END;");
database.execSQL("CREATE TRIGGER virtual_ai AFTER INSERT ON " + TABLE_NOTIFICATION + " BEGIN\n" + " INSERT INTO " + FTS_VIRTUAL_TABLE + "(docid, " + COLUMN_TITLE + ") VALUES(new.rowid, new." + COLUMN_TITLE +");\n" + "END;");
}
Is there any way to achieve this same functionality with Room?