Android中的FTS4查询错误

时间:2015-03-27 05:19:13

标签: android sqlite fts4

我使用以下方法在PC上创建了一个fts4表:

CREATE VIRTUAL TABLE main USING fts4(word, definition, notindexed=definition);

在SQLite Studio中,我查询了一个运行正常的语句:

SELECT rowid AS _id, word, definition FROM main WHERE word MATCH 'はな*';

当我提取数据库以在我的Android应用程序中使用时,同一查询会发出以下错误:

03-27 11:22:05.315    6789-6789/com.kradragon.minadictionary E/AndroidRuntime﹕ FATAL EXCEPTION: main
    android.database.sqlite.SQLiteException: unrecognized parameter: notindexed=definition (code 1): , while compiling: SELECT rowid AS _id, word, definition FROM main WHERE word MATCH 'はな*';
            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:886)
            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:497)
            at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
            at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
            at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
            at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
            at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
            at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
            at com.kradragon.minadictionary.model.DictDatabaseHelper.queryWordsMatch(DictDatabaseHelper.java:40)
            at com.kradragon.minadictionary.model.DictionaryManager.findWordsMatch(DictionaryManager.java:43)
            at com.kradragon.minadictionary.ResultsListFragment$WordListCursorLoader.loadCursor(ResultsListFragment.java:141)
            at com.kradragon.minadictionary.model.SqliteCursorLoader.loadInBackground(SqliteCursorLoader.java:24)
            at com.kradragon.minadictionary.ResultsListFragment.queryWords(ResultsListFragment.java:47)
            at com.kradragon.minadictionary.MainActivity.handleIntent(MainActivity.java:134)
            at com.kradragon.minadictionary.MainActivity.onNewIntent(MainActivity.java:188)
            at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1156)
            at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2464)
            at android.app.ActivityThread.performNewIntents(ActivityThread.java:2477)
            at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2486)
            at android.app.ActivityThread.access$1400(ActivityThread.java:162)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1435)
            at android.os.Handler.dispatchMessage(Handler.java:107)
            at android.os.Looper.loop(Looper.java:194)
            at android.app.ActivityThread.main(ActivityThread.java:5371)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
            at dalvik.system.NativeStart.main(Native Method)

我在here

中了解了notindexed

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

SQLite 3.8.0中添加了FTS notindexed选项,而不是version of SQLite used in most Androids