Issue
I am packaging a custom Sqlite build in my app, with an HTMLtokenizer to use with FTS. I create the FTS table virtually with room.
CREATE VIRTUAL TABLE IF NOT EXISTS subitem_content USING fts4(item_category_id, item_id, subitem_id, title, html, tokenize=HTMLTokenizer eng)
I also call the following:
System.loadLibrary("sqliteX")
to link the custom sqlite build and
System.loadLibrary("tokenizers")
to link the packaged Tokenizers library to the project.
I then register the tokenizer to the database with the following
sqliteDb.loadExtension("libtokenizers")
sqliteDb.registerTokenizer(Tokenizer.HTML_TOKENIZER)
This seems to work fine. I can insert data into the table and query the data just fine. That is until I close the app and restart it, where I receive the following error:
org.sqlite.database.sqlite.SQLiteException: unknown tokenizer: HTMLTokenizer (code 1): , while compiling:
If I clear the app data and start again, things work just fine the first time,but crash upon restarting the app. I've checked /proc/pid/map to make sure the native libraries are loaded, and they show up there at the time of database transaction. Why would I get this error after restart?
Solution
You are creating the database only once, when you're running the app for the first time. But the tokenizer must be available whenever you are using the database, so you must register it whenever you have a new database connection.
The proper place is wherever you create a new connection; in the original Android database API, this would be the onConfigure callback.
Answered By - CL.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.