Skip to content

Most visited

Recently visited

navigation

ContactsContract.SearchSnippets

public static class ContactsContract.SearchSnippets
extends Object

java.lang.Object
   ↳ android.provider.ContactsContract.SearchSnippets


Additional column returned by Contacts.CONTENT_FILTER_URI explaining why the filter matched the contact. This column will contain extracts from the contact's constituent Data items, formatted in a way that indicates the section of the snippet that matched the filter.

The following example searches for all contacts that match the query "presi" and requests the snippet column as well.

 Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
 builder.appendPath("presi");
 // Defer snippeting to the client side if possible, for performance reasons.
 builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");

 Cursor cursor = getContentResolver().query(builder.build());

 Bundle extras = cursor.getExtras();
 if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
     // Do our own snippet formatting.
     // For a contact with the email address (president@organization.com), the snippet
     // column will contain the string "president@organization.com".
 } else {
     // The snippet has already been pre-formatted, we can display it as is.
     // For a contact with the email address (president@organization.com), the snippet
     // column will contain the string "[presi]dent@organization.com".
 }
 

Summary

Constants

String DEFERRED_SNIPPETING_KEY

The key to ask the provider to defer the formatting of the snippet to the client if possible, for performance reasons.

String SNIPPET

The search snippet constructed by SQLite snippeting functionality.

Public constructors

ContactsContract.SearchSnippets()

Inherited methods

From class java.lang.Object

Constants

DEFERRED_SNIPPETING_KEY

added in API level 21
String DEFERRED_SNIPPETING_KEY

The key to ask the provider to defer the formatting of the snippet to the client if possible, for performance reasons. A value of 1 indicates true, 0 indicates false. False is the default. When a cursor is returned to the client, it should check for an extra with the name DEFERRED_SNIPPETING in the cursor. If it exists, the client should do its own formatting of the snippet. If it doesn't exist, the snippet column in the cursor should already contain a formatted snippet.

Constant Value: "deferred_snippeting"

SNIPPET

added in API level 21
String SNIPPET

The search snippet constructed by SQLite snippeting functionality.

The snippet may contain (parts of) several data elements belonging to the contact, with the matching parts optionally surrounded by special characters that indicate the start and end of matching text. For example, if a contact has an address "123 Main Street", using a filter "mai" would return the formatted snippet "123 [Mai]n street".

See also:

Constant Value: "snippet"

Public constructors

ContactsContract.SearchSnippets

added in API level 21
ContactsContract.SearchSnippets ()

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)