Search code examples
androidsqlitefts3

android sqlite fts3 create table if not exists


I see that we cannot use "if not exists" in the create virtual table statement

CREATE VIRTUAL TABLE WORLD_LIST IF NOT EXISTS USING FTS3(_ID INTEGER PRIMARY KEY AUTOINCREMENT, WORD TEXT)

If I remove the IF NOT EXISTS it works only once. Is there any alternative for this.


Solution

  • You could test for the existence of the table then branch accordingly:

    SELECT DISTINCT tablename from sqlite_master where tablename = ?