最近在看短信搜索功能,发现 MmsSmsProvider.java 中的SQL语句不能很好的搜索现象,不知道是什么原因,部分代码:String searchString = uri.getQueryParameter("pattern");
String query = String.format("SELECT _id, index_text, source_id, table_to_use, offsets(words) FROM words WHERE words MATCH '%s*' LIMIT 50;", searchString);
if ( sortOrder != null
|| selection != null
|| selectionArgs != null
|| projection != null) {
throw new IllegalArgumentException(
"do not specify sortOrder, selection, selectionArgs, or projection" +
"with this query");
} cursor = db.rawQuery(query, null);
执行这条SQL语句,如果短信内容是:“短信信息搜索”,只有输入“短信”才能查到结果,输入“信息”却查不到结果,也就是说输入第一个字符串才能查到,而且我把query中的‘%s*'改为‘%s‘,却导致什么都查不出来,不知何解?期待大牛现身!!!
String query = String.format("SELECT _id, index_text, source_id, table_to_use, offsets(words) FROM words WHERE words MATCH '%s*' LIMIT 50;", searchString);
if ( sortOrder != null
|| selection != null
|| selectionArgs != null
|| projection != null) {
throw new IllegalArgumentException(
"do not specify sortOrder, selection, selectionArgs, or projection" +
"with this query");
} cursor = db.rawQuery(query, null);
执行这条SQL语句,如果短信内容是:“短信信息搜索”,只有输入“短信”才能查到结果,输入“信息”却查不到结果,也就是说输入第一个字符串才能查到,而且我把query中的‘%s*'改为‘%s‘,却导致什么都查不出来,不知何解?期待大牛现身!!!
我想问下,如果表中有这样一条语句"This is a table", SELECT _id FROM words WHERE words MATCH 'tab*',是否有结果呢?
这个个人认为是sqlite对中文没有很好的支持,后面这个Bug我没有解了,好像很多机器上都有这个问题,你有空可以研究下~~