Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay, I'm not sure if this is the easiest way to accomplish what I had asked, but here's how I did it:</p> <ol> <li>Create another ContentProvider and use that in my searchable.xml</li> <li>This new ContentProvider's query method will query my SearchRecentSuggestionsProvider with special parameters and a special URI and return that Cursor.</li> </ol> <p>Source code snippet of my new ContentProvider:</p> <pre><code>... public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { final String[] PROJECTION = new String[] { "_id", "display1 AS " + SearchManager.SUGGEST_COLUMN_TEXT_1, "display2 AS " + SearchManager.SUGGEST_COLUMN_TEXT_2, "query AS " + SearchManager.SUGGEST_COLUMN_QUERY, android.R.drawable.ic_menu_recent_history + " AS " + SearchManager.SUGGEST_COLUMN_ICON_1, }; final Uri URI = Uri.parse("content://" + SearchHistoryProvider.AUTHORITY + "/suggestions"); return getContext().getContentResolver().query( URI, PROJECTION, "display1 LIKE ?", new String[] {selectionArgs[0] + "%"}, "date DESC"); } ... </code></pre> <p>If the SearchRecentSuggestionsProvider is not set up to use two lines, 'display2' in the projection above should be changed to 'null' or could probably be omitted altogether.</p> <p>If the 'suggestions' path is omitted from the URI, it will not work. It must be 'suggestions' otherwise you will see an 'Invalid Uri' Exception.</p> <p>I dug most of this information up by digging through the source code to SearchRecentSuggestionsProvider.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload