5

I want to create a table using fts5 extension

CREATE VIRTUAL TABLE TABLE_FTS_FOOD_ITEM USING fts5 (content='food_items', Shrt_Desc, Energy_Kcal);

but I am getting this error.

android.database.sqlite.SQLiteException: no such module: fts5

Earlier I was using fts4 that was working fine. Can I use fts5 with sqLitedatabase in android?

Sonam Pasi
  • 562
  • 1
  • 4
  • 19

2 Answers2

3

FTS5 is not available before SQLite 3.9.0, and even then disabled by default, so it is unlikely to be part of any SQLite library shipped with Android.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • Okay, Actually I want to query a column order by rank. Can I do the same thing with FTS4? – Sonam Pasi Apr 08 '17 at 12:36
  • 1
    Currently, I am using this query to get the desired result but I am not sure this is the right way or not, **SELECT Shrt_Desc FROM table WHERE Shrt_Desc MATCH "apple*" ORDER BY (CASE WHEN Shrt_Desc= "apple" THEN 1 WHEN Shrt_Desc LIKE "apple%" THEN 2 ELSE 3 END), Shrt_Desc asc;** – Sonam Pasi Apr 08 '17 at 13:06
  • To ask a different question, click "Ask Question". (Or read the [documentation](http://www.sqlite.org/fts3.html#appendix_a).) – CL. Apr 08 '17 at 13:09
2

Download this project: https://github.com/requery/sqlite-android Then add -DSQLITE_ENABLE_FTS5 to sqlite_flags in sqlite-android\src\main\jni\sqlite\Android.mk and rebuild (gradlew assemble in project root dir). And Voila! You have Android libs with FTS5 enabled.

wallycz
  • 312
  • 3
  • 11