Stay organized with collections
Save and categorize content based on your preferences.
public
static
class
ContactsContract.SearchSnippets
extends Object
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.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Constants
DEFERRED_SNIPPETING_KEY
public static final 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
ContactsContract.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
public static final 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".
Constant Value:
"snippet"
Public constructors
SearchSnippets
public SearchSnippets ()
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ContactsContract.SearchSnippets\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Constants](#constants) \\| [Ctors](#pubctors) \\| [Inherited Methods](#inhmethods) \n\nContactsContract.SearchSnippets\n===============================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/provider/ContactsContract.SearchSnippets \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\nclass\nContactsContract.SearchSnippets\n`\n\n\n`\n\nextends `[Object](/reference/java/lang/Object)`\n\n\n`\n\n`\n\n\n`\n\n|---|--------------------------------------------------|\n| [java.lang.Object](/reference/java/lang/Object) ||\n| ↳ | android.provider.ContactsContract.SearchSnippets |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAdditional column returned by\n[Contacts.CONTENT_FILTER_URI](/reference/android/provider/ContactsContract.Contacts#CONTENT_FILTER_URI) explaining\nwhy the filter matched the contact. This column will contain extracts from the contact's\nconstituent [Data](/reference/android/provider/ContactsContract.Data) items, formatted in a way that indicates the section of the\nsnippet that matched the filter.\n\n\nThe following example searches for all contacts that match the query \"presi\" and requests\nthe snippet column as well. \n\n```\n Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();\n builder.appendPath(\"presi\");\n // Defer snippeting to the client side if possible, for performance reasons.\n builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,\"1\");\n\n Cursor cursor = getContentResolver().query(builder.build());\n\n Bundle extras = cursor.getExtras();\n if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {\n // Do our own snippet formatting.\n // For a contact with the email address (president@organization.com), the snippet\n // column will contain the string \"president@organization.com\".\n } else {\n // The snippet has already been pre-formatted, we can display it as is.\n // For a contact with the email address (president@organization.com), the snippet\n // column will contain the string \"[presi]dent@organization.com\".\n }\n \n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Constants ||\n|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [String](/reference/java/lang/String) | [DEFERRED_SNIPPETING_KEY](/reference/android/provider/ContactsContract.SearchSnippets#DEFERRED_SNIPPETING_KEY) The key to ask the provider to defer the formatting of the snippet to the client if possible, for performance reasons. |\n| [String](/reference/java/lang/String) | [SNIPPET](/reference/android/provider/ContactsContract.SearchSnippets#SNIPPET) The search snippet constructed by SQLite snippeting functionality. |\n\n| ### Public constructors ||\n|--------------------------------------------------------------------------------------------------------|---|\n| ` `[SearchSnippets](/reference/android/provider/ContactsContract.SearchSnippets#SearchSnippets())`() ` |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[java.lang.Object](/reference/java/lang/Object)` ` |---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](/reference/java/lang/Object) | ` `[clone](/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object. | | ` boolean` | ` `[equals](/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Indicates whether some other object is \"equal to\" this one. | | ` void` | ` `[finalize](/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final `[Class](/reference/java/lang/Class)`\u003c?\u003e` | ` `[getClass](/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this `Object`. | | ` int` | ` `[hashCode](/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object. | | ` final void` | ` `[notify](/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` `[notifyAll](/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor. | | ` `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/Object#toString())`() ` Returns a string representation of the object. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||\n\nConstants\n---------\n\n### DEFERRED_SNIPPETING_KEY\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final String DEFERRED_SNIPPETING_KEY\n```\n\nThe key to ask the provider to defer the formatting of the snippet to the client if\npossible, for performance reasons.\nA value of 1 indicates true, 0 indicates false. False is the default.\nWhen a cursor is returned to the client, it should check for an extra with the name\n[ContactsContract.DEFERRED_SNIPPETING](/reference/android/provider/ContactsContract#DEFERRED_SNIPPETING) in the cursor. If it exists, the client\nshould do its own formatting of the snippet. If it doesn't exist, the snippet column\nin the cursor should already contain a formatted snippet.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n\"deferred_snippeting\"\n\n\n### SNIPPET\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final String SNIPPET\n```\n\nThe search snippet constructed by SQLite snippeting functionality.\n\n\nThe snippet may contain (parts of) several data elements belonging to the contact,\nwith the matching parts optionally surrounded by special characters that indicate the\nstart and end of matching text.\n\nFor example, if a contact has an address \"123 Main Street\", using a filter \"mai\" would\nreturn the formatted snippet \"123 \\[Mai\\]n street\".\n\n\u003cbr /\u003e\n\n**See also:**\n\n- \u003chttp://www.sqlite.org/fts3.html#snippet\u003e\n\nConstant Value:\n\n\"snippet\"\n\n\nPublic constructors\n-------------------\n\n### SearchSnippets\n\n```\npublic SearchSnippets ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]