I have two different Search activities implemented with SearchManager in my app. One is the default searchable for the whole app and the other is used for only one activity. These two searches perform lookups of different data, and it doesn't make sense to share the search history across the two different searches. The two different searchables are working fine functionally within the app, my issue is with the recent search histories.
The problem is that there are two different SearchRecentSuggestionsProvider classes defined within the app, but any search made in one shows up in both searches' recent search suggestions history. I've read through the SearchManager topic in the Dev Guide but don't see any info about multiple suggestions providers.
Here are the two providers in the AndroidManifest.xml, in the node:
<provider android:name=".SearchOneRecentSuggestionsProvider"
android:authorities="com.company.SearchOneRecentSuggestionsProvider"></provider>
<provider android:name=".SearchTwoRecentSuggestionsProvider"
android:authorities="com.company.SearchTwoRecentSuggestionsProvider"></provider>
Here's the class defined in SearchOneRecentSuggestionsProvider.java:
package com.company;
import android.content.SearchRecentSuggestionsProvider;
public class SearchOneRecentSuggestionsProvider extends SearchRecentSuggestionsProvider {
public final static String AUTHORITY = "com.company.SearchOneRecentSuggestionsProvider";
public final static int MODE = DATABASE_MODE_QUERIES;
public SearchOneRecentSuggestionsProvider() {
setupSuggestions(AUTHORITY, MODE);
}
}
(The SearchTwoRecentSuggestionsProvider class looks exactly the same except for replacing One with Two and is in it's own SearchTwoRecentSuggestionsProvider.java file.)
Here's what is inside the search suggestions database (at /data/data/com.company/databases/suggestions.db):
# sqlite3 suggestions.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .tables
android_metadata suggestions
sqlite> .schema suggestions
CREATE TABLE suggestions (_id INTEGER PRIMARY KEY,display1 TEXT UNIQUE ON CONFLICT REPLACE,query TEXT,date LONG);
sqlite> select * from suggestions;
1|searchone|searchone|1296177852444
2|searchtwo|searchtwo|1296177878744
There's no column for the SearchRecentSuggestionsProvider, so perhaps there's no way to separate the history for the two searches?
The end result of all this is that when you do a search in either one of the two different searches, you see both searchone and searchtwo in the recent search history suggestions. I'd like each to have their own history if possible. Hopefully I didn't just miss something silly! Thanks for taking the time to read this.
Looks like it's not possible at this time. For those of you searching SO for this same issue, see https://code.google.com/p/android/issues/detail?id=13501 for future updates from Google.