我正在学习Android SearchableDictionary教程
here
和代码
here
public Cursor getWordMatches(String query, String[] columns) {
//This (original code) searches your query in the KEY_WORD column, which is the SUGGEST_COLUMN_TEXT_1 column.
//String selection = KEY_WORD + " MATCH ?";
// This searches your query across ALL columns of the table, not what I want because I have added additional columns to the sqlitedb table
//String selection = FTS_VIRTUAL_TABLE + " MATCH ?";
// This is what I want, to search my query in both the keyword and keydefinition columns, which is the 1 and 2 suggest column text
String selection = KEY_WORD +"OR" + KEY_DEFINITION+ " MATCH ?";
String[] selectionArgs = new String[] {query+"*"};
return query(selection, selectionArgs, columns);
/* This builds a query that looks like:
* SELECT <columns> FROM <table> WHERE <KEY_WORD> MATCH 'query*'
* which is an FTS3 search for the query text (plus a wildcard) inside the word column.
String selection = KEY_WORD +"OR" + KEY_DEFINITION+ " MATCH ?";
String selection = FTS_VIRTUAL_TABLE+ " MATCH 'suggest_text_1:? OR suggest_text_2:?'";
我也阅读了本书的相关章节
this