public class SearchRecentSuggestionsProvider extends ContentProvider
In order to use this class, you must do the following.
SearchManager
. (This
provider will send any suggested queries via the standard
ACTION_SEARCH
Intent, which you'll already
support once you have implemented and tested basic searchability.)SearchRecentSuggestionsProvider
. The class you create will be
very simple - typically, it will have only a constructor. But the constructor has a very
important responsibility: When it calls setupSuggestions(String, int)
, it
configures the provider to match the requirements of your searchable activity.<!-- Content provider for search suggestions --> <provider android:name="YourSuggestionProviderClass" android:authorities="your.suggestion.authority" />
android:searchSuggestAuthority="your.suggestion.authority" android:searchSuggestSelection=" ? "
SearchRecentSuggestions.saveRecentQuery()
.For information about using search suggestions in your application, read the Search developer guide.
SearchRecentSuggestions
ContentProvider.PipeDataWriter<T>
Modifier and Type | Field and Description |
---|---|
static int |
DATABASE_MODE_2LINES
This mode bit configures the database to include a 2nd annotation line with each entry.
|
static int |
DATABASE_MODE_QUERIES
This mode bit configures the database to record recent queries.
|
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
SearchRecentSuggestionsProvider() |
Modifier and Type | Method and Description |
---|---|
int |
delete(Uri uri,
String selection,
String[] selectionArgs)
This method is provided for use by the ContentResolver.
|
String |
getType(Uri uri)
This method is provided for use by the ContentResolver.
|
Uri |
insert(Uri uri,
ContentValues values)
This method is provided for use by the ContentResolver.
|
boolean |
onCreate()
This method is provided for use by the ContentResolver.
|
Cursor |
query(Uri uri,
String[] projection,
String selection,
String[] selectionArgs,
String sortOrder)
This method is provided for use by the ContentResolver.
|
protected void |
setupSuggestions(String authority,
int mode)
In order to use this class, you must extend it, and call this setup function from your
constructor.
|
int |
update(Uri uri,
ContentValues values,
String selection,
String[] selectionArgs)
This method is provided for use by the ContentResolver.
|
applyBatch, attachInfo, bulkInsert, call, coerceToLocalContentProvider, dump, getContext, getIContentProvider, getPathPermissions, getReadPermission, getStreamTypes, getWritePermission, isTemporary, onConfigurationChanged, onLowMemory, onTrimMemory, openAssetFile, openFile, openFileHelper, openPipeHelper, openTypedAssetFile, query, setPathPermissions, setReadPermission, setWritePermission, shutdown
public static final int DATABASE_MODE_QUERIES
public static final int DATABASE_MODE_2LINES
protected void setupSuggestions(String authority, int mode)
SearchRecentSuggestions
helper.authority
- This must match the authority that you've declared in your manifest.mode
- You can use mode flags here to determine certain functional aspects of your
database. Note, this value should not change from run to run, because when it does change,
your suggestions database may be wiped.DATABASE_MODE_QUERIES
,
DATABASE_MODE_2LINES
public int delete(Uri uri, String selection, String[] selectionArgs)
delete
in class ContentProvider
uri
- The full URI to query, including a row ID (if a specific record is requested).selection
- An optional restriction to apply to rows when deleting.public String getType(Uri uri)
getType
in class ContentProvider
uri
- the URI to query.public Uri insert(Uri uri, ContentValues values)
insert
in class ContentProvider
uri
- The content:// URI of the insertion request.values
- A set of column_name/value pairs to add to the database.public boolean onCreate()
onCreate
in class ContentProvider
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
query
in class ContentProvider
uri
- The URI to query. This will be the full URI sent by the client;
if the client is requesting a specific record, the URI will end in a record number
that the implementation should parse and add to a WHERE or HAVING clause, specifying
that _id value.projection
- The list of columns to put into the cursor. If
null all columns are included.selection
- A selection criteria to apply when filtering rows.
If null then all rows are included.selectionArgs
- You may include ?s in selection, which will be replaced by
the values from selectionArgs, in order that they appear in the selection.
The values will be bound as Strings.sortOrder
- How the rows in the cursor should be sorted.
If null then the provider is free to define the sort order.public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
update
in class ContentProvider
uri
- The URI to query. This can potentially have a record ID if this
is an update request for a specific record.values
- A Bundle mapping from column names to new column values (NULL is a
valid value).selection
- An optional filter to match rows to update.