简体   繁体   English

使用sqllite的Android搜索错误

[英]Android search error with sqllite

im trying to use MATCH key word to get a cursor from query result from my database the query as follows 我试图使用MATCH关键字从我的数据库的查询结果中获取光标,查询如下

databaseHelper = new DatabaseHelper(this);
    database= databaseHelper.getReadableDatabase();
    data = database.query(DatabaseHelper.DATABASE_TABLE, Constants.FROM_MAINSCREEN, databaseHelper.COLUMN_TITLE + " MATCH ?", new String[]{"f*"}, null, null, null);
    if(data!=null)
        data.moveToFirst();
    dataAdapter = new MyCursorAdapterMainScreen(this, data, 0);
    listView.setAdapter(dataAdapter);

I get error as follow 我得到如下错误

android.database.sqlite.SQLiteException: SQL logic error or missing database

android.database.sqlite.SQLiteException: SQL logic error or missing database android.database.sqlite.SQLiteException:SQL逻辑错误或缺少数据库

Your problem is your query and exactly MATCH , it won't work 1 . 您的问题是您的查询和完全MATCH ,它不起作用1 So change it to: 因此将其更改为:

"... LIKE ?", new String[] {"f%"}

and now it should work. 现在应该可以了。

1 Match is introduced only with FTS3 and FTS4 tables so your table must be virtual and not ordinary as you most likely have. 1 Match仅在FTS3和FTS4表中引入,因此您的表必须是虚拟的,而不是最可能的普通表。

By default, MATCH is not implemented : 默认情况下, 未实现MATCH

The MATCH operator is a special syntax for the match() application-defined function. MATCH运算符是match()应用程序定义的函数的特殊语法。 The default match() function implementation raises an exception and is not really useful for anything. 默认的match()函数实现引发一个异常,对任何事情实际上都没有用。 But extensions can override the match() function with more helpful logic. 但是扩展可以使用更有用的逻辑来覆盖match()函数。

Looks like you could use GLOB instead of MATCH . 看起来您可以使用GLOB代替MATCH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM