dimanche 23 août 2015

Android SQLite Content Provider query (searchable)

I have a custom search provider that looks as follows:

<searchable xmlns:android="http://ift.tt/nIICcg"
android:hint="hint"
android:label="label"
android:searchSuggestAuthority="com.path_to_provider"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestIntentData="http://ift.tt/1PtvHK2"
android:searchSuggestSelection="word LIKE ? || '%' OR word LIKE '% ' || ? || '%'" />

When independentally tested, each side of the OR in my search suggestion works fine. When I use the OR for some reason, the query does not work. Is there something wrong with my query? My goal is to have the search "cat" be matched for "catastrophic" and "look at the cats"

Here is my ContentProvider query

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteDatabase sqLiteDatabase = searchHelper.getReadableDatabase();

    return sqLiteDatabase.query("table_name",
            projection,
            selection,
            selectionArgs,
            null,
            null,
            null);
}

Aucun commentaire:

Enregistrer un commentaire