• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package android.provider;
18 
19 import android.accounts.Account;
20 import android.annotation.SdkConstant;
21 import android.annotation.SdkConstant.SdkConstantType;
22 import android.annotation.SystemApi;
23 import android.app.Activity;
24 import android.content.BroadcastReceiver;
25 import android.content.ContentProviderClient;
26 import android.content.ContentProviderOperation;
27 import android.content.ContentResolver;
28 import android.content.ContentUris;
29 import android.content.ContentValues;
30 import android.content.Context;
31 import android.content.ContextWrapper;
32 import android.content.CursorEntityIterator;
33 import android.content.Entity;
34 import android.content.EntityIterator;
35 import android.content.Intent;
36 import android.content.IntentFilter;
37 import android.content.res.AssetFileDescriptor;
38 import android.content.res.Resources;
39 import android.database.Cursor;
40 import android.database.CursorWrapper;
41 import android.database.DatabaseUtils;
42 import android.graphics.Rect;
43 import android.net.Uri;
44 import android.os.RemoteException;
45 import android.text.TextUtils;
46 import android.util.DisplayMetrics;
47 import android.util.Pair;
48 import android.view.View;
49 import java.io.ByteArrayInputStream;
50 import java.io.IOException;
51 import java.io.InputStream;
52 import java.util.ArrayList;
53 
54 /**
55  * <p>
56  * The contract between the contacts provider and applications. Contains
57  * definitions for the supported URIs and columns. These APIs supersede
58  * {@link Contacts}.
59  * </p>
60  * <h3>Overview</h3>
61  * <p>
62  * ContactsContract defines an extensible database of contact-related
63  * information. Contact information is stored in a three-tier data model:
64  * </p>
65  * <ul>
66  * <li>
67  * A row in the {@link Data} table can store any kind of personal data, such
68  * as a phone number or email addresses.  The set of data kinds that can be
69  * stored in this table is open-ended. There is a predefined set of common
70  * kinds, but any application can add its own data kinds.
71  * </li>
72  * <li>
73  * A row in the {@link RawContacts} table represents a set of data describing a
74  * person and associated with a single account (for example, one of the user's
75  * Gmail accounts).
76  * </li>
77  * <li>
78  * A row in the {@link Contacts} table represents an aggregate of one or more
79  * RawContacts presumably describing the same person.  When data in or associated with
80  * the RawContacts table is changed, the affected aggregate contacts are updated as
81  * necessary.
82  * </li>
83  * </ul>
84  * <p>
85  * Other tables include:
86  * </p>
87  * <ul>
88  * <li>
89  * {@link Groups}, which contains information about raw contact groups
90  * such as Gmail contact groups.  The
91  * current API does not support the notion of groups spanning multiple accounts.
92  * </li>
93  * <li>
94  * {@link StatusUpdates}, which contains social status updates including IM
95  * availability.
96  * </li>
97  * <li>
98  * {@link AggregationExceptions}, which is used for manual aggregation and
99  * disaggregation of raw contacts
100  * </li>
101  * <li>
102  * {@link Settings}, which contains visibility and sync settings for accounts
103  * and groups.
104  * </li>
105  * <li>
106  * {@link SyncState}, which contains free-form data maintained on behalf of sync
107  * adapters
108  * </li>
109  * <li>
110  * {@link PhoneLookup}, which is used for quick caller-ID lookup</li>
111  * </ul>
112  */
113 @SuppressWarnings("unused")
114 public final class ContactsContract {
115     /** The authority for the contacts provider */
116     public static final String AUTHORITY = "com.android.contacts";
117     /** A content:// style uri to the authority for the contacts provider */
118     public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
119 
120     /**
121      * Prefix for column names that are not visible to client apps.
122      * @hide
123      */
124     public static final String HIDDEN_COLUMN_PREFIX = "x_";
125 
126     /**
127      * An optional URI parameter for insert, update, or delete queries
128      * that allows the caller
129      * to specify that it is a sync adapter. The default value is false. If true
130      * {@link RawContacts#DIRTY} is not automatically set and the
131      * "syncToNetwork" parameter is set to false when calling
132      * {@link
133      * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
134      * This prevents an unnecessary extra synchronization, see the discussion of
135      * the delete operation in {@link RawContacts}.
136      */
137     public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
138 
139     /**
140      * Query parameter that should be used by the client to access a specific
141      * {@link Directory}. The parameter value should be the _ID of the corresponding
142      * directory, e.g.
143      * {@code content://com.android.contacts/data/emails/filter/acme?directory=3}
144      */
145     public static final String DIRECTORY_PARAM_KEY = "directory";
146 
147     /**
148      * A query parameter that limits the number of results returned for supported URIs. The
149      * parameter value should be an integer.
150      *
151      * <p>This parameter is not supported by all URIs.  Supported URIs include, but not limited to,
152      * {@link Contacts#CONTENT_URI},
153      * {@link RawContacts#CONTENT_URI},
154      * {@link Data#CONTENT_URI},
155      * {@link CommonDataKinds.Phone#CONTENT_URI},
156      * {@link CommonDataKinds.Callable#CONTENT_URI},
157      * {@link CommonDataKinds.Email#CONTENT_URI},
158      * {@link CommonDataKinds.Contactables#CONTENT_URI},
159      *
160      * <p>In order to limit the number of rows returned by a non-supported URI, you can implement a
161      * {@link CursorWrapper} and override the {@link CursorWrapper#getCount()} methods.
162      */
163     public static final String LIMIT_PARAM_KEY = "limit";
164 
165     /**
166      * A query parameter specifing a primary account. This parameter should be used with
167      * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on
168      * this information to optimize its query results.
169      *
170      * For example, in an email composition screen, its implementation can specify an account when
171      * obtaining possible recipients, letting the provider know which account is selected during
172      * the composition. The provider may use the "primary account" information to optimize
173      * the search result.
174      */
175     public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account";
176 
177     /**
178      * A query parameter specifing a primary account. This parameter should be used with
179      * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}.
180      */
181     public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account";
182 
183     /**
184      * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and
185      * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to
186      * return only phone-related results. For example, frequently contacted person list should
187      * include persons contacted via phone (not email, sms, etc.)
188      */
189     public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only";
190 
191     /**
192      * A key to a boolean in the "extras" bundle of the cursor.
193      * The boolean indicates that the provider did not create a snippet and that the client asking
194      * for the snippet should do it (true means the snippeting was deferred to the client).
195      *
196      * @see SearchSnippets
197      */
198     public static final String DEFERRED_SNIPPETING = "deferred_snippeting";
199 
200     /**
201      * Key to retrieve the original deferred snippeting from the cursor on the client side.
202      *
203      * @see SearchSnippets
204      * @see #DEFERRED_SNIPPETING
205      */
206     public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query";
207 
208     /**
209      * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI},
210      * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and
211      * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}.
212      * This enables a content provider to remove duplicate entries in results.
213      */
214     public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries";
215 
216     /**
217      * <p>
218      * API for obtaining a pre-authorized version of a URI that normally requires special
219      * permission (beyond READ_CONTACTS) to read.  The caller obtaining the pre-authorized URI
220      * must already have the necessary permissions to access the URI; otherwise a
221      * {@link SecurityException} will be thrown. Unlike {@link Context#grantUriPermission},
222      * this can be used to grant permissions that aren't explicitly required for the URI inside
223      * AndroidManifest.xml. For example, permissions that are only required when reading URIs
224      * that refer to the user's profile.
225      * </p>
226      * <p>
227      * The authorized URI returned in the bundle contains an expiring token that allows the
228      * caller to execute the query without having the special permissions that would normally
229      * be required. The token expires in five minutes.
230      * </p>
231      * <p>
232      * This API does not access disk, and should be safe to invoke from the UI thread.
233      * </p>
234      * <p>
235      * Example usage:
236      * <pre>
237      * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI;
238      * Bundle uriBundle = new Bundle();
239      * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri);
240      * Bundle authResponse = getContext().getContentResolver().call(
241      *         ContactsContract.AUTHORITY_URI,
242      *         ContactsContract.Authorization.AUTHORIZATION_METHOD,
243      *         null, // String arg, not used.
244      *         uriBundle);
245      * if (authResponse != null) {
246      *     Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable(
247      *             ContactsContract.Authorization.KEY_AUTHORIZED_URI);
248      *     // This pre-authorized URI can be queried by a caller without READ_PROFILE
249      *     // permission.
250      * }
251      * </pre>
252      * </p>
253      *
254      * @hide
255      */
256     public static final class Authorization {
257         /**
258          * The method to invoke to create a pre-authorized URI out of the input argument.
259          */
260         public static final String AUTHORIZATION_METHOD = "authorize";
261 
262         /**
263          * The key to set in the outbound Bundle with the URI that should be authorized.
264          */
265         public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize";
266 
267         /**
268          * The key to retrieve from the returned Bundle to obtain the pre-authorized URI.
269          */
270         public static final String KEY_AUTHORIZED_URI = "authorized_uri";
271     }
272 
273     /**
274      * A Directory represents a contacts corpus, e.g. Local contacts,
275      * Google Apps Global Address List or Corporate Global Address List.
276      * <p>
277      * A Directory is implemented as a content provider with its unique authority and
278      * the same API as the main Contacts Provider.  However, there is no expectation that
279      * every directory provider will implement this Contract in its entirety.  If a
280      * directory provider does not have an implementation for a specific request, it
281      * should throw an UnsupportedOperationException.
282      * </p>
283      * <p>
284      * The most important use case for Directories is search.  A Directory provider is
285      * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI
286      * Contacts.CONTENT_FILTER_URI}.  If a Directory provider wants to participate
287      * in email and phone lookup functionalities, it should also implement
288      * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI}
289      * and
290      * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}.
291      * </p>
292      * <p>
293      * A directory provider should return NULL for every projection field it does not
294      * recognize, rather than throwing an exception.  This way it will not be broken
295      * if ContactsContract is extended with new fields in the future.
296      * </p>
297      * <p>
298      * The client interacts with a directory via Contacts Provider by supplying an
299      * optional {@code directory=} query parameter.
300      * <p>
301      * <p>
302      * When the Contacts Provider receives the request, it transforms the URI and forwards
303      * the request to the corresponding directory content provider.
304      * The URI is transformed in the following fashion:
305      * <ul>
306      * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li>
307      * <li>The {@code accountName=} and {@code accountType=} parameters are added or
308      * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li>
309      * </ul>
310      * </p>
311      * <p>
312      * Clients should send directory requests to Contacts Provider and let it
313      * forward them to the respective providers rather than constructing
314      * directory provider URIs by themselves. This level of indirection allows
315      * Contacts Provider to implement additional system-level features and
316      * optimizations. Access to Contacts Provider is protected by the
317      * READ_CONTACTS permission, but access to the directory provider is protected by
318      * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous
319      * platform versions the provider should perform the following check to make sure the call
320      * is coming from the ContactsProvider:
321      * <pre>
322      * private boolean isCallerAllowed() {
323      *   PackageManager pm = getContext().getPackageManager();
324      *   for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) {
325      *     if (packageName.equals("com.android.providers.contacts")) {
326      *       return true;
327      *     }
328      *   }
329      *   return false;
330      * }
331      * </pre>
332      * </p>
333      * <p>
334      * The Directory table is read-only and is maintained by the Contacts Provider
335      * automatically.
336      * </p>
337      * <p>It always has at least these two rows:
338      * <ul>
339      * <li>
340      * The local directory. It has {@link Directory#_ID Directory._ID} =
341      * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally
342      * stored contacts. The same can be achieved by omitting the {@code directory=}
343      * parameter altogether.
344      * </li>
345      * <li>
346      * The local invisible contacts. The corresponding directory ID is
347      * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}.
348      * </li>
349      * </ul>
350      * </p>
351      * <p>Custom Directories are discovered by the Contacts Provider following this procedure:
352      * <ul>
353      * <li>It finds all installed content providers with meta data identifying them
354      * as directory providers in AndroidManifest.xml:
355      * <code>
356      * &lt;meta-data android:name="android.content.ContactDirectory"
357      *               android:value="true" /&gt;
358      * </code>
359      * <p>
360      * This tag should be placed inside the corresponding content provider declaration.
361      * </p>
362      * </li>
363      * <li>
364      * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI}
365      * query to each of the directory authorities.  A directory provider must implement
366      * this query and return a list of directories.  Each directory returned by
367      * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and
368      * {@link #ACCOUNT_TYPE} columns (nulls are allowed).  Since directory IDs are assigned
369      * automatically, the _ID field will not be part of the query projection.
370      * </li>
371      * <li>Contacts Provider compiles directory lists received from all directory
372      * providers into one, assigns each individual directory a globally unique ID and
373      * stores all directory records in the Directory table.
374      * </li>
375      * </ul>
376      * </p>
377      * <p>Contacts Provider automatically interrogates newly installed or replaced packages.
378      * Thus simply installing a package containing a directory provider is sufficient
379      * to have that provider registered.  A package supplying a directory provider does
380      * not have to contain launchable activities.
381      * </p>
382      * <p>
383      * Every row in the Directory table is automatically associated with the corresponding package
384      * (apk).  If the package is later uninstalled, all corresponding directory rows
385      * are automatically removed from the Contacts Provider.
386      * </p>
387      * <p>
388      * When the list of directories handled by a directory provider changes
389      * (for instance when the user adds a new Directory account), the directory provider
390      * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change.
391      * In response, the Contacts Provider will requery the directory provider to obtain the
392      * new list of directories.
393      * </p>
394      * <p>
395      * A directory row can be optionally associated with an existing account
396      * (see {@link android.accounts.AccountManager}). If the account is later removed,
397      * the corresponding directory rows are automatically removed from the Contacts Provider.
398      * </p>
399      */
400     public static final class Directory implements BaseColumns {
401 
402         /**
403          * Not instantiable.
404          */
Directory()405         private Directory() {
406         }
407 
408         /**
409          * The content:// style URI for this table.  Requests to this URI can be
410          * performed on the UI thread because they are always unblocking.
411          */
412         public static final Uri CONTENT_URI =
413                 Uri.withAppendedPath(AUTHORITY_URI, "directories");
414 
415         /**
416          * URI used for getting all directories from primary and managed profile.
417          * It supports the same semantics as {@link #CONTENT_URI} and returns the same columns.
418          * If the device has no managed profile that is linked to the current profile, it behaves
419          * in the exact same way as {@link #CONTENT_URI}.
420          * If there is a managed profile linked to the current profile, it will merge
421          * managed profile and current profile's results and return.
422          *
423          * Note: this query returns primary profile results before managed profile results,
424          * and this order is not affected by sorting parameter.
425          *
426          */
427         public static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
428                 "directories_enterprise");
429 
430         /**
431          * Access file provided by remote directory. It allows both personal and work remote
432          * directory, but not local and invisible diretory.
433          *
434          * It's supported only by a few specific places for referring to contact pictures in the
435          * remote directory. Contact picture URIs, e.g.
436          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}, may contain this kind of URI.
437          *
438          * @hide
439          */
440         public static final Uri ENTERPRISE_FILE_URI = Uri.withAppendedPath(AUTHORITY_URI,
441                 "directory_file_enterprise");
442 
443 
444         /**
445          * The MIME-type of {@link #CONTENT_URI} providing a directory of
446          * contact directories.
447          */
448         public static final String CONTENT_TYPE =
449                 "vnd.android.cursor.dir/contact_directories";
450 
451         /**
452          * The MIME type of a {@link #CONTENT_URI} item.
453          */
454         public static final String CONTENT_ITEM_TYPE =
455                 "vnd.android.cursor.item/contact_directory";
456 
457         /**
458          * _ID of the default directory, which represents locally stored contacts.
459          * <b>This is only supported by {@link ContactsContract.Contacts#CONTENT_URI} and
460          * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}.
461          * Other URLs do not support the concept of "visible" or "invisible" contacts.
462          */
463         public static final long DEFAULT = 0;
464 
465         /**
466          * _ID of the directory that represents locally stored invisible contacts.
467          */
468         public static final long LOCAL_INVISIBLE = 1;
469 
470         /**
471          * _ID of the work profile default directory, which represents locally stored contacts.
472          */
473         public static final long ENTERPRISE_DEFAULT = Directory.ENTERPRISE_DIRECTORY_ID_BASE
474                 + DEFAULT;
475 
476         /**
477          * _ID of the work profile directory that represents locally stored invisible contacts.
478          */
479         public static final long ENTERPRISE_LOCAL_INVISIBLE = Directory.ENTERPRISE_DIRECTORY_ID_BASE
480                 + LOCAL_INVISIBLE;
481 
482         /**
483          * The name of the package that owns this directory. Contacts Provider
484          * fill it in with the name of the package containing the directory provider.
485          * If the package is later uninstalled, the directories it owns are
486          * automatically removed from this table.
487          *
488          * <p>TYPE: TEXT</p>
489          */
490         public static final String PACKAGE_NAME = "packageName";
491 
492         /**
493          * The type of directory captured as a resource ID in the context of the
494          * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory"
495          *
496          * <p>TYPE: INTEGER</p>
497          */
498         public static final String TYPE_RESOURCE_ID = "typeResourceId";
499 
500         /**
501          * An optional name that can be used in the UI to represent this directory,
502          * e.g. "Acme Corp"
503          * <p>TYPE: text</p>
504          */
505         public static final String DISPLAY_NAME = "displayName";
506 
507         /**
508          * <p>
509          * The authority of the Directory Provider. Contacts Provider will
510          * use this authority to forward requests to the directory provider.
511          * A directory provider can leave this column empty - Contacts Provider will fill it in.
512          * </p>
513          * <p>
514          * Clients of this API should not send requests directly to this authority.
515          * All directory requests must be routed through Contacts Provider.
516          * </p>
517          *
518          * <p>TYPE: text</p>
519          */
520         public static final String DIRECTORY_AUTHORITY = "authority";
521 
522         /**
523          * The account type which this directory is associated.
524          *
525          * <p>TYPE: text</p>
526          */
527         public static final String ACCOUNT_TYPE = "accountType";
528 
529         /**
530          * The account with which this directory is associated. If the account is later
531          * removed, the directories it owns are automatically removed from this table.
532          *
533          * <p>TYPE: text</p>
534          */
535         public static final String ACCOUNT_NAME = "accountName";
536 
537         /**
538          * Mimimal ID for corp directory returned from
539          * {@link Directory#CORP_CONTENT_URI}.
540          *
541          * @hide
542          */
543         // slightly smaller than 2 ** 30
544         public static final long ENTERPRISE_DIRECTORY_ID_BASE = 1000000000;
545 
546         /**
547          * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT},
548          * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the
549          * directory has for data exported from it.  Clients must obey this setting.
550          */
551         public static final String EXPORT_SUPPORT = "exportSupport";
552 
553         /**
554          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
555          * does not allow any data to be copied out of it.
556          */
557         public static final int EXPORT_SUPPORT_NONE = 0;
558 
559         /**
560          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
561          * allow its data copied only to the account specified by
562          * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}.
563          */
564         public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1;
565 
566         /**
567          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
568          * allow its data copied to any contacts account.
569          */
570         public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2;
571 
572         /**
573          * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY},
574          * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory
575          * has for shortcuts created for its elements. Clients must obey this setting.
576          */
577         public static final String SHORTCUT_SUPPORT = "shortcutSupport";
578 
579         /**
580          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
581          * does not allow any shortcuts created for its contacts.
582          */
583         public static final int SHORTCUT_SUPPORT_NONE = 0;
584 
585         /**
586          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
587          * allow creation of shortcuts for data items like email, phone or postal address,
588          * but not the entire contact.
589          */
590         public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1;
591 
592         /**
593          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
594          * allow creation of shortcuts for contact as well as their constituent elements.
595          */
596         public static final int SHORTCUT_SUPPORT_FULL = 2;
597 
598         /**
599          * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY},
600          * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent
601          * to which the directory supports contact photos.
602          */
603         public static final String PHOTO_SUPPORT = "photoSupport";
604 
605         /**
606          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
607          * does not provide any photos.
608          */
609         public static final int PHOTO_SUPPORT_NONE = 0;
610 
611         /**
612          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
613          * can only produce small size thumbnails of contact photos.
614          */
615         public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1;
616 
617         /**
618          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
619          * has full-size contact photos, but cannot provide scaled thumbnails.
620          */
621         public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2;
622 
623         /**
624          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
625          * can produce thumbnails as well as full-size contact photos.
626          */
627         public static final int PHOTO_SUPPORT_FULL = 3;
628 
629         /**
630          * Return TRUE if it is a remote stored directory.
631          */
isRemoteDirectoryId(long directoryId)632         public static boolean isRemoteDirectoryId(long directoryId) {
633             return directoryId != Directory.DEFAULT
634                     && directoryId != Directory.LOCAL_INVISIBLE
635                     && directoryId != Directory.ENTERPRISE_DEFAULT
636                     && directoryId != Directory.ENTERPRISE_LOCAL_INVISIBLE;
637         }
638 
639         /**
640          * Return TRUE if it is a remote stored directory. TODO: Remove this method once all
641          * internal apps are not using this API.
642          *
643          * @hide
644          */
isRemoteDirectory(long directoryId)645         public static boolean isRemoteDirectory(long directoryId) {
646             return isRemoteDirectoryId(directoryId);
647         }
648 
649         /**
650          * Return TRUE if a directory ID is from the contacts provider on the enterprise profile.
651          *
652          */
isEnterpriseDirectoryId(long directoryId)653         public static boolean isEnterpriseDirectoryId(long directoryId) {
654             return directoryId >= ENTERPRISE_DIRECTORY_ID_BASE;
655         }
656 
657         /**
658          * Notifies the system of a change in the list of directories handled by
659          * a particular directory provider. The Contacts provider will turn around
660          * and send a query to the directory provider for the full list of directories,
661          * which will replace the previous list.
662          */
notifyDirectoryChange(ContentResolver resolver)663         public static void notifyDirectoryChange(ContentResolver resolver) {
664             // This is done to trigger a query by Contacts Provider back to the directory provider.
665             // No data needs to be sent back, because the provider can infer the calling
666             // package from binder.
667             ContentValues contentValues = new ContentValues();
668             resolver.update(Directory.CONTENT_URI, contentValues, null, null);
669         }
670 
671         /**
672          * A query parameter that's passed to directory providers which indicates the client
673          * package name that has made the query requests.
674          */
675         public static final String CALLER_PACKAGE_PARAM_KEY = "callerPackage";
676     }
677 
678     /**
679      * @hide should be removed when users are updated to refer to SyncState
680      * @deprecated use SyncState instead
681      */
682     @Deprecated
683     public interface SyncStateColumns extends SyncStateContract.Columns {
684     }
685 
686     /**
687      * A table provided for sync adapters to use for storing private sync state data for contacts.
688      *
689      * @see SyncStateContract
690      */
691     public static final class SyncState implements SyncStateContract.Columns {
692         /**
693          * This utility class cannot be instantiated
694          */
SyncState()695         private SyncState() {}
696 
697         public static final String CONTENT_DIRECTORY =
698                 SyncStateContract.Constants.CONTENT_DIRECTORY;
699 
700         /**
701          * The content:// style URI for this table
702          */
703         public static final Uri CONTENT_URI =
704                 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
705 
706         /**
707          * @see android.provider.SyncStateContract.Helpers#get
708          */
get(ContentProviderClient provider, Account account)709         public static byte[] get(ContentProviderClient provider, Account account)
710                 throws RemoteException {
711             return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
712         }
713 
714         /**
715          * @see android.provider.SyncStateContract.Helpers#get
716          */
getWithUri(ContentProviderClient provider, Account account)717         public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
718                 throws RemoteException {
719             return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
720         }
721 
722         /**
723          * @see android.provider.SyncStateContract.Helpers#set
724          */
set(ContentProviderClient provider, Account account, byte[] data)725         public static void set(ContentProviderClient provider, Account account, byte[] data)
726                 throws RemoteException {
727             SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
728         }
729 
730         /**
731          * @see android.provider.SyncStateContract.Helpers#newSetOperation
732          */
newSetOperation(Account account, byte[] data)733         public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
734             return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
735         }
736     }
737 
738 
739     /**
740      * A table provided for sync adapters to use for storing private sync state data for the
741      * user's personal profile.
742      *
743      * @see SyncStateContract
744      */
745     public static final class ProfileSyncState implements SyncStateContract.Columns {
746         /**
747          * This utility class cannot be instantiated
748          */
ProfileSyncState()749         private ProfileSyncState() {}
750 
751         public static final String CONTENT_DIRECTORY =
752                 SyncStateContract.Constants.CONTENT_DIRECTORY;
753 
754         /**
755          * The content:// style URI for this table
756          */
757         public static final Uri CONTENT_URI =
758                 Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY);
759 
760         /**
761          * @see android.provider.SyncStateContract.Helpers#get
762          */
get(ContentProviderClient provider, Account account)763         public static byte[] get(ContentProviderClient provider, Account account)
764                 throws RemoteException {
765             return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
766         }
767 
768         /**
769          * @see android.provider.SyncStateContract.Helpers#get
770          */
getWithUri(ContentProviderClient provider, Account account)771         public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
772                 throws RemoteException {
773             return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
774         }
775 
776         /**
777          * @see android.provider.SyncStateContract.Helpers#set
778          */
set(ContentProviderClient provider, Account account, byte[] data)779         public static void set(ContentProviderClient provider, Account account, byte[] data)
780                 throws RemoteException {
781             SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
782         }
783 
784         /**
785          * @see android.provider.SyncStateContract.Helpers#newSetOperation
786          */
newSetOperation(Account account, byte[] data)787         public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
788             return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
789         }
790     }
791 
792     /**
793      * Generic columns for use by sync adapters. The specific functions of
794      * these columns are private to the sync adapter. Other clients of the API
795      * should not attempt to either read or write this column.
796      *
797      * @see RawContacts
798      * @see Groups
799      */
800     protected interface BaseSyncColumns {
801 
802         /** Generic column for use by sync adapters. */
803         public static final String SYNC1 = "sync1";
804         /** Generic column for use by sync adapters. */
805         public static final String SYNC2 = "sync2";
806         /** Generic column for use by sync adapters. */
807         public static final String SYNC3 = "sync3";
808         /** Generic column for use by sync adapters. */
809         public static final String SYNC4 = "sync4";
810     }
811 
812     /**
813      * Columns that appear when each row of a table belongs to a specific
814      * account, including sync information that an account may need.
815      *
816      * @see RawContacts
817      * @see Groups
818      */
819     protected interface SyncColumns extends BaseSyncColumns {
820         /**
821          * The name of the account instance to which this row belongs, which when paired with
822          * {@link #ACCOUNT_TYPE} identifies a specific account.
823          * <P>Type: TEXT</P>
824          */
825         public static final String ACCOUNT_NAME = "account_name";
826 
827         /**
828          * The type of account to which this row belongs, which when paired with
829          * {@link #ACCOUNT_NAME} identifies a specific account.
830          * <P>Type: TEXT</P>
831          */
832         public static final String ACCOUNT_TYPE = "account_type";
833 
834         /**
835          * String that uniquely identifies this row to its source account.
836          * <P>Type: TEXT</P>
837          */
838         public static final String SOURCE_ID = "sourceid";
839 
840         /**
841          * Version number that is updated whenever this row or its related data
842          * changes.
843          * <P>Type: INTEGER</P>
844          */
845         public static final String VERSION = "version";
846 
847         /**
848          * Flag indicating that {@link #VERSION} has changed, and this row needs
849          * to be synchronized by its owning account.
850          * <P>Type: INTEGER (boolean)</P>
851          */
852         public static final String DIRTY = "dirty";
853     }
854 
855     /**
856      * Columns of {@link ContactsContract.Contacts} that track the user's
857      * preferences for, or interactions with, the contact.
858      *
859      * @see Contacts
860      * @see RawContacts
861      * @see ContactsContract.Data
862      * @see PhoneLookup
863      * @see ContactsContract.Contacts.AggregationSuggestions
864      */
865     protected interface ContactOptionsColumns {
866         /**
867          * The number of times a contact has been contacted
868          * <P>Type: INTEGER</P>
869          */
870         public static final String TIMES_CONTACTED = "times_contacted";
871 
872         /**
873          * The last time a contact was contacted.
874          * <P>Type: INTEGER</P>
875          */
876         public static final String LAST_TIME_CONTACTED = "last_time_contacted";
877 
878         /** @hide Raw value. */
879         public static final String RAW_TIMES_CONTACTED = HIDDEN_COLUMN_PREFIX + TIMES_CONTACTED;
880 
881         /** @hide Raw value. */
882         public static final String RAW_LAST_TIME_CONTACTED =
883                 HIDDEN_COLUMN_PREFIX + LAST_TIME_CONTACTED;
884 
885         /**
886          * @hide
887          * Low res version.  Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification.
888          */
889         public static final String LR_TIMES_CONTACTED = TIMES_CONTACTED;
890 
891         /**
892          * @hide
893          * Low res version.  Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification.
894          */
895         public static final String LR_LAST_TIME_CONTACTED = LAST_TIME_CONTACTED;
896 
897         /**
898          * Is the contact starred?
899          * <P>Type: INTEGER (boolean)</P>
900          */
901         public static final String STARRED = "starred";
902 
903         /**
904          * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED},
905          * the contact is not pinned. Also see {@link PinnedPositions}.
906          * <P>Type: INTEGER </P>
907          */
908         public static final String PINNED = "pinned";
909 
910         /**
911          * URI for a custom ringtone associated with the contact. If null or missing,
912          * the default ringtone is used.
913          * <P>Type: TEXT (URI to the ringtone)</P>
914          */
915         public static final String CUSTOM_RINGTONE = "custom_ringtone";
916 
917         /**
918          * Whether the contact should always be sent to voicemail. If missing,
919          * defaults to false.
920          * <P>Type: INTEGER (0 for false, 1 for true)</P>
921          */
922         public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
923     }
924 
925     /**
926      * Columns of {@link ContactsContract.Contacts} that refer to intrinsic
927      * properties of the contact, as opposed to the user-specified options
928      * found in {@link ContactOptionsColumns}.
929      *
930      * @see Contacts
931      * @see ContactsContract.Data
932      * @see PhoneLookup
933      * @see ContactsContract.Contacts.AggregationSuggestions
934      */
935     protected interface ContactsColumns {
936         /**
937          * The display name for the contact.
938          * <P>Type: TEXT</P>
939          */
940         public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY;
941 
942         /**
943          * Reference to the row in the RawContacts table holding the contact name.
944          * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P>
945          */
946         public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
947 
948         /**
949          * Reference to the row in the data table holding the photo.  A photo can
950          * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI}
951          * and {@link #PHOTO_URI}).
952          * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI},
953          * which is a more generic mechanism for referencing the contact photo, especially for
954          * contacts returned by non-local directories (see {@link Directory}).
955          *
956          * <P>Type: INTEGER REFERENCES data(_id)</P>
957          */
958         public static final String PHOTO_ID = "photo_id";
959 
960         /**
961          * Photo file ID of the full-size photo.  If present, this will be used to populate
962          * {@link #PHOTO_URI}.  The ID can also be used with
963          * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo.
964          * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated.
965          *
966          * <P>Type: INTEGER</P>
967          */
968         public static final String PHOTO_FILE_ID = "photo_file_id";
969 
970         /**
971          * A URI that can be used to retrieve the contact's full-size photo.
972          * If PHOTO_FILE_ID is not null, this will be populated with a URI based off
973          * {@link ContactsContract.DisplayPhoto#CONTENT_URI}.  Otherwise, this will
974          * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}.
975          * A photo can be referred to either by a URI (this field) or by ID
976          * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null,
977          * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily
978          * vice versa).  Thus using PHOTO_URI is a more robust method of retrieving
979          * contact photos.
980          *
981          * <P>Type: TEXT</P>
982          */
983         public static final String PHOTO_URI = "photo_uri";
984 
985         /**
986          * A URI that can be used to retrieve a thumbnail of the contact's photo.
987          * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI})
988          * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and
989          * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa).
990          * If the content provider does not differentiate between full-size photos
991          * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain
992          * the same value, but either both shall be null or both not null.
993          *
994          * <P>Type: TEXT</P>
995          */
996         public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri";
997 
998         /**
999          * Flag that reflects whether the contact exists inside the default directory.
1000          * Ie, whether the contact is designed to only be visible outside search.
1001          */
1002         public static final String IN_DEFAULT_DIRECTORY = "in_default_directory";
1003 
1004         /**
1005          * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any
1006          * {@link CommonDataKinds.GroupMembership} for this contact.
1007          */
1008         public static final String IN_VISIBLE_GROUP = "in_visible_group";
1009 
1010         /**
1011          * Flag that reflects whether this contact represents the user's
1012          * personal profile entry.
1013          */
1014         public static final String IS_USER_PROFILE = "is_user_profile";
1015 
1016         /**
1017          * An indicator of whether this contact has at least one phone number. "1" if there is
1018          * at least one phone number, "0" otherwise.
1019          * <P>Type: INTEGER</P>
1020          */
1021         public static final String HAS_PHONE_NUMBER = "has_phone_number";
1022 
1023         /**
1024          * An opaque value that contains hints on how to find the contact if
1025          * its row id changed as a result of a sync or aggregation.
1026          */
1027         public static final String LOOKUP_KEY = "lookup";
1028 
1029         /**
1030          * Timestamp (milliseconds since epoch) of when this contact was last updated.  This
1031          * includes updates to all data associated with this contact including raw contacts.  Any
1032          * modification (including deletes and inserts) of underlying contact data are also
1033          * reflected in this timestamp.
1034          */
1035         public static final String CONTACT_LAST_UPDATED_TIMESTAMP =
1036                 "contact_last_updated_timestamp";
1037     }
1038 
1039     /**
1040      * @see Contacts
1041      */
1042     protected interface ContactStatusColumns {
1043         /**
1044          * Contact presence status. See {@link StatusUpdates} for individual status
1045          * definitions.
1046          * <p>Type: NUMBER</p>
1047          */
1048         public static final String CONTACT_PRESENCE = "contact_presence";
1049 
1050         /**
1051          * Contact Chat Capabilities. See {@link StatusUpdates} for individual
1052          * definitions.
1053          * <p>Type: NUMBER</p>
1054          */
1055         public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability";
1056 
1057         /**
1058          * Contact's latest status update.
1059          * <p>Type: TEXT</p>
1060          */
1061         public static final String CONTACT_STATUS = "contact_status";
1062 
1063         /**
1064          * The absolute time in milliseconds when the latest status was
1065          * inserted/updated.
1066          * <p>Type: NUMBER</p>
1067          */
1068         public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
1069 
1070         /**
1071          * The package containing resources for this status: label and icon.
1072          * <p>Type: TEXT</p>
1073          */
1074         public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
1075 
1076         /**
1077          * The resource ID of the label describing the source of contact
1078          * status, e.g. "Google Talk". This resource is scoped by the
1079          * {@link #CONTACT_STATUS_RES_PACKAGE}.
1080          * <p>Type: NUMBER</p>
1081          */
1082         public static final String CONTACT_STATUS_LABEL = "contact_status_label";
1083 
1084         /**
1085          * The resource ID of the icon for the source of contact status. This
1086          * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
1087          * <p>Type: NUMBER</p>
1088          */
1089         public static final String CONTACT_STATUS_ICON = "contact_status_icon";
1090     }
1091 
1092     /**
1093      * Constants for various styles of combining given name, family name etc into
1094      * a full name.  For example, the western tradition follows the pattern
1095      * 'given name' 'middle name' 'family name' with the alternative pattern being
1096      * 'family name', 'given name' 'middle name'.  The CJK tradition is
1097      * 'family name' 'middle name' 'given name', with Japanese favoring a space between
1098      * the names and Chinese omitting the space.
1099      */
1100     public interface FullNameStyle {
1101         public static final int UNDEFINED = 0;
1102         public static final int WESTERN = 1;
1103 
1104         /**
1105          * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
1106          * which specific language it belongs to: Chinese, Japanese or Korean.
1107          */
1108         public static final int CJK = 2;
1109 
1110         public static final int CHINESE = 3;
1111         public static final int JAPANESE = 4;
1112         public static final int KOREAN = 5;
1113     }
1114 
1115     /**
1116      * Constants for various styles of capturing the pronunciation of a person's name.
1117      */
1118     public interface PhoneticNameStyle {
1119         public static final int UNDEFINED = 0;
1120 
1121         /**
1122          * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
1123          * shown in UIs, but used for searches and sorting.
1124          */
1125         public static final int PINYIN = 3;
1126 
1127         /**
1128          * Hiragana and Katakana are two common styles of writing out the pronunciation
1129          * of a Japanese names.
1130          */
1131         public static final int JAPANESE = 4;
1132 
1133         /**
1134          * Hangul is the Korean phonetic alphabet.
1135          */
1136         public static final int KOREAN = 5;
1137     }
1138 
1139     /**
1140      * Types of data used to produce the display name for a contact. In the order
1141      * of increasing priority: {@link #EMAIL}, {@link #PHONE},
1142      * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_PHONETIC_NAME},
1143      * {@link #STRUCTURED_NAME}.
1144      */
1145     public interface DisplayNameSources {
1146         public static final int UNDEFINED = 0;
1147         public static final int EMAIL = 10;
1148         public static final int PHONE = 20;
1149         public static final int ORGANIZATION = 30;
1150         public static final int NICKNAME = 35;
1151         /** Display name comes from a structured name that only has phonetic components. */
1152         public static final int STRUCTURED_PHONETIC_NAME = 37;
1153         public static final int STRUCTURED_NAME = 40;
1154     }
1155 
1156     /**
1157      * Contact name and contact name metadata columns in the RawContacts table.
1158      *
1159      * @see Contacts
1160      * @see RawContacts
1161      */
1162     protected interface ContactNameColumns {
1163 
1164         /**
1165          * The kind of data that is used as the display name for the contact, such as
1166          * structured name or email address.  See {@link DisplayNameSources}.
1167          */
1168         public static final String DISPLAY_NAME_SOURCE = "display_name_source";
1169 
1170         /**
1171          * <p>
1172          * The standard text shown as the contact's display name, based on the best
1173          * available information for the contact (for example, it might be the email address
1174          * if the name is not available).
1175          * The information actually used to compute the name is stored in
1176          * {@link #DISPLAY_NAME_SOURCE}.
1177          * </p>
1178          * <p>
1179          * A contacts provider is free to choose whatever representation makes most
1180          * sense for its target market.
1181          * For example in the default Android Open Source Project implementation,
1182          * if the display name is
1183          * based on the structured name and the structured name follows
1184          * the Western full-name style, then this field contains the "given name first"
1185          * version of the full name.
1186          * <p>
1187          *
1188          * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE
1189          */
1190         public static final String DISPLAY_NAME_PRIMARY = "display_name";
1191 
1192         /**
1193          * <p>
1194          * An alternative representation of the display name, such as "family name first"
1195          * instead of "given name first" for Western names.  If an alternative is not
1196          * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}.
1197          * </p>
1198          * <p>
1199          * A contacts provider is free to provide alternatives as necessary for
1200          * its target market.
1201          * For example the default Android Open Source Project contacts provider
1202          * currently provides an
1203          * alternative in a single case:  if the display name is
1204          * based on the structured name and the structured name follows
1205          * the Western full name style, then the field contains the "family name first"
1206          * version of the full name.
1207          * Other cases may be added later.
1208          * </p>
1209          */
1210         public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
1211 
1212         /**
1213          * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}.  See
1214          * {@link PhoneticNameStyle}.
1215          */
1216         public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
1217 
1218         /**
1219          * <p>
1220          * Pronunciation of the full name in the phonetic alphabet specified by
1221          * {@link #PHONETIC_NAME_STYLE}.
1222          * </p>
1223          * <p>
1224          * The value may be set manually by the user. This capability is of
1225          * interest only in countries with commonly used phonetic alphabets,
1226          * such as Japan and Korea. See {@link PhoneticNameStyle}.
1227          * </p>
1228          */
1229         public static final String PHONETIC_NAME = "phonetic_name";
1230 
1231         /**
1232          * Sort key that takes into account locale-based traditions for sorting
1233          * names in address books.  The default
1234          * sort key is {@link #DISPLAY_NAME_PRIMARY}.  For Chinese names
1235          * the sort key is the name's Pinyin spelling, and for Japanese names
1236          * it is the Hiragana version of the phonetic name.
1237          */
1238         public static final String SORT_KEY_PRIMARY = "sort_key";
1239 
1240         /**
1241          * Sort key based on the alternative representation of the full name,
1242          * {@link #DISPLAY_NAME_ALTERNATIVE}.  Thus for Western names,
1243          * it is the one using the "family name first" format.
1244          */
1245         public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
1246     }
1247 
1248     interface ContactCounts {
1249 
1250         /**
1251          * Add this query parameter to a URI to get back row counts grouped by the address book
1252          * index as cursor extras. For most languages it is the first letter of the sort key. This
1253          * parameter does not affect the main content of the cursor.
1254          *
1255          * <p>
1256          * <pre>
1257          * Example:
1258          *
1259          * import android.provider.ContactsContract.Contacts;
1260          *
1261          * Uri uri = Contacts.CONTENT_URI.buildUpon()
1262          *          .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true")
1263          *          .build();
1264          * Cursor cursor = getContentResolver().query(uri,
1265          *          new String[] {Contacts.DISPLAY_NAME},
1266          *          null, null, null);
1267          * Bundle bundle = cursor.getExtras();
1268          * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) &&
1269          *         bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) {
1270          *     String sections[] =
1271          *             bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
1272          *     int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
1273          * }
1274          * </pre>
1275          * </p>
1276          */
1277         public static final String EXTRA_ADDRESS_BOOK_INDEX =
1278                 "android.provider.extra.ADDRESS_BOOK_INDEX";
1279 
1280         /**
1281          * The array of address book index titles, which are returned in the
1282          * same order as the data in the cursor.
1283          * <p>TYPE: String[]</p>
1284          */
1285         public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES =
1286                 "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
1287 
1288         /**
1289          * The array of group counts for the corresponding group.  Contains the same number
1290          * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
1291          * <p>TYPE: int[]</p>
1292          */
1293         public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS =
1294                 "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
1295     }
1296 
1297     /**
1298      * Constants for the contacts table, which contains a record per aggregate
1299      * of raw contacts representing the same person.
1300      * <h3>Operations</h3>
1301      * <dl>
1302      * <dt><b>Insert</b></dt>
1303      * <dd>A Contact cannot be created explicitly. When a raw contact is
1304      * inserted, the provider will first try to find a Contact representing the
1305      * same person. If one is found, the raw contact's
1306      * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
1307      * Contact. If no match is found, the provider automatically inserts a new
1308      * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
1309      * of the newly inserted raw contact.</dd>
1310      * <dt><b>Update</b></dt>
1311      * <dd>Only certain columns of Contact are modifiable:
1312      * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
1313      * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
1314      * these columns on the Contact also changes them on all constituent raw
1315      * contacts.</dd>
1316      * <dt><b>Delete</b></dt>
1317      * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
1318      * deletes all constituent raw contacts. The corresponding sync adapters
1319      * will notice the deletions of their respective raw contacts and remove
1320      * them from their back end storage.</dd>
1321      * <dt><b>Query</b></dt>
1322      * <dd>
1323      * <ul>
1324      * <li>If you need to read an individual contact, consider using
1325      * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
1326      * <li>If you need to look up a contact by the phone number, use
1327      * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
1328      * which is optimized for this purpose.</li>
1329      * <li>If you need to look up a contact by partial name, e.g. to produce
1330      * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
1331      * <li>If you need to look up a contact by some data element like email
1332      * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
1333      * The result will contain contact ID, name etc.
1334      * </ul>
1335      * </dd>
1336      * </dl>
1337      * <h2>Columns</h2>
1338      * <table class="jd-sumtable">
1339      * <tr>
1340      * <th colspan='4'>Contacts</th>
1341      * </tr>
1342      * <tr>
1343      * <td>long</td>
1344      * <td>{@link #_ID}</td>
1345      * <td>read-only</td>
1346      * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
1347      * </tr>
1348      * <tr>
1349      * <td>String</td>
1350      * <td>{@link #LOOKUP_KEY}</td>
1351      * <td>read-only</td>
1352      * <td>An opaque value that contains hints on how to find the contact if its
1353      * row id changed as a result of a sync or aggregation.</td>
1354      * </tr>
1355      * <tr>
1356      * <td>long</td>
1357      * <td>NAME_RAW_CONTACT_ID</td>
1358      * <td>read-only</td>
1359      * <td>The ID of the raw contact that contributes the display name
1360      * to the aggregate contact. During aggregation one of the constituent
1361      * raw contacts is chosen using a heuristic: a longer name or a name
1362      * with more diacritic marks or more upper case characters is chosen.</td>
1363      * </tr>
1364      * <tr>
1365      * <td>String</td>
1366      * <td>DISPLAY_NAME_PRIMARY</td>
1367      * <td>read-only</td>
1368      * <td>The display name for the contact. It is the display name
1369      * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
1370      * column.</td>
1371      * </tr>
1372      * <tr>
1373      * <td>long</td>
1374      * <td>{@link #PHOTO_ID}</td>
1375      * <td>read-only</td>
1376      * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
1377      * That row has the mime type
1378      * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
1379      * is computed automatically based on the
1380      * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
1381      * that mime type.</td>
1382      * </tr>
1383      * <tr>
1384      * <td>long</td>
1385      * <td>{@link #PHOTO_URI}</td>
1386      * <td>read-only</td>
1387      * <td>A URI that can be used to retrieve the contact's full-size photo. This
1388      * column is the preferred method of retrieving the contact photo.</td>
1389      * </tr>
1390      * <tr>
1391      * <td>long</td>
1392      * <td>{@link #PHOTO_THUMBNAIL_URI}</td>
1393      * <td>read-only</td>
1394      * <td>A URI that can be used to retrieve the thumbnail of contact's photo.  This
1395      * column is the preferred method of retrieving the contact photo.</td>
1396      * </tr>
1397      * <tr>
1398      * <td>int</td>
1399      * <td>{@link #IN_VISIBLE_GROUP}</td>
1400      * <td>read-only</td>
1401      * <td>An indicator of whether this contact is supposed to be visible in the
1402      * UI. "1" if the contact has at least one raw contact that belongs to a
1403      * visible group; "0" otherwise.</td>
1404      * </tr>
1405      * <tr>
1406      * <td>int</td>
1407      * <td>{@link #HAS_PHONE_NUMBER}</td>
1408      * <td>read-only</td>
1409      * <td>An indicator of whether this contact has at least one phone number.
1410      * "1" if there is at least one phone number, "0" otherwise.</td>
1411      * </tr>
1412      * <tr>
1413      * <td>int</td>
1414      * <td>{@link #TIMES_CONTACTED}</td>
1415      * <td>read/write</td>
1416      * <td>The number of times the contact has been contacted. See
1417      * {@link #markAsContacted}. When raw contacts are aggregated, this field is
1418      * computed automatically as the maximum number of times contacted among all
1419      * constituent raw contacts. Setting this field automatically changes the
1420      * corresponding field on all constituent raw contacts.</td>
1421      * </tr>
1422      * <tr>
1423      * <td>long</td>
1424      * <td>{@link #LAST_TIME_CONTACTED}</td>
1425      * <td>read/write</td>
1426      * <td>The timestamp of the last time the contact was contacted. See
1427      * {@link #markAsContacted}. Setting this field also automatically
1428      * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
1429      * this field is computed automatically as the latest time contacted of all
1430      * constituent raw contacts. Setting this field automatically changes the
1431      * corresponding field on all constituent raw contacts.</td>
1432      * </tr>
1433      * <tr>
1434      * <td>int</td>
1435      * <td>{@link #STARRED}</td>
1436      * <td>read/write</td>
1437      * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
1438      * When raw contacts are aggregated, this field is automatically computed:
1439      * if any constituent raw contacts are starred, then this field is set to
1440      * '1'. Setting this field automatically changes the corresponding field on
1441      * all constituent raw contacts.</td>
1442      * </tr>
1443      * <tr>
1444      * <td>String</td>
1445      * <td>{@link #CUSTOM_RINGTONE}</td>
1446      * <td>read/write</td>
1447      * <td>A custom ringtone associated with a contact. Typically this is the
1448      * URI returned by an activity launched with the
1449      * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
1450      * </tr>
1451      * <tr>
1452      * <td>int</td>
1453      * <td>{@link #SEND_TO_VOICEMAIL}</td>
1454      * <td>read/write</td>
1455      * <td>An indicator of whether calls from this contact should be forwarded
1456      * directly to voice mail ('1') or not ('0'). When raw contacts are
1457      * aggregated, this field is automatically computed: if <i>all</i>
1458      * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
1459      * to '1'. Setting this field automatically changes the corresponding field
1460      * on all constituent raw contacts.</td>
1461      * </tr>
1462      * <tr>
1463      * <td>int</td>
1464      * <td>{@link #CONTACT_PRESENCE}</td>
1465      * <td>read-only</td>
1466      * <td>Contact IM presence status. See {@link StatusUpdates} for individual
1467      * status definitions. Automatically computed as the highest presence of all
1468      * constituent raw contacts. The provider may choose not to store this value
1469      * in persistent storage. The expectation is that presence status will be
1470      * updated on a regular basis.</td>
1471      * </tr>
1472      * <tr>
1473      * <td>String</td>
1474      * <td>{@link #CONTACT_STATUS}</td>
1475      * <td>read-only</td>
1476      * <td>Contact's latest status update. Automatically computed as the latest
1477      * of all constituent raw contacts' status updates.</td>
1478      * </tr>
1479      * <tr>
1480      * <td>long</td>
1481      * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
1482      * <td>read-only</td>
1483      * <td>The absolute time in milliseconds when the latest status was
1484      * inserted/updated.</td>
1485      * </tr>
1486      * <tr>
1487      * <td>String</td>
1488      * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
1489      * <td>read-only</td>
1490      * <td> The package containing resources for this status: label and icon.</td>
1491      * </tr>
1492      * <tr>
1493      * <td>long</td>
1494      * <td>{@link #CONTACT_STATUS_LABEL}</td>
1495      * <td>read-only</td>
1496      * <td>The resource ID of the label describing the source of contact status,
1497      * e.g. "Google Talk". This resource is scoped by the
1498      * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1499      * </tr>
1500      * <tr>
1501      * <td>long</td>
1502      * <td>{@link #CONTACT_STATUS_ICON}</td>
1503      * <td>read-only</td>
1504      * <td>The resource ID of the icon for the source of contact status. This
1505      * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1506      * </tr>
1507      * </table>
1508      */
1509     public static class Contacts implements BaseColumns, ContactsColumns,
1510             ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts {
1511         /**
1512          * This utility class cannot be instantiated
1513          */
Contacts()1514         private Contacts()  {}
1515 
1516         /**
1517          * The content:// style URI for this table
1518          */
1519         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
1520 
1521         /**
1522          * Special contacts URI to refer to contacts on the corp profile from the personal
1523          * profile.
1524          *
1525          * It's supported only by a few specific places for referring to contact pictures that
1526          * are in the corp provider for enterprise caller-ID.  Contact picture URIs returned from
1527          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI.
1528          *
1529          * @hide
1530          */
1531         public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
1532                 "contacts_corp");
1533 
1534         /**
1535          * A content:// style URI for this table that should be used to create
1536          * shortcuts or otherwise create long-term links to contacts. This URI
1537          * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
1538          * It can optionally also have a "/" and last known contact ID appended after
1539          * that. This "complete" format is an important optimization and is highly recommended.
1540          * <p>
1541          * As long as the contact's row ID remains the same, this URI is
1542          * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
1543          * as a result of a sync or aggregation, this URI will look up the
1544          * contact using indirect information (sync IDs or constituent raw
1545          * contacts).
1546          * <p>
1547          * Lookup key should be appended unencoded - it is stored in the encoded
1548          * form, ready for use in a URI.
1549          */
1550         public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1551                 "lookup");
1552 
1553         /**
1554          * Base {@link Uri} for referencing a single {@link Contacts} entry,
1555          * created by appending {@link #LOOKUP_KEY} using
1556          * {@link Uri#withAppendedPath(Uri, String)}. Provides
1557          * {@link OpenableColumns} columns when queried, or returns the
1558          * referenced contact formatted as a vCard when opened through
1559          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1560          */
1561         public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1562                 "as_vcard");
1563 
1564        /**
1565         * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI}
1566         * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned
1567         * vcard should not contain a photo.
1568         *
1569         * This is useful for obtaining a space efficient vcard.
1570         */
1571         public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "no_photo";
1572 
1573         /**
1574          * Base {@link Uri} for referencing multiple {@link Contacts} entry,
1575          * created by appending {@link #LOOKUP_KEY} using
1576          * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
1577          * joined with the colon (":") separator, and the resulting string encoded.
1578          *
1579          * Provides {@link OpenableColumns} columns when queried, or returns the
1580          * referenced contact formatted as a vCard when opened through
1581          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1582          *
1583          * <p>
1584          * Usage example:
1585          * <dl>
1586          * <dt>The following code snippet creates a multi-vcard URI that references all the
1587          * contacts in a user's database.</dt>
1588          * <dd>
1589          *
1590          * <pre>
1591          * public Uri getAllContactsVcardUri() {
1592          *     Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI,
1593          *         new String[] {Contacts.LOOKUP_KEY}, null, null, null);
1594          *     if (cursor == null) {
1595          *         return null;
1596          *     }
1597          *     try {
1598          *         StringBuilder uriListBuilder = new StringBuilder();
1599          *         int index = 0;
1600          *         while (cursor.moveToNext()) {
1601          *             if (index != 0) uriListBuilder.append(':');
1602          *             uriListBuilder.append(cursor.getString(0));
1603          *             index++;
1604          *         }
1605          *         return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI,
1606          *                 Uri.encode(uriListBuilder.toString()));
1607          *     } finally {
1608          *         cursor.close();
1609          *     }
1610          * }
1611          * </pre>
1612          *
1613          * </p>
1614          */
1615         public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1616                 "as_multi_vcard");
1617 
1618         /**
1619          * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
1620          * requested {@link Contacts} entry.
1621          *
1622          * @param contactUri A {@link #CONTENT_URI} row, or an existing
1623          *            {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
1624          */
getLookupUri(ContentResolver resolver, Uri contactUri)1625         public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
1626             final Cursor c = resolver.query(contactUri, new String[] {
1627                     Contacts.LOOKUP_KEY, Contacts._ID
1628             }, null, null, null);
1629             if (c == null) {
1630                 return null;
1631             }
1632 
1633             try {
1634                 if (c.moveToFirst()) {
1635                     final String lookupKey = c.getString(0);
1636                     final long contactId = c.getLong(1);
1637                     return getLookupUri(contactId, lookupKey);
1638                 }
1639             } finally {
1640                 c.close();
1641             }
1642             return null;
1643         }
1644 
1645         /**
1646          * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
1647          * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
1648          * <p>
1649          * Returns null if unable to construct a valid lookup URI from the
1650          * provided parameters.
1651          */
getLookupUri(long contactId, String lookupKey)1652         public static Uri getLookupUri(long contactId, String lookupKey) {
1653             if (TextUtils.isEmpty(lookupKey)) {
1654                 return null;
1655             }
1656             return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
1657                     lookupKey), contactId);
1658         }
1659 
1660         /**
1661          * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
1662          * <p>
1663          * Returns null if the contact cannot be found.
1664          */
lookupContact(ContentResolver resolver, Uri lookupUri)1665         public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
1666             if (lookupUri == null) {
1667                 return null;
1668             }
1669 
1670             Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
1671             if (c == null) {
1672                 return null;
1673             }
1674 
1675             try {
1676                 if (c.moveToFirst()) {
1677                     long contactId = c.getLong(0);
1678                     return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1679                 }
1680             } finally {
1681                 c.close();
1682             }
1683             return null;
1684         }
1685 
1686         /**
1687          * Mark a contact as having been contacted. Updates two fields:
1688          * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The
1689          * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED
1690          * field is populated with the current system time.
1691          *
1692          * @param resolver the ContentResolver to use
1693          * @param contactId the person who was contacted
1694          *
1695          * @deprecated The class DataUsageStatUpdater of the Android support library should
1696          *     be used instead.
1697          */
1698         @Deprecated
markAsContacted(ContentResolver resolver, long contactId)1699         public static void markAsContacted(ContentResolver resolver, long contactId) {
1700             Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
1701             ContentValues values = new ContentValues();
1702             // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
1703             values.put(LR_LAST_TIME_CONTACTED, System.currentTimeMillis());
1704             resolver.update(uri, values, null, null);
1705         }
1706 
1707         /**
1708          * The content:// style URI used for "type-to-filter" functionality on the
1709          * {@link #CONTENT_URI} URI. The filter string will be used to match
1710          * various parts of the contact name. The filter argument should be passed
1711          * as an additional path segment after this URI.
1712          */
1713         public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
1714                 CONTENT_URI, "filter");
1715 
1716         /**
1717          * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
1718          * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in parameters,
1719          * otherwise it will throw IllegalArgumentException.
1720          */
1721         public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
1722                 CONTENT_URI, "filter_enterprise");
1723 
1724         /**
1725          * The content:// style URI for this table joined with useful data from
1726          * {@link ContactsContract.Data}, filtered to include only starred contacts
1727          * and the most frequently contacted contacts.
1728          */
1729         public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
1730                 CONTENT_URI, "strequent");
1731 
1732         /**
1733          * The content:// style URI for showing a list of frequently contacted people.
1734          */
1735         public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath(
1736                 CONTENT_URI, "frequent");
1737 
1738         /**
1739          * The content:// style URI used for "type-to-filter" functionality on the
1740          * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
1741          * various parts of the contact name. The filter argument should be passed
1742          * as an additional path segment after this URI.
1743          */
1744         public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
1745                 CONTENT_STREQUENT_URI, "filter");
1746 
1747         public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
1748                 CONTENT_URI, "group");
1749 
1750         /**
1751          * The MIME type of {@link #CONTENT_URI} providing a directory of
1752          * people.
1753          */
1754         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
1755 
1756         /**
1757          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1758          * person.
1759          */
1760         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
1761 
1762         /**
1763          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1764          * person.
1765          */
1766         public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
1767 
1768         /**
1769          * Mimimal ID for corp contacts returned from
1770          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
1771          *
1772          * @hide
1773          */
1774         public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
1775 
1776         /**
1777          * Prefix for corp contacts returned from
1778          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
1779          *
1780          * @hide
1781          */
1782         public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-";
1783 
1784         /**
1785          * Return TRUE if a contact ID is from the contacts provider on the enterprise profile.
1786          *
1787          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact.
1788          */
isEnterpriseContactId(long contactId)1789         public static boolean isEnterpriseContactId(long contactId) {
1790             return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
1791         }
1792 
1793         /**
1794          * A sub-directory of a single contact that contains all of the constituent raw contact
1795          * {@link ContactsContract.Data} rows.  This directory can be used either
1796          * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
1797          */
1798         public static final class Data implements BaseColumns, DataColumns {
1799             /**
1800              * no public constructor since this is a utility class
1801              */
Data()1802             private Data() {}
1803 
1804             /**
1805              * The directory twig for this sub-table
1806              */
1807             public static final String CONTENT_DIRECTORY = "data";
1808         }
1809 
1810         /**
1811          * <p>
1812          * A sub-directory of a contact that contains all of its
1813          * {@link ContactsContract.RawContacts} as well as
1814          * {@link ContactsContract.Data} rows. To access this directory append
1815          * {@link #CONTENT_DIRECTORY} to the contact URI.
1816          * </p>
1817          * <p>
1818          * Entity has three ID fields: {@link #CONTACT_ID} for the contact,
1819          * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for
1820          * the data rows. Entity always contains at least one row per
1821          * constituent raw contact, even if there are no actual data rows. In
1822          * this case the {@link #DATA_ID} field will be null.
1823          * </p>
1824          * <p>
1825          * Entity reads all data for the entire contact in one transaction, to
1826          * guarantee consistency.  There is significant data duplication
1827          * in the Entity (each row repeats all Contact columns and all RawContact
1828          * columns), so the benefits of transactional consistency should be weighed
1829          * against the cost of transferring large amounts of denormalized data
1830          * from the Provider.
1831          * </p>
1832          * <p>
1833          * To reduce the amount of data duplication the contacts provider and directory
1834          * providers implementing this protocol are allowed to provide common Contacts
1835          * and RawContacts fields in the first row returned for each raw contact only and
1836          * leave them as null in subsequent rows.
1837          * </p>
1838          */
1839         public static final class Entity implements BaseColumns, ContactsColumns,
1840                 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns,
1841                 StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns {
1842             /**
1843              * no public constructor since this is a utility class
1844              */
Entity()1845             private Entity() {
1846             }
1847 
1848             /**
1849              * The directory twig for this sub-table
1850              */
1851             public static final String CONTENT_DIRECTORY = "entities";
1852 
1853             /**
1854              * The ID of the raw contact row.
1855              * <P>Type: INTEGER</P>
1856              */
1857             public static final String RAW_CONTACT_ID = "raw_contact_id";
1858 
1859             /**
1860              * The ID of the data row. The value will be null if this raw contact has no
1861              * data rows.
1862              * <P>Type: INTEGER</P>
1863              */
1864             public static final String DATA_ID = "data_id";
1865         }
1866 
1867         /**
1868          * <p>
1869          * A sub-directory of a single contact that contains all of the constituent raw contact
1870          * {@link ContactsContract.StreamItems} rows.  This directory can be used either
1871          * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
1872          * </p>
1873          * <p>
1874          * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM
1875          * permission.
1876          * </p>
1877          *
1878          * @deprecated - Do not use. This will not be supported in the future. In the future,
1879          * cursors returned from related queries will be empty.
1880          *
1881          * @hide
1882          * @removed
1883          */
1884         @Deprecated
1885         public static final class StreamItems implements StreamItemsColumns {
1886             /**
1887              * no public constructor since this is a utility class
1888              *
1889              * @deprecated - Do not use. This will not be supported in the future. In the future,
1890              * cursors returned from related queries will be empty.
1891              */
1892             @Deprecated
StreamItems()1893             private StreamItems() {}
1894 
1895             /**
1896              * The directory twig for this sub-table
1897              *
1898              * @deprecated - Do not use. This will not be supported in the future. In the future,
1899              * cursors returned from related queries will be empty.
1900              */
1901             @Deprecated
1902             public static final String CONTENT_DIRECTORY = "stream_items";
1903         }
1904 
1905         /**
1906          * <p>
1907          * A <i>read-only</i> sub-directory of a single contact aggregate that
1908          * contains all aggregation suggestions (other contacts). The
1909          * aggregation suggestions are computed based on approximate data
1910          * matches with this contact.
1911          * </p>
1912          * <p>
1913          * <i>Note: this query may be expensive! If you need to use it in bulk,
1914          * make sure the user experience is acceptable when the query runs for a
1915          * long time.</i>
1916          * <p>
1917          * Usage example:
1918          *
1919          * <pre>
1920          * Uri uri = Contacts.CONTENT_URI.buildUpon()
1921          *          .appendEncodedPath(String.valueOf(contactId))
1922          *          .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
1923          *          .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
1924          *          .build()
1925          * Cursor cursor = getContentResolver().query(suggestionsUri,
1926          *          new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
1927          *          null, null, null);
1928          * </pre>
1929          *
1930          * </p>
1931          * <p>
1932          * This directory can be used either with a {@link #CONTENT_URI} or
1933          * {@link #CONTENT_LOOKUP_URI}.
1934          * </p>
1935          */
1936         public static final class AggregationSuggestions implements BaseColumns, ContactsColumns,
1937                 ContactOptionsColumns, ContactStatusColumns {
1938             /**
1939              * No public constructor since this is a utility class
1940              */
AggregationSuggestions()1941             private AggregationSuggestions() {}
1942 
1943             /**
1944              * The directory twig for this sub-table. The URI can be followed by an optional
1945              * type-to-filter, similar to
1946              * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
1947              */
1948             public static final String CONTENT_DIRECTORY = "suggestions";
1949 
1950             /**
1951              * Used to specify what kind of data is supplied for the suggestion query.
1952              *
1953              * @hide
1954              */
1955             public static final String PARAMETER_MATCH_NAME = "name";
1956 
1957             /**
1958              * A convenience builder for aggregation suggestion content URIs.
1959              */
1960             public static final class Builder {
1961                 private long mContactId;
1962                 private final ArrayList<String> mValues = new ArrayList<String>();
1963                 private int mLimit;
1964 
1965                 /**
1966                  * Optional existing contact ID.  If it is not provided, the search
1967                  * will be based exclusively on the values supplied with {@link #addNameParameter}.
1968                  *
1969                  * @param contactId contact to find aggregation suggestions for
1970                  * @return This Builder object to allow for chaining of calls to builder methods
1971                  */
setContactId(long contactId)1972                 public Builder setContactId(long contactId) {
1973                     this.mContactId = contactId;
1974                     return this;
1975                 }
1976 
1977                 /**
1978                  * Add a name to be used when searching for aggregation suggestions.
1979                  *
1980                  * @param name name to find aggregation suggestions for
1981                  * @return This Builder object to allow for chaining of calls to builder methods
1982                  */
addNameParameter(String name)1983                 public Builder addNameParameter(String name) {
1984                     mValues.add(name);
1985                     return this;
1986                 }
1987 
1988                 /**
1989                  * Sets the Maximum number of suggested aggregations that should be returned.
1990                  * @param limit The maximum number of suggested aggregations
1991                  *
1992                  * @return This Builder object to allow for chaining of calls to builder methods
1993                  */
setLimit(int limit)1994                 public Builder setLimit(int limit) {
1995                     mLimit = limit;
1996                     return this;
1997                 }
1998 
1999                 /**
2000                  * Combine all of the options that have been set and return a new {@link Uri}
2001                  * object for fetching aggregation suggestions.
2002                  */
build()2003                 public Uri build() {
2004                     android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon();
2005                     builder.appendEncodedPath(String.valueOf(mContactId));
2006                     builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY);
2007                     if (mLimit != 0) {
2008                         builder.appendQueryParameter("limit", String.valueOf(mLimit));
2009                     }
2010 
2011                     int count = mValues.size();
2012                     for (int i = 0; i < count; i++) {
2013                         builder.appendQueryParameter("query", PARAMETER_MATCH_NAME
2014                                 + ":" + mValues.get(i));
2015                     }
2016 
2017                     return builder.build();
2018                 }
2019             }
2020 
2021             /**
2022              * @hide
2023              */
builder()2024             public static final Builder builder() {
2025                 return new Builder();
2026             }
2027         }
2028 
2029         /**
2030          * A <i>read-only</i> sub-directory of a single contact that contains
2031          * the contact's primary photo.  The photo may be stored in up to two ways -
2032          * the default "photo" is a thumbnail-sized image stored directly in the data
2033          * row, while the "display photo", if present, is a larger version stored as
2034          * a file.
2035          * <p>
2036          * Usage example:
2037          * <dl>
2038          * <dt>Retrieving the thumbnail-sized photo</dt>
2039          * <dd>
2040          * <pre>
2041          * public InputStream openPhoto(long contactId) {
2042          *     Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
2043          *     Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
2044          *     Cursor cursor = getContentResolver().query(photoUri,
2045          *          new String[] {Contacts.Photo.PHOTO}, null, null, null);
2046          *     if (cursor == null) {
2047          *         return null;
2048          *     }
2049          *     try {
2050          *         if (cursor.moveToFirst()) {
2051          *             byte[] data = cursor.getBlob(0);
2052          *             if (data != null) {
2053          *                 return new ByteArrayInputStream(data);
2054          *             }
2055          *         }
2056          *     } finally {
2057          *         cursor.close();
2058          *     }
2059          *     return null;
2060          * }
2061          * </pre>
2062          * </dd>
2063          * <dt>Retrieving the larger photo version</dt>
2064          * <dd>
2065          * <pre>
2066          * public InputStream openDisplayPhoto(long contactId) {
2067          *     Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
2068          *     Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
2069          *     try {
2070          *         AssetFileDescriptor fd =
2071          *             getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
2072          *         return fd.createInputStream();
2073          *     } catch (IOException e) {
2074          *         return null;
2075          *     }
2076          * }
2077          * </pre>
2078          * </dd>
2079          * </dl>
2080          *
2081          * </p>
2082          * <p>You may also consider using the convenience method
2083          * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)}
2084          * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo.
2085          * </p>
2086          * <p>
2087          * This directory can be used either with a {@link #CONTENT_URI} or
2088          * {@link #CONTENT_LOOKUP_URI}.
2089          * </p>
2090          */
2091         public static final class Photo implements BaseColumns, DataColumnsWithJoins {
2092             /**
2093              * no public constructor since this is a utility class
2094              */
Photo()2095             private Photo() {}
2096 
2097             /**
2098              * The directory twig for this sub-table
2099              */
2100             public static final String CONTENT_DIRECTORY = "photo";
2101 
2102             /**
2103              * The directory twig for retrieving the full-size display photo.
2104              */
2105             public static final String DISPLAY_PHOTO = "display_photo";
2106 
2107             /**
2108              * Full-size photo file ID of the raw contact.
2109              * See {@link ContactsContract.DisplayPhoto}.
2110              * <p>
2111              * Type: NUMBER
2112              */
2113             public static final String PHOTO_FILE_ID = DATA14;
2114 
2115             /**
2116              * Thumbnail photo of the raw contact. This is the raw bytes of an image
2117              * that could be inflated using {@link android.graphics.BitmapFactory}.
2118              * <p>
2119              * Type: BLOB
2120              */
2121             public static final String PHOTO = DATA15;
2122         }
2123 
2124         /**
2125          * Opens an InputStream for the contacts's photo and returns the
2126          * photo as a byte stream.
2127          * @param cr The content resolver to use for querying
2128          * @param contactUri the contact whose photo should be used. This can be used with
2129          * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
2130          * @param preferHighres If this is true and the contact has a higher resolution photo
2131          * available, it is returned. If false, this function always tries to get the thumbnail
2132          * @return an InputStream of the photo, or null if no photo is present
2133          */
openContactPhotoInputStream(ContentResolver cr, Uri contactUri, boolean preferHighres)2134         public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri,
2135                 boolean preferHighres) {
2136             if (preferHighres) {
2137                 final Uri displayPhotoUri = Uri.withAppendedPath(contactUri,
2138                         Contacts.Photo.DISPLAY_PHOTO);
2139                 try {
2140                     AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r");
2141                     if (fd != null) {
2142                         return fd.createInputStream();
2143                     }
2144                 } catch (IOException e) {
2145                     // fallback to the thumbnail code
2146                 }
2147            }
2148 
2149             Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
2150             if (photoUri == null) {
2151                 return null;
2152             }
2153             Cursor cursor = cr.query(photoUri,
2154                     new String[] {
2155                         ContactsContract.CommonDataKinds.Photo.PHOTO
2156                     }, null, null, null);
2157             try {
2158                 if (cursor == null || !cursor.moveToNext()) {
2159                     return null;
2160                 }
2161                 byte[] data = cursor.getBlob(0);
2162                 if (data == null) {
2163                     return null;
2164                 }
2165                 return new ByteArrayInputStream(data);
2166             } finally {
2167                 if (cursor != null) {
2168                     cursor.close();
2169                 }
2170             }
2171         }
2172 
2173         /**
2174          * Opens an InputStream for the contacts's thumbnail photo and returns the
2175          * photo as a byte stream.
2176          * @param cr The content resolver to use for querying
2177          * @param contactUri the contact whose photo should be used. This can be used with
2178          * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
2179          * @return an InputStream of the photo, or null if no photo is present
2180          * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead
2181          * of the thumbnail the high-res picture is preferred
2182          */
openContactPhotoInputStream(ContentResolver cr, Uri contactUri)2183         public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
2184             return openContactPhotoInputStream(cr, contactUri, false);
2185         }
2186     }
2187 
2188     /**
2189      * <p>
2190      * Constants for the user's profile data, which is represented as a single contact on
2191      * the device that represents the user.  The profile contact is not aggregated
2192      * together automatically in the same way that normal contacts are; instead, each
2193      * account (including data set, if applicable) on the device may contribute a single
2194      * raw contact representing the user's personal profile data from that source.
2195      * </p>
2196      * <p>
2197      * Access to the profile entry through these URIs (or incidental access to parts of
2198      * the profile if retrieved directly via ID) requires additional permissions beyond
2199      * the read/write contact permissions required by the provider.  Querying for profile
2200      * data requires android.permission.READ_PROFILE permission, and inserting or
2201      * updating profile data requires android.permission.WRITE_PROFILE permission.
2202      * </p>
2203      * <h3>Operations</h3>
2204      * <dl>
2205      * <dt><b>Insert</b></dt>
2206      * <dd>The user's profile entry cannot be created explicitly (attempting to do so
2207      * will throw an exception). When a raw contact is inserted into the profile, the
2208      * provider will check for the existence of a profile on the device.  If one is
2209      * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of
2210      * the profile Contact. If no match is found, the profile Contact is created and
2211      * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly
2212      * inserted raw contact.</dd>
2213      * <dt><b>Update</b></dt>
2214      * <dd>The profile Contact has the same update restrictions as Contacts in general,
2215      * but requires the android.permission.WRITE_PROFILE permission.</dd>
2216      * <dt><b>Delete</b></dt>
2217      * <dd>The profile Contact cannot be explicitly deleted.  It will be removed
2218      * automatically if all of its constituent raw contact entries are deleted.</dd>
2219      * <dt><b>Query</b></dt>
2220      * <dd>
2221      * <ul>
2222      * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as
2223      * retrieving a contact by ID, except that it will only ever return the user's
2224      * profile contact.
2225      * </li>
2226      * <li>
2227      * The profile contact supports all of the same sub-paths as an individual contact
2228      * does - the content of the profile contact can be retrieved as entities or
2229      * data rows.  Similarly, specific raw contact entries can be retrieved by appending
2230      * the desired raw contact ID within the profile.
2231      * </li>
2232      * </ul>
2233      * </dd>
2234      * </dl>
2235      */
2236     public static final class Profile implements BaseColumns, ContactsColumns,
2237             ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
2238         /**
2239          * This utility class cannot be instantiated
2240          */
Profile()2241         private Profile() {
2242         }
2243 
2244         /**
2245          * The content:// style URI for this table, which requests the contact entry
2246          * representing the user's personal profile data.
2247          */
2248         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile");
2249 
2250         /**
2251          * {@link Uri} for referencing the user's profile {@link Contacts} entry,
2252          * Provides {@link OpenableColumns} columns when queried, or returns the
2253          * user's profile contact formatted as a vCard when opened through
2254          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
2255          */
2256         public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
2257                 "as_vcard");
2258 
2259         /**
2260          * {@link Uri} for referencing the raw contacts that make up the user's profile
2261          * {@link Contacts} entry.  An individual raw contact entry within the profile
2262          * can be addressed by appending the raw contact ID.  The entities or data within
2263          * that specific raw contact can be requested by appending the entity or data
2264          * path as well.
2265          */
2266         public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI,
2267                 "raw_contacts");
2268 
2269         /**
2270          * The minimum ID for any entity that belongs to the profile.  This essentially
2271          * defines an ID-space in which profile data is stored, and is used by the provider
2272          * to determine whether a request via a non-profile-specific URI should be directed
2273          * to the profile data rather than general contacts data, along with all the special
2274          * permission checks that entails.
2275          *
2276          * Callers may use {@link #isProfileId} to check whether a specific ID falls into
2277          * the set of data intended for the profile.
2278          */
2279         public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE;
2280     }
2281 
2282     /**
2283      * This method can be used to identify whether the given ID is associated with profile
2284      * data.  It does not necessarily indicate that the ID is tied to valid data, merely
2285      * that accessing data using this ID will result in profile access checks and will only
2286      * return data from the profile.
2287      *
2288      * @param id The ID to check.
2289      * @return Whether the ID is associated with profile data.
2290      */
isProfileId(long id)2291     public static boolean isProfileId(long id) {
2292         return id >= Profile.MIN_ID;
2293     }
2294 
2295     protected interface DeletedContactsColumns {
2296 
2297         /**
2298          * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted.
2299          * <P>Type: INTEGER</P>
2300          */
2301         public static final String CONTACT_ID = "contact_id";
2302 
2303         /**
2304          * Time (milliseconds since epoch) that the contact was deleted.
2305          */
2306         public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp";
2307     }
2308 
2309     /**
2310      * Constants for the deleted contact table.  This table holds a log of deleted contacts.
2311      * <p>
2312      * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted.
2313      */
2314     public static final class DeletedContacts implements DeletedContactsColumns {
2315 
2316         /**
2317          * This utility class cannot be instantiated
2318          */
DeletedContacts()2319         private DeletedContacts() {
2320         }
2321 
2322         /**
2323          * The content:// style URI for this table, which requests a directory of raw contact rows
2324          * matching the selection criteria.
2325          */
2326         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
2327                 "deleted_contacts");
2328 
2329         /**
2330          * Number of days that the delete log will be kept.  After this time, delete records may be
2331          * deleted.
2332          *
2333          * @hide
2334          */
2335         private static final int DAYS_KEPT = 30;
2336 
2337         /**
2338          * Milliseconds that the delete log will be kept.  After this time, delete records may be
2339          * deleted.
2340          */
2341         public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT;
2342     }
2343 
2344     protected interface RawContactsColumns {
2345         /**
2346          * A reference to the {@link ContactsContract.Contacts#_ID} that this
2347          * data belongs to.
2348          * <P>Type: INTEGER</P>
2349          */
2350         public static final String CONTACT_ID = "contact_id";
2351 
2352         /**
2353          * Persistent unique id for each raw_contact within its account.
2354          * This id is provided by its own data source, and can be used to backup metadata
2355          * to the server.
2356          * This should be unique within each set of account_name/account_type/data_set
2357          */
2358         public static final String BACKUP_ID = "backup_id";
2359 
2360         /**
2361          * The data set within the account that this row belongs to.  This allows
2362          * multiple sync adapters for the same account type to distinguish between
2363          * each others' data.
2364          *
2365          * This is empty by default, and is completely optional.  It only needs to
2366          * be populated if multiple sync adapters are entering distinct data for
2367          * the same account type and account name.
2368          * <P>Type: TEXT</P>
2369          */
2370         public static final String DATA_SET = "data_set";
2371 
2372         /**
2373          * A concatenation of the account type and data set (delimited by a forward
2374          * slash) - if the data set is empty, this will be the same as the account
2375          * type.  For applications that need to be aware of the data set, this can
2376          * be used instead of account type to distinguish sets of data.  This is
2377          * never intended to be used for specifying accounts.
2378          * <p>
2379          * This column does *not* escape forward slashes in the account type or the data set.
2380          * If this is an issue, consider using
2381          * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and
2382          * {@link ContactsContract.RawContacts#DATA_SET} directly.
2383          */
2384         public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
2385 
2386         /**
2387          * The aggregation mode for this contact.
2388          * <P>Type: INTEGER</P>
2389          */
2390         public static final String AGGREGATION_MODE = "aggregation_mode";
2391 
2392         /**
2393          * The "deleted" flag: "0" by default, "1" if the row has been marked
2394          * for deletion. When {@link android.content.ContentResolver#delete} is
2395          * called on a raw contact, it is marked for deletion and removed from its
2396          * aggregate contact. The sync adaptor deletes the raw contact on the server and
2397          * then calls ContactResolver.delete once more, this time passing the
2398          * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2399          * the data removal.
2400          * <P>Type: INTEGER</P>
2401          */
2402         public static final String DELETED = "deleted";
2403 
2404         /**
2405          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
2406          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
2407          * <P>Type: INTEGER</P>
2408          */
2409         public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
2410 
2411         /**
2412          * Flag that reflects whether this raw contact belongs to the user's
2413          * personal profile entry.
2414          */
2415         public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile";
2416 
2417         /**
2418          * Flag indicating that a raw contact's metadata has changed, and its metadata
2419          * needs to be synchronized by the server.
2420          * <P>Type: INTEGER (boolean)</P>
2421          */
2422         public static final String METADATA_DIRTY = "metadata_dirty";
2423     }
2424 
2425     /**
2426      * Constants for the raw contacts table, which contains one row of contact
2427      * information for each person in each synced account. Sync adapters and
2428      * contact management apps
2429      * are the primary consumers of this API.
2430      *
2431      * <h3>Aggregation</h3>
2432      * <p>
2433      * As soon as a raw contact is inserted or whenever its constituent data
2434      * changes, the provider will check if the raw contact matches other
2435      * existing raw contacts and if so will aggregate it with those. The
2436      * aggregation is reflected in the {@link RawContacts} table by the change of the
2437      * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
2438      * </p>
2439      * <p>
2440      * Changes to the structured name, organization, phone number, email address,
2441      * or nickname trigger a re-aggregation.
2442      * </p>
2443      * <p>
2444      * See also {@link AggregationExceptions} for a mechanism to control
2445      * aggregation programmatically.
2446      * </p>
2447      *
2448      * <h3>Operations</h3>
2449      * <dl>
2450      * <dt><b>Insert</b></dt>
2451      * <dd>
2452      * <p>
2453      * Raw contacts can be inserted incrementally or in a batch.
2454      * The incremental method is more traditional but less efficient.
2455      * It should be used
2456      * only if no {@link Data} values are available at the time the raw contact is created:
2457      * <pre>
2458      * ContentValues values = new ContentValues();
2459      * values.put(RawContacts.ACCOUNT_TYPE, accountType);
2460      * values.put(RawContacts.ACCOUNT_NAME, accountName);
2461      * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
2462      * long rawContactId = ContentUris.parseId(rawContactUri);
2463      * </pre>
2464      * </p>
2465      * <p>
2466      * Once {@link Data} values become available, insert those.
2467      * For example, here's how you would insert a name:
2468      *
2469      * <pre>
2470      * values.clear();
2471      * values.put(Data.RAW_CONTACT_ID, rawContactId);
2472      * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
2473      * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
2474      * getContentResolver().insert(Data.CONTENT_URI, values);
2475      * </pre>
2476      * </p>
2477      * <p>
2478      * The batch method is by far preferred.  It inserts the raw contact and its
2479      * constituent data rows in a single database transaction
2480      * and causes at most one aggregation pass.
2481      * <pre>
2482      * ArrayList&lt;ContentProviderOperation&gt; ops =
2483      *          new ArrayList&lt;ContentProviderOperation&gt;();
2484      * ...
2485      * int rawContactInsertIndex = ops.size();
2486      * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
2487      *          .withValue(RawContacts.ACCOUNT_TYPE, accountType)
2488      *          .withValue(RawContacts.ACCOUNT_NAME, accountName)
2489      *          .build());
2490      *
2491      * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
2492      *          .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
2493      *          .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
2494      *          .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
2495      *          .build());
2496      *
2497      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2498      * </pre>
2499      * </p>
2500      * <p>
2501      * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
2502      * to refer to the as-yet-unknown index value of the raw contact inserted in the
2503      * first operation.
2504      * </p>
2505      *
2506      * <dt><b>Update</b></dt>
2507      * <dd><p>
2508      * Raw contacts can be updated incrementally or in a batch.
2509      * Batch mode should be used whenever possible.
2510      * The procedures and considerations are analogous to those documented above for inserts.
2511      * </p></dd>
2512      * <dt><b>Delete</b></dt>
2513      * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
2514      * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
2515      * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
2516      * itself is also deleted automatically.
2517      * </p>
2518      * <p>
2519      * The invocation of {@code resolver.delete(...)}, does not immediately delete
2520      * a raw contacts row.
2521      * Instead, it sets the {@link #DELETED} flag on the raw contact and
2522      * removes the raw contact from its aggregate contact.
2523      * The sync adapter then deletes the raw contact from the server and
2524      * finalizes phone-side deletion by calling {@code resolver.delete(...)}
2525      * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
2526      * <p>Some sync adapters are read-only, meaning that they only sync server-side
2527      * changes to the phone, but not the reverse.  If one of those raw contacts
2528      * is marked for deletion, it will remain on the phone.  However it will be
2529      * effectively invisible, because it will not be part of any aggregate contact.
2530      * </dd>
2531      *
2532      * <dt><b>Query</b></dt>
2533      * <dd>
2534      * <p>
2535      * It is easy to find all raw contacts in a Contact:
2536      * <pre>
2537      * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
2538      *          new String[]{RawContacts._ID},
2539      *          RawContacts.CONTACT_ID + "=?",
2540      *          new String[]{String.valueOf(contactId)}, null);
2541      * </pre>
2542      * </p>
2543      * <p>
2544      * To find raw contacts within a specific account,
2545      * you can either put the account name and type in the selection or pass them as query
2546      * parameters.  The latter approach is preferable, especially when you can reuse the
2547      * URI:
2548      * <pre>
2549      * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
2550      *          .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
2551      *          .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
2552      *          .build();
2553      * Cursor c1 = getContentResolver().query(rawContactUri,
2554      *          RawContacts.STARRED + "&lt;&gt;0", null, null, null);
2555      * ...
2556      * Cursor c2 = getContentResolver().query(rawContactUri,
2557      *          RawContacts.DELETED + "&lt;&gt;0", null, null, null);
2558      * </pre>
2559      * </p>
2560      * <p>The best way to read a raw contact along with all the data associated with it is
2561      * by using the {@link Entity} directory. If the raw contact has data rows,
2562      * the Entity cursor will contain a row for each data row.  If the raw contact has no
2563      * data rows, the cursor will still contain one row with the raw contact-level information.
2564      * <pre>
2565      * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
2566      * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
2567      * Cursor c = getContentResolver().query(entityUri,
2568      *          new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
2569      *          null, null, null);
2570      * try {
2571      *     while (c.moveToNext()) {
2572      *         String sourceId = c.getString(0);
2573      *         if (!c.isNull(1)) {
2574      *             String mimeType = c.getString(2);
2575      *             String data = c.getString(3);
2576      *             ...
2577      *         }
2578      *     }
2579      * } finally {
2580      *     c.close();
2581      * }
2582      * </pre>
2583      * </p>
2584      * </dd>
2585      * </dl>
2586      * <h2>Columns</h2>
2587      *
2588      * <table class="jd-sumtable">
2589      * <tr>
2590      * <th colspan='4'>RawContacts</th>
2591      * </tr>
2592      * <tr>
2593      * <td>long</td>
2594      * <td>{@link #_ID}</td>
2595      * <td>read-only</td>
2596      * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
2597      * it is much better for a sync adapter to update a raw contact rather than to delete and
2598      * re-insert it.</td>
2599      * </tr>
2600      * <tr>
2601      * <td>long</td>
2602      * <td>{@link #CONTACT_ID}</td>
2603      * <td>read-only</td>
2604      * <td>The ID of the row in the {@link ContactsContract.Contacts} table
2605      * that this raw contact belongs
2606      * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
2607      * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
2608      * </tr>
2609      * <tr>
2610      * <td>int</td>
2611      * <td>{@link #AGGREGATION_MODE}</td>
2612      * <td>read/write</td>
2613      * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
2614      * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
2615      * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
2616      * </tr>
2617      * <tr>
2618      * <td>int</td>
2619      * <td>{@link #DELETED}</td>
2620      * <td>read/write</td>
2621      * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
2622      * for deletion. When {@link android.content.ContentResolver#delete} is
2623      * called on a raw contact, it is marked for deletion and removed from its
2624      * aggregate contact. The sync adaptor deletes the raw contact on the server and
2625      * then calls ContactResolver.delete once more, this time passing the
2626      * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2627      * the data removal.</td>
2628      * </tr>
2629      * <tr>
2630      * <td>int</td>
2631      * <td>{@link #TIMES_CONTACTED}</td>
2632      * <td>read/write</td>
2633      * <td>The number of times the contact has been contacted. To have an effect
2634      * on the corresponding value of the aggregate contact, this field
2635      * should be set at the time the raw contact is inserted.
2636      * After that, this value is typically updated via
2637      * {@link ContactsContract.Contacts#markAsContacted}.</td>
2638      * </tr>
2639      * <tr>
2640      * <td>long</td>
2641      * <td>{@link #LAST_TIME_CONTACTED}</td>
2642      * <td>read/write</td>
2643      * <td>The timestamp of the last time the contact was contacted. To have an effect
2644      * on the corresponding value of the aggregate contact, this field
2645      * should be set at the time the raw contact is inserted.
2646      * After that, this value is typically updated via
2647      * {@link ContactsContract.Contacts#markAsContacted}.
2648      * </td>
2649      * </tr>
2650      * <tr>
2651      * <td>int</td>
2652      * <td>{@link #STARRED}</td>
2653      * <td>read/write</td>
2654      * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
2655      * Changing this field immediately affects the corresponding aggregate contact:
2656      * if any raw contacts in that aggregate contact are starred, then the contact
2657      * itself is marked as starred.</td>
2658      * </tr>
2659      * <tr>
2660      * <td>String</td>
2661      * <td>{@link #CUSTOM_RINGTONE}</td>
2662      * <td>read/write</td>
2663      * <td>A custom ringtone associated with a raw contact. Typically this is the
2664      * URI returned by an activity launched with the
2665      * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
2666      * To have an effect on the corresponding value of the aggregate contact, this field
2667      * should be set at the time the raw contact is inserted. To set a custom
2668      * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
2669      * Contacts.CUSTOM_RINGTONE}
2670      * instead.</td>
2671      * </tr>
2672      * <tr>
2673      * <td>int</td>
2674      * <td>{@link #SEND_TO_VOICEMAIL}</td>
2675      * <td>read/write</td>
2676      * <td>An indicator of whether calls from this raw contact should be forwarded
2677      * directly to voice mail ('1') or not ('0'). To have an effect
2678      * on the corresponding value of the aggregate contact, this field
2679      * should be set at the time the raw contact is inserted.</td>
2680      * </tr>
2681      * <tr>
2682      * <td>String</td>
2683      * <td>{@link #ACCOUNT_NAME}</td>
2684      * <td>read/write-once</td>
2685      * <td>The name of the account instance to which this row belongs, which when paired with
2686      * {@link #ACCOUNT_TYPE} identifies a specific account.
2687      * For example, this will be the Gmail address if it is a Google account.
2688      * It should be set at the time the raw contact is inserted and never
2689      * changed afterwards.</td>
2690      * </tr>
2691      * <tr>
2692      * <td>String</td>
2693      * <td>{@link #ACCOUNT_TYPE}</td>
2694      * <td>read/write-once</td>
2695      * <td>
2696      * <p>
2697      * The type of account to which this row belongs, which when paired with
2698      * {@link #ACCOUNT_NAME} identifies a specific account.
2699      * It should be set at the time the raw contact is inserted and never
2700      * changed afterwards.
2701      * </p>
2702      * <p>
2703      * To ensure uniqueness, new account types should be chosen according to the
2704      * Java package naming convention.  Thus a Google account is of type "com.google".
2705      * </p>
2706      * </td>
2707      * </tr>
2708      * <tr>
2709      * <td>String</td>
2710      * <td>{@link #DATA_SET}</td>
2711      * <td>read/write-once</td>
2712      * <td>
2713      * <p>
2714      * The data set within the account that this row belongs to.  This allows
2715      * multiple sync adapters for the same account type to distinguish between
2716      * each others' data.  The combination of {@link #ACCOUNT_TYPE},
2717      * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
2718      * that is associated with a single sync adapter.
2719      * </p>
2720      * <p>
2721      * This is empty by default, and is completely optional.  It only needs to
2722      * be populated if multiple sync adapters are entering distinct data for
2723      * the same account type and account name.
2724      * </p>
2725      * <p>
2726      * It should be set at the time the raw contact is inserted and never
2727      * changed afterwards.
2728      * </p>
2729      * </td>
2730      * </tr>
2731      * <tr>
2732      * <td>String</td>
2733      * <td>{@link #SOURCE_ID}</td>
2734      * <td>read/write</td>
2735      * <td>String that uniquely identifies this row to its source account.
2736      * Typically it is set at the time the raw contact is inserted and never
2737      * changed afterwards. The one notable exception is a new raw contact: it
2738      * will have an account name and type (and possibly a data set), but no
2739      * source id. This indicates to the sync adapter that a new contact needs
2740      * to be created server-side and its ID stored in the corresponding
2741      * SOURCE_ID field on the phone.
2742      * </td>
2743      * </tr>
2744      * <tr>
2745      * <td>int</td>
2746      * <td>{@link #VERSION}</td>
2747      * <td>read-only</td>
2748      * <td>Version number that is updated whenever this row or its related data
2749      * changes. This field can be used for optimistic locking of a raw contact.
2750      * </td>
2751      * </tr>
2752      * <tr>
2753      * <td>int</td>
2754      * <td>{@link #DIRTY}</td>
2755      * <td>read/write</td>
2756      * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
2757      * to be synchronized by its owning account.  The value is set to "1" automatically
2758      * whenever the raw contact changes, unless the URI has the
2759      * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
2760      * The sync adapter should always supply this query parameter to prevent
2761      * unnecessary synchronization: user changes some data on the server,
2762      * the sync adapter updates the contact on the phone (without the
2763      * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
2764      * which triggers a sync to bring the changes to the server.
2765      * </td>
2766      * </tr>
2767      * <tr>
2768      * <td>String</td>
2769      * <td>{@link #SYNC1}</td>
2770      * <td>read/write</td>
2771      * <td>Generic column provided for arbitrary use by sync adapters.
2772      * The content provider
2773      * stores this information on behalf of the sync adapter but does not
2774      * interpret it in any way.
2775      * </td>
2776      * </tr>
2777      * <tr>
2778      * <td>String</td>
2779      * <td>{@link #SYNC2}</td>
2780      * <td>read/write</td>
2781      * <td>Generic column for use by sync adapters.
2782      * </td>
2783      * </tr>
2784      * <tr>
2785      * <td>String</td>
2786      * <td>{@link #SYNC3}</td>
2787      * <td>read/write</td>
2788      * <td>Generic column for use by sync adapters.
2789      * </td>
2790      * </tr>
2791      * <tr>
2792      * <td>String</td>
2793      * <td>{@link #SYNC4}</td>
2794      * <td>read/write</td>
2795      * <td>Generic column for use by sync adapters.
2796      * </td>
2797      * </tr>
2798      * </table>
2799      */
2800     public static final class RawContacts implements BaseColumns, RawContactsColumns,
2801             ContactOptionsColumns, ContactNameColumns, SyncColumns  {
2802         /**
2803          * This utility class cannot be instantiated
2804          */
RawContacts()2805         private RawContacts() {
2806         }
2807 
2808         /**
2809          * The content:// style URI for this table, which requests a directory of
2810          * raw contact rows matching the selection criteria.
2811          */
2812         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
2813 
2814         /**
2815          * The MIME type of the results from {@link #CONTENT_URI} when a specific
2816          * ID value is not provided, and multiple raw contacts may be returned.
2817          */
2818         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
2819 
2820         /**
2821          * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
2822          * yielding a subdirectory of a single person.
2823          */
2824         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
2825 
2826         /**
2827          * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
2828          */
2829         public static final int AGGREGATION_MODE_DEFAULT = 0;
2830 
2831         /**
2832          * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
2833          * @deprecated Aggregation is synchronous, this historic value is a no-op
2834          */
2835         @Deprecated
2836         public static final int AGGREGATION_MODE_IMMEDIATE = 1;
2837 
2838         /**
2839          * <p>
2840          * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
2841          * Changes to the raw contact will update the associated aggregate contact but will not
2842          * result in any change in how the contact is aggregated. Similar to
2843          * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
2844          * {@link Contacts} aggregate.
2845          * </p>
2846          * <p>
2847          * This can be used to postpone aggregation until after a series of updates, for better
2848          * performance and/or user experience.
2849          * </p>
2850          * <p>
2851          * Note that changing
2852          * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
2853          * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
2854          * subsequent
2855          * change to the raw contact's data will.
2856          * </p>
2857          */
2858         public static final int AGGREGATION_MODE_SUSPENDED = 2;
2859 
2860         /**
2861          * <p>
2862          * Aggregation mode: never aggregate this raw contact.  The raw contact will not
2863          * have a corresponding {@link Contacts} aggregate and therefore will not be included in
2864          * {@link Contacts} query results.
2865          * </p>
2866          * <p>
2867          * For example, this mode can be used for a raw contact that is marked for deletion while
2868          * waiting for the deletion to occur on the server side.
2869          * </p>
2870          *
2871          * @see #AGGREGATION_MODE_SUSPENDED
2872          */
2873         public static final int AGGREGATION_MODE_DISABLED = 3;
2874 
2875         /**
2876          * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
2877          * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
2878          * entry of the given {@link RawContacts} entry.
2879          */
getContactLookupUri(ContentResolver resolver, Uri rawContactUri)2880         public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
2881             // TODO: use a lighter query by joining rawcontacts with contacts in provider
2882             final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
2883             final Cursor cursor = resolver.query(dataUri, new String[] {
2884                     RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
2885             }, null, null, null);
2886 
2887             Uri lookupUri = null;
2888             try {
2889                 if (cursor != null && cursor.moveToFirst()) {
2890                     final long contactId = cursor.getLong(0);
2891                     final String lookupKey = cursor.getString(1);
2892                     return Contacts.getLookupUri(contactId, lookupKey);
2893                 }
2894             } finally {
2895                 if (cursor != null) cursor.close();
2896             }
2897             return lookupUri;
2898         }
2899 
2900         /**
2901          * A sub-directory of a single raw contact that contains all of its
2902          * {@link ContactsContract.Data} rows. To access this directory
2903          * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI.
2904          */
2905         public static final class Data implements BaseColumns, DataColumns {
2906             /**
2907              * no public constructor since this is a utility class
2908              */
Data()2909             private Data() {
2910             }
2911 
2912             /**
2913              * The directory twig for this sub-table
2914              */
2915             public static final String CONTENT_DIRECTORY = "data";
2916         }
2917 
2918         /**
2919          * <p>
2920          * A sub-directory of a single raw contact that contains all of its
2921          * {@link ContactsContract.Data} rows. To access this directory append
2922          * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See
2923          * {@link RawContactsEntity} for a stand-alone table containing the same
2924          * data.
2925          * </p>
2926          * <p>
2927          * Entity has two ID fields: {@link #_ID} for the raw contact
2928          * and {@link #DATA_ID} for the data rows.
2929          * Entity always contains at least one row, even if there are no
2930          * actual data rows. In this case the {@link #DATA_ID} field will be
2931          * null.
2932          * </p>
2933          * <p>
2934          * Using Entity should be preferred to using two separate queries:
2935          * RawContacts followed by Data. The reason is that Entity reads all
2936          * data for a raw contact in one transaction, so there is no possibility
2937          * of the data changing between the two queries.
2938          */
2939         public static final class Entity implements BaseColumns, DataColumns {
2940             /**
2941              * no public constructor since this is a utility class
2942              */
Entity()2943             private Entity() {
2944             }
2945 
2946             /**
2947              * The directory twig for this sub-table
2948              */
2949             public static final String CONTENT_DIRECTORY = "entity";
2950 
2951             /**
2952              * The ID of the data row. The value will be null if this raw contact has no
2953              * data rows.
2954              * <P>Type: INTEGER</P>
2955              */
2956             public static final String DATA_ID = "data_id";
2957         }
2958 
2959         /**
2960          * <p>
2961          * A sub-directory of a single raw contact that contains all of its
2962          * {@link ContactsContract.StreamItems} rows. To access this directory append
2963          * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See
2964          * {@link ContactsContract.StreamItems} for a stand-alone table containing the
2965          * same data.
2966          * </p>
2967          * <p>
2968          * Access to the social stream through this sub-directory requires additional permissions
2969          * beyond the read/write contact permissions required by the provider.  Querying for
2970          * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and
2971          * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM
2972          * permission.
2973          * </p>
2974          *
2975          * @deprecated - Do not use. This will not be supported in the future. In the future,
2976          * cursors returned from related queries will be empty.
2977          *
2978          * @hide
2979          * @removed
2980          */
2981         @Deprecated
2982         public static final class StreamItems implements BaseColumns, StreamItemsColumns {
2983             /**
2984              * No public constructor since this is a utility class
2985              *
2986              * @deprecated - Do not use. This will not be supported in the future. In the future,
2987              * cursors returned from related queries will be empty.
2988              */
2989             @Deprecated
StreamItems()2990             private StreamItems() {
2991             }
2992 
2993             /**
2994              * The directory twig for this sub-table
2995              *
2996              * @deprecated - Do not use. This will not be supported in the future. In the future,
2997              * cursors returned from related queries will be empty.
2998              */
2999             @Deprecated
3000             public static final String CONTENT_DIRECTORY = "stream_items";
3001         }
3002 
3003         /**
3004          * <p>
3005          * A sub-directory of a single raw contact that represents its primary
3006          * display photo.  To access this directory append
3007          * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI.
3008          * The resulting URI represents an image file, and should be interacted with
3009          * using ContentResolver.openAssetFileDescriptor.
3010          * <p>
3011          * <p>
3012          * Note that this sub-directory also supports opening the photo as an asset file
3013          * in write mode.  Callers can create or replace the primary photo associated
3014          * with this raw contact by opening the asset file and writing the full-size
3015          * photo contents into it.  When the file is closed, the image will be parsed,
3016          * sized down if necessary for the full-size display photo and thumbnail
3017          * dimensions, and stored.
3018          * </p>
3019          * <p>
3020          * Usage example:
3021          * <pre>
3022          * public void writeDisplayPhoto(long rawContactId, byte[] photo) {
3023          *     Uri rawContactPhotoUri = Uri.withAppendedPath(
3024          *             ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
3025          *             RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
3026          *     try {
3027          *         AssetFileDescriptor fd =
3028          *             getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw");
3029          *         OutputStream os = fd.createOutputStream();
3030          *         os.write(photo);
3031          *         os.close();
3032          *         fd.close();
3033          *     } catch (IOException e) {
3034          *         // Handle error cases.
3035          *     }
3036          * }
3037          * </pre>
3038          * </p>
3039          */
3040         public static final class DisplayPhoto {
3041             /**
3042              * No public constructor since this is a utility class
3043              */
DisplayPhoto()3044             private DisplayPhoto() {
3045             }
3046 
3047             /**
3048              * The directory twig for this sub-table
3049              */
3050             public static final String CONTENT_DIRECTORY = "display_photo";
3051         }
3052 
3053         /**
3054          * TODO: javadoc
3055          * @param cursor
3056          * @return
3057          */
newEntityIterator(Cursor cursor)3058         public static EntityIterator newEntityIterator(Cursor cursor) {
3059             return new EntityIteratorImpl(cursor);
3060         }
3061 
3062         private static class EntityIteratorImpl extends CursorEntityIterator {
3063             private static final String[] DATA_KEYS = new String[]{
3064                     Data.DATA1,
3065                     Data.DATA2,
3066                     Data.DATA3,
3067                     Data.DATA4,
3068                     Data.DATA5,
3069                     Data.DATA6,
3070                     Data.DATA7,
3071                     Data.DATA8,
3072                     Data.DATA9,
3073                     Data.DATA10,
3074                     Data.DATA11,
3075                     Data.DATA12,
3076                     Data.DATA13,
3077                     Data.DATA14,
3078                     Data.DATA15,
3079                     Data.SYNC1,
3080                     Data.SYNC2,
3081                     Data.SYNC3,
3082                     Data.SYNC4};
3083 
EntityIteratorImpl(Cursor cursor)3084             public EntityIteratorImpl(Cursor cursor) {
3085                 super(cursor);
3086             }
3087 
3088             @Override
getEntityAndIncrementCursor(Cursor cursor)3089             public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
3090                     throws RemoteException {
3091                 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
3092                 final long rawContactId = cursor.getLong(columnRawContactId);
3093 
3094                 // we expect the cursor is already at the row we need to read from
3095                 ContentValues cv = new ContentValues();
3096                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
3097                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
3098                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET);
3099                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
3100                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
3101                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
3102                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
3103                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
3104                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
3105                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
3106                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
3107                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
3108                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
3109                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
3110                 android.content.Entity contact = new android.content.Entity(cv);
3111 
3112                 // read data rows until the contact id changes
3113                 do {
3114                     if (rawContactId != cursor.getLong(columnRawContactId)) {
3115                         break;
3116                     }
3117                     // add the data to to the contact
3118                     cv = new ContentValues();
3119                     cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
3120                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3121                             Data.RES_PACKAGE);
3122                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
3123                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
3124                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
3125                             Data.IS_SUPER_PRIMARY);
3126                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
3127                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3128                             CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
3129                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3130                             Data.DATA_VERSION);
3131                     for (String key : DATA_KEYS) {
3132                         final int columnIndex = cursor.getColumnIndexOrThrow(key);
3133                         switch (cursor.getType(columnIndex)) {
3134                             case Cursor.FIELD_TYPE_NULL:
3135                                 // don't put anything
3136                                 break;
3137                             case Cursor.FIELD_TYPE_INTEGER:
3138                             case Cursor.FIELD_TYPE_FLOAT:
3139                             case Cursor.FIELD_TYPE_STRING:
3140                                 cv.put(key, cursor.getString(columnIndex));
3141                                 break;
3142                             case Cursor.FIELD_TYPE_BLOB:
3143                                 cv.put(key, cursor.getBlob(columnIndex));
3144                                 break;
3145                             default:
3146                                 throw new IllegalStateException("Invalid or unhandled data type");
3147                         }
3148                     }
3149                     contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
3150                 } while (cursor.moveToNext());
3151 
3152                 return contact;
3153             }
3154 
3155         }
3156     }
3157 
3158     /**
3159      * Social status update columns.
3160      *
3161      * @see StatusUpdates
3162      * @see ContactsContract.Data
3163      */
3164     protected interface StatusColumns {
3165         /**
3166          * Contact's latest presence level.
3167          * <P>Type: INTEGER (one of the values below)</P>
3168          */
3169         public static final String PRESENCE = "mode";
3170 
3171         /**
3172          * @deprecated use {@link #PRESENCE}
3173          */
3174         @Deprecated
3175         public static final String PRESENCE_STATUS = PRESENCE;
3176 
3177         /**
3178          * An allowed value of {@link #PRESENCE}.
3179          */
3180         int OFFLINE = 0;
3181 
3182         /**
3183          * An allowed value of {@link #PRESENCE}.
3184          */
3185         int INVISIBLE = 1;
3186 
3187         /**
3188          * An allowed value of {@link #PRESENCE}.
3189          */
3190         int AWAY = 2;
3191 
3192         /**
3193          * An allowed value of {@link #PRESENCE}.
3194          */
3195         int IDLE = 3;
3196 
3197         /**
3198          * An allowed value of {@link #PRESENCE}.
3199          */
3200         int DO_NOT_DISTURB = 4;
3201 
3202         /**
3203          * An allowed value of {@link #PRESENCE}.
3204          */
3205         int AVAILABLE = 5;
3206 
3207         /**
3208          * Contact latest status update.
3209          * <p>Type: TEXT</p>
3210          */
3211         public static final String STATUS = "status";
3212 
3213         /**
3214          * @deprecated use {@link #STATUS}
3215          */
3216         @Deprecated
3217         public static final String PRESENCE_CUSTOM_STATUS = STATUS;
3218 
3219         /**
3220          * The absolute time in milliseconds when the latest status was inserted/updated.
3221          * <p>Type: NUMBER</p>
3222          */
3223         public static final String STATUS_TIMESTAMP = "status_ts";
3224 
3225         /**
3226          * The package containing resources for this status: label and icon.
3227          * <p>Type: TEXT</p>
3228          */
3229         public static final String STATUS_RES_PACKAGE = "status_res_package";
3230 
3231         /**
3232          * The resource ID of the label describing the source of the status update, e.g. "Google
3233          * Talk".  This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3234          * <p>Type: NUMBER</p>
3235          */
3236         public static final String STATUS_LABEL = "status_label";
3237 
3238         /**
3239          * The resource ID of the icon for the source of the status update.
3240          * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3241          * <p>Type: NUMBER</p>
3242          */
3243         public static final String STATUS_ICON = "status_icon";
3244 
3245         /**
3246          * Contact's audio/video chat capability level.
3247          * <P>Type: INTEGER (one of the values below)</P>
3248          */
3249         public static final String CHAT_CAPABILITY = "chat_capability";
3250 
3251         /**
3252          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone
3253          * and speaker)
3254          */
3255         public static final int CAPABILITY_HAS_VOICE = 1;
3256 
3257         /**
3258          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
3259          * display a video feed.
3260          */
3261         public static final int CAPABILITY_HAS_VIDEO = 2;
3262 
3263         /**
3264          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
3265          * camera that can be used for video chat (e.g. a front-facing camera on a phone).
3266          */
3267         public static final int CAPABILITY_HAS_CAMERA = 4;
3268     }
3269 
3270     /**
3271      * <p>
3272      * Constants for the stream_items table, which contains social stream updates from
3273      * the user's contact list.
3274      * </p>
3275      * <p>
3276      * Only a certain number of stream items will ever be stored under a given raw contact.
3277      * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to
3278      * determine this limit, and should restrict the number of items inserted in any given
3279      * transaction correspondingly.  Insertion of more items beyond the limit will
3280      * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}.
3281      * </p>
3282      * <p>
3283      * Access to the social stream through these URIs requires additional permissions beyond the
3284      * read/write contact permissions required by the provider.  Querying for social stream data
3285      * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social
3286      * stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
3287      * </p>
3288      * <h3>Account check</h3>
3289      * <p>
3290      * The content URIs to the insert, update and delete operations are required to have the account
3291      * information matching that of the owning raw contact as query parameters, namely
3292      * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3293      * {@link RawContacts#DATA_SET} isn't required.
3294      * </p>
3295      * <h3>Operations</h3>
3296      * <dl>
3297      * <dt><b>Insert</b></dt>
3298      * <dd>
3299      * <p>Social stream updates are always associated with a raw contact.  There are a couple
3300      * of ways to insert these entries.
3301      * <dl>
3302      * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt>
3303      * <dd>
3304      * <pre>
3305      * ContentValues values = new ContentValues();
3306      * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3307      * values.put(StreamItems.TIMESTAMP, timestamp);
3308      * values.put(StreamItems.COMMENTS, "3 people reshared this");
3309      * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
3310      * ContentUris.appendId(builder, rawContactId);
3311      * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY);
3312      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3313      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3314      * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
3315      * long streamItemId = ContentUris.parseId(streamItemUri);
3316      * </pre>
3317      * </dd>
3318      * <dt>Via {@link StreamItems#CONTENT_URI}:</dt>
3319      * <dd>
3320      *<pre>
3321      * ContentValues values = new ContentValues();
3322      * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
3323      * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3324      * values.put(StreamItems.TIMESTAMP, timestamp);
3325      * values.put(StreamItems.COMMENTS, "3 people reshared this");
3326      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3327      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3328      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3329      * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
3330      * long streamItemId = ContentUris.parseId(streamItemUri);
3331      *</pre>
3332      * </dd>
3333      * </dl>
3334      * </dd>
3335      * </p>
3336      * <p>
3337      * Once a {@link StreamItems} entry has been inserted, photos associated with that
3338      * social update can be inserted.  For example, after one of the insertions above,
3339      * photos could be added to the stream item in one of the following ways:
3340      * <dl>
3341      * <dt>Via a URI including the stream item ID:</dt>
3342      * <dd>
3343      * <pre>
3344      * values.clear();
3345      * values.put(StreamItemPhotos.SORT_INDEX, 1);
3346      * values.put(StreamItemPhotos.PHOTO, photoData);
3347      * getContentResolver().insert(Uri.withAppendedPath(
3348      *     ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId),
3349      *     StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
3350      * </pre>
3351      * </dd>
3352      * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt>
3353      * <dd>
3354      * <pre>
3355      * values.clear();
3356      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3357      * values.put(StreamItemPhotos.SORT_INDEX, 1);
3358      * values.put(StreamItemPhotos.PHOTO, photoData);
3359      * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
3360      * </pre>
3361      * <p>Note that this latter form allows the insertion of a stream item and its
3362      * photos in a single transaction, by using {@link ContentProviderOperation} with
3363      * back references to populate the stream item ID in the {@link ContentValues}.
3364      * </dd>
3365      * </dl>
3366      * </p>
3367      * </dd>
3368      * <dt><b>Update</b></dt>
3369      * <dd>Updates can be performed by appending the stream item ID to the
3370      * {@link StreamItems#CONTENT_URI} URI.  Only social stream entries that were
3371      * created by the calling package can be updated.</dd>
3372      * <dt><b>Delete</b></dt>
3373      * <dd>Deletes can be performed by appending the stream item ID to the
3374      * {@link StreamItems#CONTENT_URI} URI.  Only social stream entries that were
3375      * created by the calling package can be deleted.</dd>
3376      * <dt><b>Query</b></dt>
3377      * <dl>
3378      * <dt>Finding all social stream updates for a given contact</dt>
3379      * <dd>By Contact ID:
3380      * <pre>
3381      * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3382      *          ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
3383      *          Contacts.StreamItems.CONTENT_DIRECTORY),
3384      *          null, null, null, null);
3385      * </pre>
3386      * </dd>
3387      * <dd>By lookup key:
3388      * <pre>
3389      * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
3390      *          .appendPath(lookupKey)
3391      *          .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
3392      *          null, null, null, null);
3393      * </pre>
3394      * </dd>
3395      * <dt>Finding all social stream updates for a given raw contact</dt>
3396      * <dd>
3397      * <pre>
3398      * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3399      *          ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
3400      *          RawContacts.StreamItems.CONTENT_DIRECTORY)),
3401      *          null, null, null, null);
3402      * </pre>
3403      * </dd>
3404      * <dt>Querying for a specific stream item by ID</dt>
3405      * <dd>
3406      * <pre>
3407      * Cursor c = getContentResolver().query(ContentUris.withAppendedId(
3408      *          StreamItems.CONTENT_URI, streamItemId),
3409      *          null, null, null, null);
3410      * </pre>
3411      * </dd>
3412      * </dl>
3413      *
3414      * @deprecated - Do not use. This will not be supported in the future. In the future,
3415      * cursors returned from related queries will be empty.
3416      *
3417      * @hide
3418      * @removed
3419      */
3420     @Deprecated
3421     public static final class StreamItems implements BaseColumns, StreamItemsColumns {
3422         /**
3423          * This utility class cannot be instantiated
3424          *
3425          * @deprecated - Do not use. This will not be supported in the future. In the future,
3426          * cursors returned from related queries will be empty.
3427          */
3428         @Deprecated
StreamItems()3429         private StreamItems() {
3430         }
3431 
3432         /**
3433          * The content:// style URI for this table, which handles social network stream
3434          * updates for the user's contacts.
3435          *
3436          * @deprecated - Do not use. This will not be supported in the future. In the future,
3437          * cursors returned from related queries will be empty.
3438          */
3439         @Deprecated
3440         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items");
3441 
3442         /**
3443          * <p>
3444          * A content:// style URI for the photos stored in a sub-table underneath
3445          * stream items.  This is only used for inserts, and updates - queries and deletes
3446          * for photos should be performed by appending
3447          * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a
3448          * specific stream item.
3449          * </p>
3450          * <p>
3451          * When using this URI, the stream item ID for the photo(s) must be identified
3452          * in the {@link ContentValues} passed in.
3453          * </p>
3454          *
3455          * @deprecated - Do not use. This will not be supported in the future. In the future,
3456          * cursors returned from related queries will be empty.
3457          */
3458         @Deprecated
3459         public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo");
3460 
3461         /**
3462          * This URI allows the caller to query for the maximum number of stream items
3463          * that will be stored under any single raw contact.
3464          *
3465          * @deprecated - Do not use. This will not be supported in the future. In the future,
3466          * cursors returned from related queries will be empty.
3467          */
3468         @Deprecated
3469         public static final Uri CONTENT_LIMIT_URI =
3470                 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
3471 
3472         /**
3473          * The MIME type of a directory of stream items.
3474          *
3475          * @deprecated - Do not use. This will not be supported in the future. In the future,
3476          * cursors returned from related queries will be empty.
3477          */
3478         @Deprecated
3479         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item";
3480 
3481         /**
3482          * The MIME type of a single stream item.
3483          *
3484          * @deprecated - Do not use. This will not be supported in the future. In the future,
3485          * cursors returned from related queries will be empty.
3486          */
3487         @Deprecated
3488         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item";
3489 
3490         /**
3491          * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
3492          * contain this column, with the value indicating the maximum number of
3493          * stream items that will be stored under any single raw contact.
3494          *
3495          * @deprecated - Do not use. This will not be supported in the future. In the future,
3496          * cursors returned from related queries will be empty.
3497          */
3498         @Deprecated
3499         public static final String MAX_ITEMS = "max_items";
3500 
3501         /**
3502          * <p>
3503          * A sub-directory of a single stream item entry that contains all of its
3504          * photo rows. To access this
3505          * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to
3506          * an individual stream item URI.
3507          * </p>
3508          * <p>
3509          * Access to social stream photos requires additional permissions beyond the read/write
3510          * contact permissions required by the provider.  Querying for social stream photos
3511          * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3512          * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3513          * </p>
3514          *
3515          * @deprecated - Do not use. This will not be supported in the future. In the future,
3516          * cursors returned from related queries will be empty.
3517          *
3518          * @hide
3519          * @removed
3520          */
3521         @Deprecated
3522         public static final class StreamItemPhotos
3523                 implements BaseColumns, StreamItemPhotosColumns {
3524             /**
3525              * No public constructor since this is a utility class
3526              *
3527              * @deprecated - Do not use. This will not be supported in the future. In the future,
3528              * cursors returned from related queries will be empty.
3529              */
3530             @Deprecated
StreamItemPhotos()3531             private StreamItemPhotos() {
3532             }
3533 
3534             /**
3535              * The directory twig for this sub-table
3536              *
3537              * @deprecated - Do not use. This will not be supported in the future. In the future,
3538              * cursors returned from related queries will be empty.
3539              */
3540             @Deprecated
3541             public static final String CONTENT_DIRECTORY = "photo";
3542 
3543             /**
3544              * The MIME type of a directory of stream item photos.
3545              *
3546              * @deprecated - Do not use. This will not be supported in the future. In the future,
3547              * cursors returned from related queries will be empty.
3548              */
3549             @Deprecated
3550             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo";
3551 
3552             /**
3553              * The MIME type of a single stream item photo.
3554              *
3555              * @deprecated - Do not use. This will not be supported in the future. In the future,
3556              * cursors returned from related queries will be empty.
3557              */
3558             @Deprecated
3559             public static final String CONTENT_ITEM_TYPE
3560                     = "vnd.android.cursor.item/stream_item_photo";
3561         }
3562     }
3563 
3564     /**
3565      * Columns in the StreamItems table.
3566      *
3567      * @see ContactsContract.StreamItems
3568      * @deprecated - Do not use. This will not be supported in the future. In the future,
3569      * cursors returned from related queries will be empty.
3570      *
3571      * @hide
3572      * @removed
3573      */
3574     @Deprecated
3575     protected interface StreamItemsColumns {
3576         /**
3577          * A reference to the {@link android.provider.ContactsContract.Contacts#_ID}
3578          * that this stream item belongs to.
3579          *
3580          * <p>Type: INTEGER</p>
3581          * <p>read-only</p>
3582          *
3583          * @deprecated - Do not use. This will not be supported in the future. In the future,
3584          * cursors returned from related queries will be empty.
3585          */
3586         @Deprecated
3587         public static final String CONTACT_ID = "contact_id";
3588 
3589         /**
3590          * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY}
3591          * that this stream item belongs to.
3592          *
3593          * <p>Type: TEXT</p>
3594          * <p>read-only</p>
3595          *
3596          * @deprecated - Do not use. This will not be supported in the future. In the future,
3597          * cursors returned from related queries will be empty.
3598          */
3599         @Deprecated
3600         public static final String CONTACT_LOOKUP_KEY = "contact_lookup";
3601 
3602         /**
3603          * A reference to the {@link RawContacts#_ID}
3604          * that this stream item belongs to.
3605          * <p>Type: INTEGER</p>
3606          *
3607          * @deprecated - Do not use. This will not be supported in the future. In the future,
3608          * cursors returned from related queries will be empty.
3609          */
3610         @Deprecated
3611         public static final String RAW_CONTACT_ID = "raw_contact_id";
3612 
3613         /**
3614          * The package name to use when creating {@link Resources} objects for
3615          * this stream item. This value is only designed for use when building
3616          * user interfaces, and should not be used to infer the owner.
3617          * <P>Type: TEXT</P>
3618          *
3619          * @deprecated - Do not use. This will not be supported in the future. In the future,
3620          * cursors returned from related queries will be empty.
3621          */
3622         @Deprecated
3623         public static final String RES_PACKAGE = "res_package";
3624 
3625         /**
3626          * The account type to which the raw_contact of this item is associated. See
3627          * {@link RawContacts#ACCOUNT_TYPE}
3628          *
3629          * <p>Type: TEXT</p>
3630          * <p>read-only</p>
3631          *
3632          * @deprecated - Do not use. This will not be supported in the future. In the future,
3633          * cursors returned from related queries will be empty.
3634          */
3635         @Deprecated
3636         public static final String ACCOUNT_TYPE = "account_type";
3637 
3638         /**
3639          * The account name to which the raw_contact of this item is associated. See
3640          * {@link RawContacts#ACCOUNT_NAME}
3641          *
3642          * <p>Type: TEXT</p>
3643          * <p>read-only</p>
3644          *
3645          * @deprecated - Do not use. This will not be supported in the future. In the future,
3646          * cursors returned from related queries will be empty.
3647          */
3648         @Deprecated
3649         public static final String ACCOUNT_NAME = "account_name";
3650 
3651         /**
3652          * The data set within the account that the raw_contact of this row belongs to. This allows
3653          * multiple sync adapters for the same account type to distinguish between
3654          * each others' data.
3655          * {@link RawContacts#DATA_SET}
3656          *
3657          * <P>Type: TEXT</P>
3658          * <p>read-only</p>
3659          *
3660          * @deprecated - Do not use. This will not be supported in the future. In the future,
3661          * cursors returned from related queries will be empty.
3662          */
3663         @Deprecated
3664         public static final String DATA_SET = "data_set";
3665 
3666         /**
3667          * The source_id of the raw_contact that this row belongs to.
3668          * {@link RawContacts#SOURCE_ID}
3669          *
3670          * <P>Type: TEXT</P>
3671          * <p>read-only</p>
3672          *
3673          * @deprecated - Do not use. This will not be supported in the future. In the future,
3674          * cursors returned from related queries will be empty.
3675          */
3676         @Deprecated
3677         public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id";
3678 
3679         /**
3680          * The resource name of the icon for the source of the stream item.
3681          * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference
3682          * drawables, the "@drawable/" prefix must be omitted.
3683          * <P>Type: TEXT</P>
3684          *
3685          * @deprecated - Do not use. This will not be supported in the future. In the future,
3686          * cursors returned from related queries will be empty.
3687          */
3688         @Deprecated
3689         public static final String RES_ICON = "icon";
3690 
3691         /**
3692          * The resource name of the label describing the source of the status update, e.g. "Google
3693          * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only
3694          * reference strings, the "@string/" prefix must be omitted.
3695          * <p>Type: TEXT</p>
3696          *
3697          * @deprecated - Do not use. This will not be supported in the future. In the future,
3698          * cursors returned from related queries will be empty.
3699          */
3700         @Deprecated
3701         public static final String RES_LABEL = "label";
3702 
3703         /**
3704          * <P>
3705          * The main textual contents of the item. Typically this is content
3706          * that was posted by the source of this stream item, but it can also
3707          * be a textual representation of an action (e.g. ”Checked in at Joe's”).
3708          * This text is displayed to the user and allows formatting and embedded
3709          * resource images via HTML (as parseable via
3710          * {@link android.text.Html#fromHtml}).
3711          * </P>
3712          * <P>
3713          * Long content may be truncated and/or ellipsized - the exact behavior
3714          * is unspecified, but it should not break tags.
3715          * </P>
3716          * <P>Type: TEXT</P>
3717          *
3718          * @deprecated - Do not use. This will not be supported in the future. In the future,
3719          * cursors returned from related queries will be empty.
3720          */
3721         @Deprecated
3722         public static final String TEXT = "text";
3723 
3724         /**
3725          * The absolute time (milliseconds since epoch) when this stream item was
3726          * inserted/updated.
3727          * <P>Type: NUMBER</P>
3728          *
3729          * @deprecated - Do not use. This will not be supported in the future. In the future,
3730          * cursors returned from related queries will be empty.
3731          */
3732         @Deprecated
3733         public static final String TIMESTAMP = "timestamp";
3734 
3735         /**
3736          * <P>
3737          * Summary information about the stream item, for example to indicate how
3738          * many people have reshared it, how many have liked it, how many thumbs
3739          * up and/or thumbs down it has, what the original source was, etc.
3740          * </P>
3741          * <P>
3742          * This text is displayed to the user and allows simple formatting via
3743          * HTML, in the same manner as {@link #TEXT} allows.
3744          * </P>
3745          * <P>
3746          * Long content may be truncated and/or ellipsized - the exact behavior
3747          * is unspecified, but it should not break tags.
3748          * </P>
3749          * <P>Type: TEXT</P>
3750          *
3751          * @deprecated - Do not use. This will not be supported in the future. In the future,
3752          * cursors returned from related queries will be empty.
3753          */
3754         @Deprecated
3755         public static final String COMMENTS = "comments";
3756 
3757         /**
3758          * Generic column for use by sync adapters.
3759          *
3760          * @deprecated - Do not use. This will not be supported in the future. In the future,
3761          * cursors returned from related queries will be empty.
3762          */
3763         @Deprecated
3764         public static final String SYNC1 = "stream_item_sync1";
3765         /**
3766          * Generic column for use by sync adapters.
3767          *
3768          * @deprecated - Do not use. This will not be supported in the future. In the future,
3769          * cursors returned from related queries will be empty.
3770          */
3771         @Deprecated
3772         public static final String SYNC2 = "stream_item_sync2";
3773         /**
3774          * Generic column for use by sync adapters.
3775          *
3776          * @deprecated - Do not use. This will not be supported in the future. In the future,
3777          * cursors returned from related queries will be empty.
3778          */
3779         @Deprecated
3780         public static final String SYNC3 = "stream_item_sync3";
3781         /**
3782          * Generic column for use by sync adapters.
3783          *
3784          * @deprecated - Do not use. This will not be supported in the future. In the future,
3785          * cursors returned from related queries will be empty.
3786          */
3787         @Deprecated
3788         public static final String SYNC4 = "stream_item_sync4";
3789     }
3790 
3791     /**
3792      * <p>
3793      * Constants for the stream_item_photos table, which contains photos associated with
3794      * social stream updates.
3795      * </p>
3796      * <p>
3797      * Access to social stream photos requires additional permissions beyond the read/write
3798      * contact permissions required by the provider.  Querying for social stream photos
3799      * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3800      * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3801      * </p>
3802      * <h3>Account check</h3>
3803      * <p>
3804      * The content URIs to the insert, update and delete operations are required to have the account
3805      * information matching that of the owning raw contact as query parameters, namely
3806      * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3807      * {@link RawContacts#DATA_SET} isn't required.
3808      * </p>
3809      * <h3>Operations</h3>
3810      * <dl>
3811      * <dt><b>Insert</b></dt>
3812      * <dd>
3813      * <p>Social stream photo entries are associated with a social stream item.  Photos
3814      * can be inserted into a social stream item in a couple of ways:
3815      * <dl>
3816      * <dt>
3817      * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3818      * stream item:
3819      * </dt>
3820      * <dd>
3821      * <pre>
3822      * ContentValues values = new ContentValues();
3823      * values.put(StreamItemPhotos.SORT_INDEX, 1);
3824      * values.put(StreamItemPhotos.PHOTO, photoData);
3825      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3826      * ContentUris.appendId(builder, streamItemId);
3827      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3828      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3829      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3830      * Uri photoUri = getContentResolver().insert(builder.build(), values);
3831      * long photoId = ContentUris.parseId(photoUri);
3832      * </pre>
3833      * </dd>
3834      * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3835      * <dd>
3836      * <pre>
3837      * ContentValues values = new ContentValues();
3838      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3839      * values.put(StreamItemPhotos.SORT_INDEX, 1);
3840      * values.put(StreamItemPhotos.PHOTO, photoData);
3841      * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3842      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3843      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3844      * Uri photoUri = getContentResolver().insert(builder.build(), values);
3845      * long photoId = ContentUris.parseId(photoUri);
3846      * </pre>
3847      * </dd>
3848      * </dl>
3849      * </p>
3850      * </dd>
3851      * <dt><b>Update</b></dt>
3852      * <dd>
3853      * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry,
3854      * identified by both the stream item ID it belongs to and the stream item photo ID.
3855      * This can be specified in two ways.
3856      * <dl>
3857      * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3858      * stream item:
3859      * </dt>
3860      * <dd>
3861      * <pre>
3862      * ContentValues values = new ContentValues();
3863      * values.put(StreamItemPhotos.PHOTO, newPhotoData);
3864      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3865      * ContentUris.appendId(builder, streamItemId);
3866      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3867      * ContentUris.appendId(builder, streamItemPhotoId);
3868      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3869      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3870      * getContentResolver().update(builder.build(), values, null, null);
3871      * </pre>
3872      * </dd>
3873      * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3874      * <dd>
3875      * <pre>
3876      * ContentValues values = new ContentValues();
3877      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3878      * values.put(StreamItemPhotos.PHOTO, newPhotoData);
3879      * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3880      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3881      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3882      * getContentResolver().update(builder.build(), values);
3883      * </pre>
3884      * </dd>
3885      * </dl>
3886      * </p>
3887      * </dd>
3888      * <dt><b>Delete</b></dt>
3889      * <dd>Deletes can be made against either a specific photo item in a stream item, or
3890      * against all or a selected subset of photo items under a stream item.
3891      * For example:
3892      * <dl>
3893      * <dt>Deleting a single photo via the
3894      * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item:
3895      * </dt>
3896      * <dd>
3897      * <pre>
3898      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3899      * ContentUris.appendId(builder, streamItemId);
3900      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3901      * ContentUris.appendId(builder, streamItemPhotoId);
3902      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3903      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3904      * getContentResolver().delete(builder.build(), null, null);
3905      * </pre>
3906      * </dd>
3907      * <dt>Deleting all photos under a stream item</dt>
3908      * <dd>
3909      * <pre>
3910      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3911      * ContentUris.appendId(builder, streamItemId);
3912      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3913      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3914      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3915      * getContentResolver().delete(builder.build(), null, null);
3916      * </pre>
3917      * </dd>
3918      * </dl>
3919      * </dd>
3920      * <dt><b>Query</b></dt>
3921      * <dl>
3922      * <dt>Querying for a specific photo in a stream item</dt>
3923      * <dd>
3924      * <pre>
3925      * Cursor c = getContentResolver().query(
3926      *     ContentUris.withAppendedId(
3927      *         Uri.withAppendedPath(
3928      *             ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3929      *             StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3930      *         streamItemPhotoId), null, null, null, null);
3931      * </pre>
3932      * </dd>
3933      * <dt>Querying for all photos in a stream item</dt>
3934      * <dd>
3935      * <pre>
3936      * Cursor c = getContentResolver().query(
3937      *     Uri.withAppendedPath(
3938      *         ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3939      *         StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3940      *     null, null, null, StreamItemPhotos.SORT_INDEX);
3941      * </pre>
3942      * </dl>
3943      * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a
3944      * {@link StreamItemPhotos#PHOTO_URI}.  The {@link StreamItemPhotos#PHOTO_FILE_ID}
3945      * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to
3946      * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as
3947      * an asset file, as follows:
3948      * <pre>
3949      * public InputStream openDisplayPhoto(String photoUri) {
3950      *     try {
3951      *         AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
3952      *         return fd.createInputStream();
3953      *     } catch (IOException e) {
3954      *         return null;
3955      *     }
3956      * }
3957      * <pre>
3958      * </dd>
3959      * </dl>
3960      *
3961      * @deprecated - Do not use. This will not be supported in the future. In the future,
3962      * cursors returned from related queries will be empty.
3963      *
3964      * @hide
3965      * @removed
3966      */
3967     @Deprecated
3968     public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns {
3969         /**
3970          * No public constructor since this is a utility class
3971          *
3972          * @deprecated - Do not use. This will not be supported in the future. In the future,
3973          * cursors returned from related queries will be empty.
3974          */
3975         @Deprecated
StreamItemPhotos()3976         private StreamItemPhotos() {
3977         }
3978 
3979         /**
3980          * <p>
3981          * The binary representation of the photo.  Any size photo can be inserted;
3982          * the provider will resize it appropriately for storage and display.
3983          * </p>
3984          * <p>
3985          * This is only intended for use when inserting or updating a stream item photo.
3986          * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI}
3987          * as an asset file.
3988          * </p>
3989          * <P>Type: BLOB</P>
3990          *
3991          * @deprecated - Do not use. This will not be supported in the future. In the future,
3992          * cursors returned from related queries will be empty.
3993          */
3994         @Deprecated
3995         public static final String PHOTO = "photo";
3996     }
3997 
3998     /**
3999      * Columns in the StreamItemPhotos table.
4000      *
4001      * @see ContactsContract.StreamItemPhotos
4002      * @deprecated - Do not use. This will not be supported in the future. In the future,
4003      * cursors returned from related queries will be empty.
4004      *
4005      * @hide
4006      * @removed
4007      */
4008     @Deprecated
4009     protected interface StreamItemPhotosColumns {
4010         /**
4011          * A reference to the {@link StreamItems#_ID} this photo is associated with.
4012          * <P>Type: NUMBER</P>
4013          *
4014          * @deprecated - Do not use. This will not be supported in the future. In the future,
4015          * cursors returned from related queries will be empty.
4016          */
4017         @Deprecated
4018         public static final String STREAM_ITEM_ID = "stream_item_id";
4019 
4020         /**
4021          * An integer to use for sort order for photos in the stream item.  If not
4022          * specified, the {@link StreamItemPhotos#_ID} will be used for sorting.
4023          * <P>Type: NUMBER</P>
4024          *
4025          * @deprecated - Do not use. This will not be supported in the future. In the future,
4026          * cursors returned from related queries will be empty.
4027          */
4028         @Deprecated
4029         public static final String SORT_INDEX = "sort_index";
4030 
4031         /**
4032          * Photo file ID for the photo.
4033          * See {@link ContactsContract.DisplayPhoto}.
4034          * <P>Type: NUMBER</P>
4035          *
4036          * @deprecated - Do not use. This will not be supported in the future. In the future,
4037          * cursors returned from related queries will be empty.
4038          */
4039         @Deprecated
4040         public static final String PHOTO_FILE_ID = "photo_file_id";
4041 
4042         /**
4043          * URI for retrieving the photo content, automatically populated.  Callers
4044          * may retrieve the photo content by opening this URI as an asset file.
4045          * <P>Type: TEXT</P>
4046          *
4047          * @deprecated - Do not use. This will not be supported in the future. In the future,
4048          * cursors returned from related queries will be empty.
4049          */
4050         @Deprecated
4051         public static final String PHOTO_URI = "photo_uri";
4052 
4053         /**
4054          * Generic column for use by sync adapters.
4055          *
4056          * @deprecated - Do not use. This will not be supported in the future. In the future,
4057          * cursors returned from related queries will be empty.
4058          */
4059         @Deprecated
4060         public static final String SYNC1 = "stream_item_photo_sync1";
4061         /**
4062          * Generic column for use by sync adapters.
4063          *
4064          * @deprecated - Do not use. This will not be supported in the future. In the future,
4065          * cursors returned from related queries will be empty.
4066          */
4067         @Deprecated
4068         public static final String SYNC2 = "stream_item_photo_sync2";
4069         /**
4070          * Generic column for use by sync adapters.
4071          *
4072          * @deprecated - Do not use. This will not be supported in the future. In the future,
4073          * cursors returned from related queries will be empty.
4074          */
4075         @Deprecated
4076         public static final String SYNC3 = "stream_item_photo_sync3";
4077         /**
4078          * Generic column for use by sync adapters.
4079          *
4080          * @deprecated - Do not use. This will not be supported in the future. In the future,
4081          * cursors returned from related queries will be empty.
4082          */
4083         @Deprecated
4084         public static final String SYNC4 = "stream_item_photo_sync4";
4085     }
4086 
4087     /**
4088      * <p>
4089      * Constants for the photo files table, which tracks metadata for hi-res photos
4090      * stored in the file system.
4091      * </p>
4092      *
4093      * @hide
4094      */
4095     public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns {
4096         /**
4097          * No public constructor since this is a utility class
4098          */
PhotoFiles()4099         private PhotoFiles() {
4100         }
4101     }
4102 
4103     /**
4104      * Columns in the PhotoFiles table.
4105      *
4106      * @see ContactsContract.PhotoFiles
4107      *
4108      * @hide
4109      */
4110     protected interface PhotoFilesColumns {
4111 
4112         /**
4113          * The height, in pixels, of the photo this entry is associated with.
4114          * <P>Type: NUMBER</P>
4115          */
4116         public static final String HEIGHT = "height";
4117 
4118         /**
4119          * The width, in pixels, of the photo this entry is associated with.
4120          * <P>Type: NUMBER</P>
4121          */
4122         public static final String WIDTH = "width";
4123 
4124         /**
4125          * The size, in bytes, of the photo stored on disk.
4126          * <P>Type: NUMBER</P>
4127          */
4128         public static final String FILESIZE = "filesize";
4129     }
4130 
4131     /**
4132      * Columns in the Data table.
4133      *
4134      * @see ContactsContract.Data
4135      */
4136     protected interface DataColumns {
4137         /**
4138          * The package name to use when creating {@link Resources} objects for
4139          * this data row. This value is only designed for use when building user
4140          * interfaces, and should not be used to infer the owner.
4141          */
4142         public static final String RES_PACKAGE = "res_package";
4143 
4144         /**
4145          * The MIME type of the item represented by this row.
4146          */
4147         public static final String MIMETYPE = "mimetype";
4148 
4149         /**
4150          * Hash id on the data fields, used for backup and restore.
4151          *
4152          * @hide
4153          */
4154         public static final String HASH_ID = "hash_id";
4155 
4156         /**
4157          * A reference to the {@link RawContacts#_ID}
4158          * that this data belongs to.
4159          */
4160         public static final String RAW_CONTACT_ID = "raw_contact_id";
4161 
4162         /**
4163          * Whether this is the primary entry of its kind for the raw contact it belongs to.
4164          * <P>Type: INTEGER (if set, non-0 means true)</P>
4165          */
4166         public static final String IS_PRIMARY = "is_primary";
4167 
4168         /**
4169          * Whether this is the primary entry of its kind for the aggregate
4170          * contact it belongs to. Any data record that is "super primary" must
4171          * also be "primary".
4172          * <P>Type: INTEGER (if set, non-0 means true)</P>
4173          */
4174         public static final String IS_SUPER_PRIMARY = "is_super_primary";
4175 
4176         /**
4177          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
4178          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
4179          * <P>Type: INTEGER</P>
4180          */
4181         public static final String IS_READ_ONLY = "is_read_only";
4182 
4183         /**
4184          * The version of this data record. This is a read-only value. The data column is
4185          * guaranteed to not change without the version going up. This value is monotonically
4186          * increasing.
4187          * <P>Type: INTEGER</P>
4188          */
4189         public static final String DATA_VERSION = "data_version";
4190 
4191         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4192         public static final String DATA1 = "data1";
4193         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4194         public static final String DATA2 = "data2";
4195         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4196         public static final String DATA3 = "data3";
4197         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4198         public static final String DATA4 = "data4";
4199         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4200         public static final String DATA5 = "data5";
4201         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4202         public static final String DATA6 = "data6";
4203         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4204         public static final String DATA7 = "data7";
4205         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4206         public static final String DATA8 = "data8";
4207         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4208         public static final String DATA9 = "data9";
4209         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4210         public static final String DATA10 = "data10";
4211         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4212         public static final String DATA11 = "data11";
4213         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4214         public static final String DATA12 = "data12";
4215         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4216         public static final String DATA13 = "data13";
4217         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4218         public static final String DATA14 = "data14";
4219         /**
4220          * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
4221          * this field is used to store BLOBs (binary data).
4222          */
4223         public static final String DATA15 = "data15";
4224 
4225         /** Generic column for use by sync adapters. */
4226         public static final String SYNC1 = "data_sync1";
4227         /** Generic column for use by sync adapters. */
4228         public static final String SYNC2 = "data_sync2";
4229         /** Generic column for use by sync adapters. */
4230         public static final String SYNC3 = "data_sync3";
4231         /** Generic column for use by sync adapters. */
4232         public static final String SYNC4 = "data_sync4";
4233 
4234         /**
4235          * Carrier presence information.
4236          * <P>
4237          * Type: INTEGER (A bitmask of CARRIER_PRESENCE_* fields)
4238          * </P>
4239          */
4240         public static final String CARRIER_PRESENCE = "carrier_presence";
4241 
4242         /**
4243          * Indicates that the entry is Video Telephony (VT) capable on the
4244          * current carrier. An allowed bitmask of {@link #CARRIER_PRESENCE}.
4245          */
4246         public static final int CARRIER_PRESENCE_VT_CAPABLE = 0x01;
4247     }
4248 
4249     /**
4250      * Columns in the Data_Usage_Stat table
4251      */
4252     protected interface DataUsageStatColumns {
4253         /** The last time (in milliseconds) this {@link Data} was used. */
4254         public static final String LAST_TIME_USED = "last_time_used";
4255 
4256         /** The number of times the referenced {@link Data} has been used. */
4257         public static final String TIMES_USED = "times_used";
4258 
4259         /** @hide Raw value. */
4260         public static final String RAW_LAST_TIME_USED = HIDDEN_COLUMN_PREFIX + LAST_TIME_USED;
4261 
4262         /** @hide Raw value. */
4263         public static final String RAW_TIMES_USED = HIDDEN_COLUMN_PREFIX + TIMES_USED;
4264 
4265         /**
4266          * @hide
4267          * Low res version.  Same as {@link #LAST_TIME_USED} but use it in CP2 for clarification.
4268          */
4269         public static final String LR_LAST_TIME_USED = LAST_TIME_USED;
4270 
4271         /**
4272          * @hide
4273          * Low res version.  Same as {@link #TIMES_USED} but use it in CP2 for clarification.
4274          */
4275         public static final String LR_TIMES_USED = TIMES_USED;
4276     }
4277 
4278     /**
4279      * Combines all columns returned by {@link ContactsContract.Data} table queries.
4280      *
4281      * @see ContactsContract.Data
4282      */
4283     protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
4284             RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
4285             ContactStatusColumns, DataUsageStatColumns {
4286     }
4287 
4288     /**
4289      * <p>
4290      * Constants for the data table, which contains data points tied to a raw
4291      * contact.  Each row of the data table is typically used to store a single
4292      * piece of contact
4293      * information (such as a phone number) and its
4294      * associated metadata (such as whether it is a work or home number).
4295      * </p>
4296      * <h3>Data kinds</h3>
4297      * <p>
4298      * Data is a generic table that can hold any kind of contact data.
4299      * The kind of data stored in a given row is specified by the row's
4300      * {@link #MIMETYPE} value, which determines the meaning of the
4301      * generic columns {@link #DATA1} through
4302      * {@link #DATA15}.
4303      * For example, if the data kind is
4304      * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
4305      * {@link #DATA1} stores the
4306      * phone number, but if the data kind is
4307      * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
4308      * stores the email address.
4309      * Sync adapters and applications can introduce their own data kinds.
4310      * </p>
4311      * <p>
4312      * ContactsContract defines a small number of pre-defined data kinds, e.g.
4313      * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
4314      * convenience, these classes define data kind specific aliases for DATA1 etc.
4315      * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
4316      * {@link ContactsContract.Data Data.DATA1}.
4317      * </p>
4318      * <p>
4319      * {@link #DATA1} is an indexed column and should be used for the data element that is
4320      * expected to be most frequently used in query selections. For example, in the
4321      * case of a row representing email addresses {@link #DATA1} should probably
4322      * be used for the email address itself, while {@link #DATA2} etc can be
4323      * used for auxiliary information like type of email address.
4324      * <p>
4325      * <p>
4326      * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
4327      * </p>
4328      * <p>
4329      * The sync adapter for a given account type must correctly handle every data type
4330      * used in the corresponding raw contacts.  Otherwise it could result in lost or
4331      * corrupted data.
4332      * </p>
4333      * <p>
4334      * Similarly, you should refrain from introducing new kinds of data for an other
4335      * party's account types. For example, if you add a data row for
4336      * "favorite song" to a raw contact owned by a Google account, it will not
4337      * get synced to the server, because the Google sync adapter does not know
4338      * how to handle this data kind. Thus new data kinds are typically
4339      * introduced along with new account types, i.e. new sync adapters.
4340      * </p>
4341      * <h3>Batch operations</h3>
4342      * <p>
4343      * Data rows can be inserted/updated/deleted using the traditional
4344      * {@link ContentResolver#insert}, {@link ContentResolver#update} and
4345      * {@link ContentResolver#delete} methods, however the newer mechanism based
4346      * on a batch of {@link ContentProviderOperation} will prove to be a better
4347      * choice in almost all cases. All operations in a batch are executed in a
4348      * single transaction, which ensures that the phone-side and server-side
4349      * state of a raw contact are always consistent. Also, the batch-based
4350      * approach is far more efficient: not only are the database operations
4351      * faster when executed in a single transaction, but also sending a batch of
4352      * commands to the content provider saves a lot of time on context switching
4353      * between your process and the process in which the content provider runs.
4354      * </p>
4355      * <p>
4356      * The flip side of using batched operations is that a large batch may lock
4357      * up the database for a long time preventing other applications from
4358      * accessing data and potentially causing ANRs ("Application Not Responding"
4359      * dialogs.)
4360      * </p>
4361      * <p>
4362      * To avoid such lockups of the database, make sure to insert "yield points"
4363      * in the batch. A yield point indicates to the content provider that before
4364      * executing the next operation it can commit the changes that have already
4365      * been made, yield to other requests, open another transaction and continue
4366      * processing operations. A yield point will not automatically commit the
4367      * transaction, but only if there is another request waiting on the
4368      * database. Normally a sync adapter should insert a yield point at the
4369      * beginning of each raw contact operation sequence in the batch. See
4370      * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
4371      * </p>
4372      * <h3>Operations</h3>
4373      * <dl>
4374      * <dt><b>Insert</b></dt>
4375      * <dd>
4376      * <p>
4377      * An individual data row can be inserted using the traditional
4378      * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
4379      * should always be inserted as a batch.
4380      * </p>
4381      * <p>
4382      * An example of a traditional insert:
4383      * <pre>
4384      * ContentValues values = new ContentValues();
4385      * values.put(Data.RAW_CONTACT_ID, rawContactId);
4386      * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
4387      * values.put(Phone.NUMBER, "1-800-GOOG-411");
4388      * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
4389      * values.put(Phone.LABEL, "free directory assistance");
4390      * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
4391      * </pre>
4392      * <p>
4393      * The same done using ContentProviderOperations:
4394      * <pre>
4395      * ArrayList&lt;ContentProviderOperation&gt; ops =
4396      *          new ArrayList&lt;ContentProviderOperation&gt;();
4397      *
4398      * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
4399      *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
4400      *          .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
4401      *          .withValue(Phone.NUMBER, "1-800-GOOG-411")
4402      *          .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
4403      *          .withValue(Phone.LABEL, "free directory assistance")
4404      *          .build());
4405      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4406      * </pre>
4407      * </p>
4408      * <dt><b>Update</b></dt>
4409      * <dd>
4410      * <p>
4411      * Just as with insert, update can be done incrementally or as a batch,
4412      * the batch mode being the preferred method:
4413      * <pre>
4414      * ArrayList&lt;ContentProviderOperation&gt; ops =
4415      *          new ArrayList&lt;ContentProviderOperation&gt;();
4416      *
4417      * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
4418      *          .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4419      *          .withValue(Email.DATA, "somebody@android.com")
4420      *          .build());
4421      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4422      * </pre>
4423      * </p>
4424      * </dd>
4425      * <dt><b>Delete</b></dt>
4426      * <dd>
4427      * <p>
4428      * Just as with insert and update, deletion can be done either using the
4429      * {@link ContentResolver#delete} method or using a ContentProviderOperation:
4430      * <pre>
4431      * ArrayList&lt;ContentProviderOperation&gt; ops =
4432      *          new ArrayList&lt;ContentProviderOperation&gt;();
4433      *
4434      * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
4435      *          .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4436      *          .build());
4437      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4438      * </pre>
4439      * </p>
4440      * </dd>
4441      * <dt><b>Query</b></dt>
4442      * <dd>
4443      * <p>
4444      * <dl>
4445      * <dt>Finding all Data of a given type for a given contact</dt>
4446      * <dd>
4447      * <pre>
4448      * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4449      *          new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4450      *          Data.CONTACT_ID + &quot;=?&quot; + " AND "
4451      *                  + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4452      *          new String[] {String.valueOf(contactId)}, null);
4453      * </pre>
4454      * </p>
4455      * <p>
4456      * </dd>
4457      * <dt>Finding all Data of a given type for a given raw contact</dt>
4458      * <dd>
4459      * <pre>
4460      * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4461      *          new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4462      *          Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
4463      *                  + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4464      *          new String[] {String.valueOf(rawContactId)}, null);
4465      * </pre>
4466      * </dd>
4467      * <dt>Finding all Data for a given raw contact</dt>
4468      * <dd>
4469      * Most sync adapters will want to read all data rows for a raw contact
4470      * along with the raw contact itself.  For that you should use the
4471      * {@link RawContactsEntity}. See also {@link RawContacts}.
4472      * </dd>
4473      * </dl>
4474      * </p>
4475      * </dd>
4476      * </dl>
4477      * <h2>Columns</h2>
4478      * <p>
4479      * Many columns are available via a {@link Data#CONTENT_URI} query.  For best performance you
4480      * should explicitly specify a projection to only those columns that you need.
4481      * </p>
4482      * <table class="jd-sumtable">
4483      * <tr>
4484      * <th colspan='4'>Data</th>
4485      * </tr>
4486      * <tr>
4487      * <td style="width: 7em;">long</td>
4488      * <td style="width: 20em;">{@link #_ID}</td>
4489      * <td style="width: 5em;">read-only</td>
4490      * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
4491      * it would be a bad idea to delete and reinsert a data row. A sync adapter should
4492      * always do an update instead.</td>
4493      * </tr>
4494      * <tr>
4495      * <td>String</td>
4496      * <td>{@link #MIMETYPE}</td>
4497      * <td>read/write-once</td>
4498      * <td>
4499      * <p>The MIME type of the item represented by this row. Examples of common
4500      * MIME types are:
4501      * <ul>
4502      * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
4503      * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
4504      * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
4505      * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
4506      * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
4507      * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
4508      * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
4509      * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
4510      * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
4511      * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
4512      * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
4513      * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
4514      * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
4515      * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li>
4516      * </ul>
4517      * </p>
4518      * </td>
4519      * </tr>
4520      * <tr>
4521      * <td>long</td>
4522      * <td>{@link #RAW_CONTACT_ID}</td>
4523      * <td>read/write-once</td>
4524      * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
4525      * </tr>
4526      * <tr>
4527      * <td>int</td>
4528      * <td>{@link #IS_PRIMARY}</td>
4529      * <td>read/write</td>
4530      * <td>Whether this is the primary entry of its kind for the raw contact it belongs to.
4531      * "1" if true, "0" if false.
4532      * </td>
4533      * </tr>
4534      * <tr>
4535      * <td>int</td>
4536      * <td>{@link #IS_SUPER_PRIMARY}</td>
4537      * <td>read/write</td>
4538      * <td>Whether this is the primary entry of its kind for the aggregate
4539      * contact it belongs to. Any data record that is "super primary" must
4540      * also be "primary".  For example, the super-primary entry may be
4541      * interpreted as the default contact value of its kind (for example,
4542      * the default phone number to use for the contact).</td>
4543      * </tr>
4544      * <tr>
4545      * <td>int</td>
4546      * <td>{@link #DATA_VERSION}</td>
4547      * <td>read-only</td>
4548      * <td>The version of this data record. Whenever the data row changes
4549      * the version goes up. This value is monotonically increasing.</td>
4550      * </tr>
4551      * <tr>
4552      * <td>Any type</td>
4553      * <td>
4554      * {@link #DATA1}<br>
4555      * {@link #DATA2}<br>
4556      * {@link #DATA3}<br>
4557      * {@link #DATA4}<br>
4558      * {@link #DATA5}<br>
4559      * {@link #DATA6}<br>
4560      * {@link #DATA7}<br>
4561      * {@link #DATA8}<br>
4562      * {@link #DATA9}<br>
4563      * {@link #DATA10}<br>
4564      * {@link #DATA11}<br>
4565      * {@link #DATA12}<br>
4566      * {@link #DATA13}<br>
4567      * {@link #DATA14}<br>
4568      * {@link #DATA15}
4569      * </td>
4570      * <td>read/write</td>
4571      * <td>
4572      * <p>
4573      * Generic data columns.  The meaning of each column is determined by the
4574      * {@link #MIMETYPE}.  By convention, {@link #DATA15} is used for storing
4575      * BLOBs (binary data).
4576      * </p>
4577      * <p>
4578      * Data columns whose meaning is not explicitly defined for a given MIMETYPE
4579      * should not be used.  There is no guarantee that any sync adapter will
4580      * preserve them.  Sync adapters themselves should not use such columns either,
4581      * but should instead use {@link #SYNC1}-{@link #SYNC4}.
4582      * </p>
4583      * </td>
4584      * </tr>
4585      * <tr>
4586      * <td>Any type</td>
4587      * <td>
4588      * {@link #SYNC1}<br>
4589      * {@link #SYNC2}<br>
4590      * {@link #SYNC3}<br>
4591      * {@link #SYNC4}
4592      * </td>
4593      * <td>read/write</td>
4594      * <td>Generic columns for use by sync adapters. For example, a Photo row
4595      * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
4596      * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
4597      * </tr>
4598      * </table>
4599      *
4600      * <p>
4601      * Some columns from the most recent associated status update are also available
4602      * through an implicit join.
4603      * </p>
4604      * <table class="jd-sumtable">
4605      * <tr>
4606      * <th colspan='4'>Join with {@link StatusUpdates}</th>
4607      * </tr>
4608      * <tr>
4609      * <td style="width: 7em;">int</td>
4610      * <td style="width: 20em;">{@link #PRESENCE}</td>
4611      * <td style="width: 5em;">read-only</td>
4612      * <td>IM presence status linked to this data row. Compare with
4613      * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
4614      * all IM rows. See {@link StatusUpdates} for individual status definitions.
4615      * The provider may choose not to store this value
4616      * in persistent storage. The expectation is that presence status will be
4617      * updated on a regular basis.
4618      * </td>
4619      * </tr>
4620      * <tr>
4621      * <td>String</td>
4622      * <td>{@link #STATUS}</td>
4623      * <td>read-only</td>
4624      * <td>Latest status update linked with this data row.</td>
4625      * </tr>
4626      * <tr>
4627      * <td>long</td>
4628      * <td>{@link #STATUS_TIMESTAMP}</td>
4629      * <td>read-only</td>
4630      * <td>The absolute time in milliseconds when the latest status was
4631      * inserted/updated for this data row.</td>
4632      * </tr>
4633      * <tr>
4634      * <td>String</td>
4635      * <td>{@link #STATUS_RES_PACKAGE}</td>
4636      * <td>read-only</td>
4637      * <td>The package containing resources for this status: label and icon.</td>
4638      * </tr>
4639      * <tr>
4640      * <td>long</td>
4641      * <td>{@link #STATUS_LABEL}</td>
4642      * <td>read-only</td>
4643      * <td>The resource ID of the label describing the source of status update linked
4644      * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4645      * </tr>
4646      * <tr>
4647      * <td>long</td>
4648      * <td>{@link #STATUS_ICON}</td>
4649      * <td>read-only</td>
4650      * <td>The resource ID of the icon for the source of the status update linked
4651      * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4652      * </tr>
4653      * </table>
4654      *
4655      * <p>
4656      * Some columns from the associated raw contact are also available through an
4657      * implicit join.  The other columns are excluded as uninteresting in this
4658      * context.
4659      * </p>
4660      *
4661      * <table class="jd-sumtable">
4662      * <tr>
4663      * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
4664      * </tr>
4665      * <tr>
4666      * <td style="width: 7em;">long</td>
4667      * <td style="width: 20em;">{@link #CONTACT_ID}</td>
4668      * <td style="width: 5em;">read-only</td>
4669      * <td>The id of the row in the {@link Contacts} table that this data belongs
4670      * to.</td>
4671      * </tr>
4672      * <tr>
4673      * <td>int</td>
4674      * <td>{@link #AGGREGATION_MODE}</td>
4675      * <td>read-only</td>
4676      * <td>See {@link RawContacts}.</td>
4677      * </tr>
4678      * <tr>
4679      * <td>int</td>
4680      * <td>{@link #DELETED}</td>
4681      * <td>read-only</td>
4682      * <td>See {@link RawContacts}.</td>
4683      * </tr>
4684      * </table>
4685      *
4686      * <p>
4687      * The ID column for the associated aggregated contact table
4688      * {@link ContactsContract.Contacts} is available
4689      * via the implicit join to the {@link RawContacts} table, see above.
4690      * The remaining columns from this table are also
4691      * available, through an implicit join.  This
4692      * facilitates lookup by
4693      * the value of a single data element, such as the email address.
4694      * </p>
4695      *
4696      * <table class="jd-sumtable">
4697      * <tr>
4698      * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
4699      * </tr>
4700      * <tr>
4701      * <td style="width: 7em;">String</td>
4702      * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
4703      * <td style="width: 5em;">read-only</td>
4704      * <td>See {@link ContactsContract.Contacts}</td>
4705      * </tr>
4706      * <tr>
4707      * <td>String</td>
4708      * <td>{@link #DISPLAY_NAME}</td>
4709      * <td>read-only</td>
4710      * <td>See {@link ContactsContract.Contacts}</td>
4711      * </tr>
4712      * <tr>
4713      * <td>long</td>
4714      * <td>{@link #PHOTO_ID}</td>
4715      * <td>read-only</td>
4716      * <td>See {@link ContactsContract.Contacts}.</td>
4717      * </tr>
4718      * <tr>
4719      * <td>int</td>
4720      * <td>{@link #IN_VISIBLE_GROUP}</td>
4721      * <td>read-only</td>
4722      * <td>See {@link ContactsContract.Contacts}.</td>
4723      * </tr>
4724      * <tr>
4725      * <td>int</td>
4726      * <td>{@link #HAS_PHONE_NUMBER}</td>
4727      * <td>read-only</td>
4728      * <td>See {@link ContactsContract.Contacts}.</td>
4729      * </tr>
4730      * <tr>
4731      * <td>int</td>
4732      * <td>{@link #TIMES_CONTACTED}</td>
4733      * <td>read-only</td>
4734      * <td>See {@link ContactsContract.Contacts}.</td>
4735      * </tr>
4736      * <tr>
4737      * <td>long</td>
4738      * <td>{@link #LAST_TIME_CONTACTED}</td>
4739      * <td>read-only</td>
4740      * <td>See {@link ContactsContract.Contacts}.</td>
4741      * </tr>
4742      * <tr>
4743      * <td>int</td>
4744      * <td>{@link #STARRED}</td>
4745      * <td>read-only</td>
4746      * <td>See {@link ContactsContract.Contacts}.</td>
4747      * </tr>
4748      * <tr>
4749      * <td>String</td>
4750      * <td>{@link #CUSTOM_RINGTONE}</td>
4751      * <td>read-only</td>
4752      * <td>See {@link ContactsContract.Contacts}.</td>
4753      * </tr>
4754      * <tr>
4755      * <td>int</td>
4756      * <td>{@link #SEND_TO_VOICEMAIL}</td>
4757      * <td>read-only</td>
4758      * <td>See {@link ContactsContract.Contacts}.</td>
4759      * </tr>
4760      * <tr>
4761      * <td>int</td>
4762      * <td>{@link #CONTACT_PRESENCE}</td>
4763      * <td>read-only</td>
4764      * <td>See {@link ContactsContract.Contacts}.</td>
4765      * </tr>
4766      * <tr>
4767      * <td>String</td>
4768      * <td>{@link #CONTACT_STATUS}</td>
4769      * <td>read-only</td>
4770      * <td>See {@link ContactsContract.Contacts}.</td>
4771      * </tr>
4772      * <tr>
4773      * <td>long</td>
4774      * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
4775      * <td>read-only</td>
4776      * <td>See {@link ContactsContract.Contacts}.</td>
4777      * </tr>
4778      * <tr>
4779      * <td>String</td>
4780      * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
4781      * <td>read-only</td>
4782      * <td>See {@link ContactsContract.Contacts}.</td>
4783      * </tr>
4784      * <tr>
4785      * <td>long</td>
4786      * <td>{@link #CONTACT_STATUS_LABEL}</td>
4787      * <td>read-only</td>
4788      * <td>See {@link ContactsContract.Contacts}.</td>
4789      * </tr>
4790      * <tr>
4791      * <td>long</td>
4792      * <td>{@link #CONTACT_STATUS_ICON}</td>
4793      * <td>read-only</td>
4794      * <td>See {@link ContactsContract.Contacts}.</td>
4795      * </tr>
4796      * </table>
4797      */
4798     public final static class Data implements DataColumnsWithJoins, ContactCounts {
4799         /**
4800          * This utility class cannot be instantiated
4801          */
Data()4802         private Data() {}
4803 
4804         /**
4805          * The content:// style URI for this table, which requests a directory
4806          * of data rows matching the selection criteria.
4807          */
4808         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
4809 
4810         /**
4811         * The content:// style URI for this table in managed profile, which requests a directory
4812         * of data rows matching the selection criteria.
4813         *
4814         * @hide
4815         */
4816         static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
4817                 "data_enterprise");
4818 
4819         /**
4820          * A boolean parameter for {@link Data#CONTENT_URI}.
4821          * This specifies whether or not the returned data items should be filtered to show
4822          * data items belonging to visible contacts only.
4823          */
4824         public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
4825 
4826         /**
4827          * The MIME type of the results from {@link #CONTENT_URI}.
4828          */
4829         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
4830 
4831         /**
4832          * <p>
4833          * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
4834          * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
4835          * entry of the given {@link ContactsContract.Data} entry.
4836          * </p>
4837          * <p>
4838          * Returns the Uri for the contact in the first entry returned by
4839          * {@link ContentResolver#query(Uri, String[], String, String[], String)}
4840          * for the provided {@code dataUri}.  If the query returns null or empty
4841          * results, silently returns null.
4842          * </p>
4843          */
getContactLookupUri(ContentResolver resolver, Uri dataUri)4844         public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
4845             final Cursor cursor = resolver.query(dataUri, new String[] {
4846                     RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
4847             }, null, null, null);
4848 
4849             Uri lookupUri = null;
4850             try {
4851                 if (cursor != null && cursor.moveToFirst()) {
4852                     final long contactId = cursor.getLong(0);
4853                     final String lookupKey = cursor.getString(1);
4854                     return Contacts.getLookupUri(contactId, lookupKey);
4855                 }
4856             } finally {
4857                 if (cursor != null) cursor.close();
4858             }
4859             return lookupUri;
4860         }
4861     }
4862 
4863     /**
4864      * <p>
4865      * Constants for the raw contacts entities table, which can be thought of as
4866      * an outer join of the raw_contacts table with the data table.  It is a strictly
4867      * read-only table.
4868      * </p>
4869      * <p>
4870      * If a raw contact has data rows, the RawContactsEntity cursor will contain
4871      * a one row for each data row. If the raw contact has no data rows, the
4872      * cursor will still contain one row with the raw contact-level information
4873      * and nulls for data columns.
4874      *
4875      * <pre>
4876      * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
4877      * Cursor c = getContentResolver().query(entityUri,
4878      *          new String[]{
4879      *              RawContactsEntity.SOURCE_ID,
4880      *              RawContactsEntity.DATA_ID,
4881      *              RawContactsEntity.MIMETYPE,
4882      *              RawContactsEntity.DATA1
4883      *          }, null, null, null);
4884      * try {
4885      *     while (c.moveToNext()) {
4886      *         String sourceId = c.getString(0);
4887      *         if (!c.isNull(1)) {
4888      *             String mimeType = c.getString(2);
4889      *             String data = c.getString(3);
4890      *             ...
4891      *         }
4892      *     }
4893      * } finally {
4894      *     c.close();
4895      * }
4896      * </pre>
4897      *
4898      * <h3>Columns</h3>
4899      * RawContactsEntity has a combination of RawContact and Data columns.
4900      *
4901      * <table class="jd-sumtable">
4902      * <tr>
4903      * <th colspan='4'>RawContacts</th>
4904      * </tr>
4905      * <tr>
4906      * <td style="width: 7em;">long</td>
4907      * <td style="width: 20em;">{@link #_ID}</td>
4908      * <td style="width: 5em;">read-only</td>
4909      * <td>Raw contact row ID. See {@link RawContacts}.</td>
4910      * </tr>
4911      * <tr>
4912      * <td>long</td>
4913      * <td>{@link #CONTACT_ID}</td>
4914      * <td>read-only</td>
4915      * <td>See {@link RawContacts}.</td>
4916      * </tr>
4917      * <tr>
4918      * <td>int</td>
4919      * <td>{@link #AGGREGATION_MODE}</td>
4920      * <td>read-only</td>
4921      * <td>See {@link RawContacts}.</td>
4922      * </tr>
4923      * <tr>
4924      * <td>int</td>
4925      * <td>{@link #DELETED}</td>
4926      * <td>read-only</td>
4927      * <td>See {@link RawContacts}.</td>
4928      * </tr>
4929      * </table>
4930      *
4931      * <table class="jd-sumtable">
4932      * <tr>
4933      * <th colspan='4'>Data</th>
4934      * </tr>
4935      * <tr>
4936      * <td style="width: 7em;">long</td>
4937      * <td style="width: 20em;">{@link #DATA_ID}</td>
4938      * <td style="width: 5em;">read-only</td>
4939      * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
4940      * </tr>
4941      * <tr>
4942      * <td>String</td>
4943      * <td>{@link #MIMETYPE}</td>
4944      * <td>read-only</td>
4945      * <td>See {@link ContactsContract.Data}.</td>
4946      * </tr>
4947      * <tr>
4948      * <td>int</td>
4949      * <td>{@link #IS_PRIMARY}</td>
4950      * <td>read-only</td>
4951      * <td>See {@link ContactsContract.Data}.</td>
4952      * </tr>
4953      * <tr>
4954      * <td>int</td>
4955      * <td>{@link #IS_SUPER_PRIMARY}</td>
4956      * <td>read-only</td>
4957      * <td>See {@link ContactsContract.Data}.</td>
4958      * </tr>
4959      * <tr>
4960      * <td>int</td>
4961      * <td>{@link #DATA_VERSION}</td>
4962      * <td>read-only</td>
4963      * <td>See {@link ContactsContract.Data}.</td>
4964      * </tr>
4965      * <tr>
4966      * <td>Any type</td>
4967      * <td>
4968      * {@link #DATA1}<br>
4969      * {@link #DATA2}<br>
4970      * {@link #DATA3}<br>
4971      * {@link #DATA4}<br>
4972      * {@link #DATA5}<br>
4973      * {@link #DATA6}<br>
4974      * {@link #DATA7}<br>
4975      * {@link #DATA8}<br>
4976      * {@link #DATA9}<br>
4977      * {@link #DATA10}<br>
4978      * {@link #DATA11}<br>
4979      * {@link #DATA12}<br>
4980      * {@link #DATA13}<br>
4981      * {@link #DATA14}<br>
4982      * {@link #DATA15}
4983      * </td>
4984      * <td>read-only</td>
4985      * <td>See {@link ContactsContract.Data}.</td>
4986      * </tr>
4987      * <tr>
4988      * <td>Any type</td>
4989      * <td>
4990      * {@link #SYNC1}<br>
4991      * {@link #SYNC2}<br>
4992      * {@link #SYNC3}<br>
4993      * {@link #SYNC4}
4994      * </td>
4995      * <td>read-only</td>
4996      * <td>See {@link ContactsContract.Data}.</td>
4997      * </tr>
4998      * </table>
4999      */
5000     public final static class RawContactsEntity
5001             implements BaseColumns, DataColumns, RawContactsColumns {
5002         /**
5003          * This utility class cannot be instantiated
5004          */
RawContactsEntity()5005         private RawContactsEntity() {}
5006 
5007         /**
5008          * The content:// style URI for this table
5009          */
5010         public static final Uri CONTENT_URI =
5011                 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
5012 
5013         /**
5014         * The content:// style URI for this table in corp profile
5015         *
5016         * @hide
5017         */
5018         public static final Uri CORP_CONTENT_URI =
5019                 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities_corp");
5020 
5021         /**
5022          * The content:// style URI for this table, specific to the user's profile.
5023          */
5024         public static final Uri PROFILE_CONTENT_URI =
5025                 Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities");
5026 
5027         /**
5028          * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
5029          */
5030         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
5031 
5032         /**
5033          * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
5034          * Data.CONTENT_URI contains only exportable data.
5035          *
5036          * This flag is useful (currently) only for vCard exporter in Contacts app, which
5037          * needs to exclude "un-exportable" data from available data to export, while
5038          * Contacts app itself has priviledge to access all data including "un-expotable"
5039          * ones and providers return all of them regardless of the callers' intention.
5040          * <P>Type: INTEGER</p>
5041          *
5042          * @hide Maybe available only in Eclair and not really ready for public use.
5043          * TODO: remove, or implement this feature completely. As of now (Eclair),
5044          * we only use this flag in queryEntities(), not query().
5045          */
5046         public static final String FOR_EXPORT_ONLY = "for_export_only";
5047 
5048         /**
5049          * The ID of the data column. The value will be null if this raw contact has no data rows.
5050          * <P>Type: INTEGER</P>
5051          */
5052         public static final String DATA_ID = "data_id";
5053     }
5054 
5055     /**
5056      * @see PhoneLookup
5057      */
5058     protected interface PhoneLookupColumns {
5059         /**
5060          *  The ID of the data row.
5061          *  <P>Type: INTEGER</P>
5062          */
5063         public static final String DATA_ID = "data_id";
5064         /**
5065          * A reference to the {@link ContactsContract.Contacts#_ID} that this
5066          * data belongs to.
5067          * <P>Type: INTEGER</P>
5068          */
5069         public static final String CONTACT_ID = "contact_id";
5070         /**
5071          * The phone number as the user entered it.
5072          * <P>Type: TEXT</P>
5073          */
5074         public static final String NUMBER = "number";
5075 
5076         /**
5077          * The type of phone number, for example Home or Work.
5078          * <P>Type: INTEGER</P>
5079          */
5080         public static final String TYPE = "type";
5081 
5082         /**
5083          * The user defined label for the phone number.
5084          * <P>Type: TEXT</P>
5085          */
5086         public static final String LABEL = "label";
5087 
5088         /**
5089          * The phone number's E164 representation.
5090          * <P>Type: TEXT</P>
5091          */
5092         public static final String NORMALIZED_NUMBER = "normalized_number";
5093     }
5094 
5095     /**
5096      * A table that represents the result of looking up a phone number, for
5097      * example for caller ID. To perform a lookup you must append the number you
5098      * want to find to {@link #CONTENT_FILTER_URI}.  This query is highly
5099      * optimized.
5100      * <pre>
5101      * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
5102      * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
5103      * </pre>
5104      *
5105      * <h3>Columns</h3>
5106      *
5107      * <table class="jd-sumtable">
5108      * <tr>
5109      * <th colspan='4'>PhoneLookup</th>
5110      * </tr>
5111      * <tr>
5112      * <td>String</td>
5113      * <td>{@link #NUMBER}</td>
5114      * <td>read-only</td>
5115      * <td>Phone number.</td>
5116      * </tr>
5117      * <tr>
5118      * <td>String</td>
5119      * <td>{@link #TYPE}</td>
5120      * <td>read-only</td>
5121      * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
5122      * </tr>
5123      * <tr>
5124      * <td>String</td>
5125      * <td>{@link #LABEL}</td>
5126      * <td>read-only</td>
5127      * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
5128      * </tr>
5129      * </table>
5130      * <p>
5131      * Columns from the Contacts table are also available through a join.
5132      * </p>
5133      * <table class="jd-sumtable">
5134      * <tr>
5135      * <th colspan='4'>Join with {@link Contacts}</th>
5136      * </tr>
5137      * <tr>
5138      * <td>long</td>
5139      * <td>{@link #_ID}</td>
5140      * <td>read-only</td>
5141      * <td>Contact ID.</td>
5142      * </tr>
5143      * <tr>
5144      * <td>long</td>
5145      * <td>{@link #CONTACT_ID}</td>
5146      * <td>read-only</td>
5147      * <td>Contact ID.</td>
5148      * </tr>
5149      * <tr>
5150      * <td>long</td>
5151      * <td>{@link #DATA_ID}</td>
5152      * <td>read-only</td>
5153      * <td>Data ID.</td>
5154      * </tr>
5155      * <tr>
5156      * <td>String</td>
5157      * <td>{@link #LOOKUP_KEY}</td>
5158      * <td>read-only</td>
5159      * <td>See {@link ContactsContract.Contacts}</td>
5160      * </tr>
5161      * <tr>
5162      * <td>String</td>
5163      * <td>{@link #DISPLAY_NAME}</td>
5164      * <td>read-only</td>
5165      * <td>See {@link ContactsContract.Contacts}</td>
5166      * </tr>
5167      * <tr>
5168      * <td>long</td>
5169      * <td>{@link #PHOTO_ID}</td>
5170      * <td>read-only</td>
5171      * <td>See {@link ContactsContract.Contacts}.</td>
5172      * </tr>
5173      * <tr>
5174      * <td>int</td>
5175      * <td>{@link #IN_VISIBLE_GROUP}</td>
5176      * <td>read-only</td>
5177      * <td>See {@link ContactsContract.Contacts}.</td>
5178      * </tr>
5179      * <tr>
5180      * <td>int</td>
5181      * <td>{@link #HAS_PHONE_NUMBER}</td>
5182      * <td>read-only</td>
5183      * <td>See {@link ContactsContract.Contacts}.</td>
5184      * </tr>
5185      * <tr>
5186      * <td>int</td>
5187      * <td>{@link #TIMES_CONTACTED}</td>
5188      * <td>read-only</td>
5189      * <td>See {@link ContactsContract.Contacts}.</td>
5190      * </tr>
5191      * <tr>
5192      * <td>long</td>
5193      * <td>{@link #LAST_TIME_CONTACTED}</td>
5194      * <td>read-only</td>
5195      * <td>See {@link ContactsContract.Contacts}.</td>
5196      * </tr>
5197      * <tr>
5198      * <td>int</td>
5199      * <td>{@link #STARRED}</td>
5200      * <td>read-only</td>
5201      * <td>See {@link ContactsContract.Contacts}.</td>
5202      * </tr>
5203      * <tr>
5204      * <td>String</td>
5205      * <td>{@link #CUSTOM_RINGTONE}</td>
5206      * <td>read-only</td>
5207      * <td>See {@link ContactsContract.Contacts}.</td>
5208      * </tr>
5209      * <tr>
5210      * <td>int</td>
5211      * <td>{@link #SEND_TO_VOICEMAIL}</td>
5212      * <td>read-only</td>
5213      * <td>See {@link ContactsContract.Contacts}.</td>
5214      * </tr>
5215      * </table>
5216      */
5217     public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
5218             ContactsColumns, ContactOptionsColumns, ContactNameColumns {
5219         /**
5220          * This utility class cannot be instantiated
5221          */
PhoneLookup()5222         private PhoneLookup() {}
5223 
5224         /**
5225          * The content:// style URI for this table. Append the phone number you want to lookup
5226          * to this URI and query it to perform a lookup. For example:
5227          * <pre>
5228          * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
5229          *         Uri.encode(phoneNumber));
5230          * </pre>
5231          */
5232         public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5233                 "phone_lookup");
5234 
5235         /**
5236          * <p>URI used for the "enterprise caller-id".</p>
5237          *
5238          * <p>
5239          * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same
5240          * columns.  If the device has no corp profile that is linked to the current profile, it
5241          * behaves in the exact same way as {@link #CONTENT_FILTER_URI}.  If there is a corp profile
5242          * linked to the current profile, it first queries against the personal contact database,
5243          * and if no matching contacts are found there, then queries against the
5244          * corp contacts database.
5245          * </p>
5246          * <p>
5247          * If a result is from the corp profile, it makes the following changes to the data:
5248          * <ul>
5249          *     <li>
5250          *     {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
5251          *     URIs.  Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
5252          *     load pictures from them.
5253          *     {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null.  Do not use them.
5254          *     </li>
5255          *     <li>
5256          *     Corp contacts will get artificial {@link #_ID}s.  In order to tell whether a contact
5257          *     is from the corp profile, use
5258          *     {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
5259          *     </li>
5260          *     <li>
5261          *     Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
5262          *     </li>
5263          *     <li>
5264          *     Returned work contact IDs and lookup keys are not accepted in places that not
5265          *     explicitly say to accept them.
5266          *     </li>
5267          * </ul>
5268          * <p>
5269          * A contact lookup URL built by
5270          * {@link ContactsContract.Contacts#getLookupUri(long, String)}
5271          * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
5272          * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
5273          * corp profile.
5274          * </p>
5275          *
5276          * <pre>
5277          * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
5278          *         Uri.encode(phoneNumber));
5279          * </pre>
5280          */
5281         public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5282                 "phone_lookup_enterprise");
5283 
5284         /**
5285          * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows.
5286          *
5287          * @hide
5288          */
5289         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup";
5290 
5291         /**
5292          * If this boolean parameter is set to true, then the appended query is treated as a
5293          * SIP address and the lookup will be performed against SIP addresses in the user's
5294          * contacts.
5295          */
5296         public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip";
5297     }
5298 
5299     /**
5300      * Additional data mixed in with {@link StatusColumns} to link
5301      * back to specific {@link ContactsContract.Data#_ID} entries.
5302      *
5303      * @see StatusUpdates
5304      */
5305     protected interface PresenceColumns {
5306 
5307         /**
5308          * Reference to the {@link Data#_ID} entry that owns this presence.
5309          * <P>Type: INTEGER</P>
5310          */
5311         public static final String DATA_ID = "presence_data_id";
5312 
5313         /**
5314          * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
5315          * <p>Type: NUMBER</p>
5316          */
5317         public static final String PROTOCOL = "protocol";
5318 
5319         /**
5320          * Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
5321          * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
5322          * omitted if {@link #PROTOCOL} value is not
5323          * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
5324          *
5325          * <p>Type: NUMBER</p>
5326          */
5327         public static final String CUSTOM_PROTOCOL = "custom_protocol";
5328 
5329         /**
5330          * The IM handle the presence item is for. The handle is scoped to
5331          * {@link #PROTOCOL}.
5332          * <P>Type: TEXT</P>
5333          */
5334         public static final String IM_HANDLE = "im_handle";
5335 
5336         /**
5337          * The IM account for the local user that the presence data came from.
5338          * <P>Type: TEXT</P>
5339          */
5340         public static final String IM_ACCOUNT = "im_account";
5341     }
5342 
5343     /**
5344      * <p>
5345      * A status update is linked to a {@link ContactsContract.Data} row and captures
5346      * the user's latest status update via the corresponding source, e.g.
5347      * "Having lunch" via "Google Talk".
5348      * </p>
5349      * <p>
5350      * There are two ways a status update can be inserted: by explicitly linking
5351      * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
5352      * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5353      * {@link #IM_HANDLE}.  There is no difference between insert and update, you can use
5354      * either.
5355      * </p>
5356      * <p>
5357      * Inserting or updating a status update for the user's profile requires either using
5358      * the {@link #DATA_ID} to identify the data row to attach the update to, or
5359      * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the
5360      * profile.
5361      * </p>
5362      * <p>
5363      * You cannot use {@link ContentResolver#update} to change a status, but
5364      * {@link ContentResolver#insert} will replace the latests status if it already
5365      * exists.
5366      * </p>
5367      * <p>
5368      * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
5369      * for multiple contacts at once.
5370      * </p>
5371      *
5372      * <h3>Columns</h3>
5373      * <table class="jd-sumtable">
5374      * <tr>
5375      * <th colspan='4'>StatusUpdates</th>
5376      * </tr>
5377      * <tr>
5378      * <td>long</td>
5379      * <td>{@link #DATA_ID}</td>
5380      * <td>read/write</td>
5381      * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
5382      * field is <i>not</i> specified, the provider will attempt to find a data row
5383      * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5384      * {@link #IM_HANDLE} columns.
5385      * </td>
5386      * </tr>
5387      * <tr>
5388      * <td>long</td>
5389      * <td>{@link #PROTOCOL}</td>
5390      * <td>read/write</td>
5391      * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
5392      * </tr>
5393      * <tr>
5394      * <td>String</td>
5395      * <td>{@link #CUSTOM_PROTOCOL}</td>
5396      * <td>read/write</td>
5397      * <td>Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
5398      * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
5399      * omitted if {@link #PROTOCOL} value is not
5400      * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
5401      * </tr>
5402      * <tr>
5403      * <td>String</td>
5404      * <td>{@link #IM_HANDLE}</td>
5405      * <td>read/write</td>
5406      * <td> The IM handle the presence item is for. The handle is scoped to
5407      * {@link #PROTOCOL}.</td>
5408      * </tr>
5409      * <tr>
5410      * <td>String</td>
5411      * <td>{@link #IM_ACCOUNT}</td>
5412      * <td>read/write</td>
5413      * <td>The IM account for the local user that the presence data came from.</td>
5414      * </tr>
5415      * <tr>
5416      * <td>int</td>
5417      * <td>{@link #PRESENCE}</td>
5418      * <td>read/write</td>
5419      * <td>Contact IM presence status. The allowed values are:
5420      * <p>
5421      * <ul>
5422      * <li>{@link #OFFLINE}</li>
5423      * <li>{@link #INVISIBLE}</li>
5424      * <li>{@link #AWAY}</li>
5425      * <li>{@link #IDLE}</li>
5426      * <li>{@link #DO_NOT_DISTURB}</li>
5427      * <li>{@link #AVAILABLE}</li>
5428      * </ul>
5429      * </p>
5430      * <p>
5431      * Since presence status is inherently volatile, the content provider
5432      * may choose not to store this field in long-term storage.
5433      * </p>
5434      * </td>
5435      * </tr>
5436      * <tr>
5437      * <td>int</td>
5438      * <td>{@link #CHAT_CAPABILITY}</td>
5439      * <td>read/write</td>
5440      * <td>Contact IM chat compatibility value. The allowed values combinations of the following
5441      * flags. If None of these flags is set, the device can only do text messaging.
5442      * <p>
5443      * <ul>
5444      * <li>{@link #CAPABILITY_HAS_VIDEO}</li>
5445      * <li>{@link #CAPABILITY_HAS_VOICE}</li>
5446      * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
5447      * </ul>
5448      * </p>
5449      * <p>
5450      * Since chat compatibility is inherently volatile as the contact's availability moves from
5451      * one device to another, the content provider may choose not to store this field in long-term
5452      * storage.
5453      * </p>
5454      * </td>
5455      * </tr>
5456      * <tr>
5457      * <td>String</td>
5458      * <td>{@link #STATUS}</td>
5459      * <td>read/write</td>
5460      * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
5461      * </tr>
5462      * <tr>
5463      * <td>long</td>
5464      * <td>{@link #STATUS_TIMESTAMP}</td>
5465      * <td>read/write</td>
5466      * <td>The absolute time in milliseconds when the status was
5467      * entered by the user. If this value is not provided, the provider will follow
5468      * this logic: if there was no prior status update, the value will be left as null.
5469      * If there was a prior status update, the provider will default this field
5470      * to the current time.</td>
5471      * </tr>
5472      * <tr>
5473      * <td>String</td>
5474      * <td>{@link #STATUS_RES_PACKAGE}</td>
5475      * <td>read/write</td>
5476      * <td> The package containing resources for this status: label and icon.</td>
5477      * </tr>
5478      * <tr>
5479      * <td>long</td>
5480      * <td>{@link #STATUS_LABEL}</td>
5481      * <td>read/write</td>
5482      * <td>The resource ID of the label describing the source of contact status,
5483      * e.g. "Google Talk". This resource is scoped by the
5484      * {@link #STATUS_RES_PACKAGE}.</td>
5485      * </tr>
5486      * <tr>
5487      * <td>long</td>
5488      * <td>{@link #STATUS_ICON}</td>
5489      * <td>read/write</td>
5490      * <td>The resource ID of the icon for the source of contact status. This
5491      * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
5492      * </tr>
5493      * </table>
5494      */
5495     public static class StatusUpdates implements StatusColumns, PresenceColumns {
5496 
5497         /**
5498          * This utility class cannot be instantiated
5499          */
StatusUpdates()5500         private StatusUpdates() {}
5501 
5502         /**
5503          * The content:// style URI for this table
5504          */
5505         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
5506 
5507         /**
5508          * The content:// style URI for this table, specific to the user's profile.
5509          */
5510         public static final Uri PROFILE_CONTENT_URI =
5511                 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates");
5512 
5513         /**
5514          * Gets the resource ID for the proper presence icon.
5515          *
5516          * @param status the status to get the icon for
5517          * @return the resource ID for the proper presence icon
5518          */
getPresenceIconResourceId(int status)5519         public static final int getPresenceIconResourceId(int status) {
5520             switch (status) {
5521                 case AVAILABLE:
5522                     return android.R.drawable.presence_online;
5523                 case IDLE:
5524                 case AWAY:
5525                     return android.R.drawable.presence_away;
5526                 case DO_NOT_DISTURB:
5527                     return android.R.drawable.presence_busy;
5528                 case INVISIBLE:
5529                     return android.R.drawable.presence_invisible;
5530                 case OFFLINE:
5531                 default:
5532                     return android.R.drawable.presence_offline;
5533             }
5534         }
5535 
5536         /**
5537          * Returns the precedence of the status code the higher number being the higher precedence.
5538          *
5539          * @param status The status code.
5540          * @return An integer representing the precedence, 0 being the lowest.
5541          */
getPresencePrecedence(int status)5542         public static final int getPresencePrecedence(int status) {
5543             // Keep this function here incase we want to enforce a different precedence than the
5544             // natural order of the status constants.
5545             return status;
5546         }
5547 
5548         /**
5549          * The MIME type of {@link #CONTENT_URI} providing a directory of
5550          * status update details.
5551          */
5552         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
5553 
5554         /**
5555          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
5556          * status update detail.
5557          */
5558         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
5559     }
5560 
5561     /**
5562      * @deprecated This old name was never meant to be made public. Do not use.
5563      */
5564     @Deprecated
5565     public static final class Presence extends StatusUpdates {
5566 
5567     }
5568 
5569     /**
5570      * Additional column returned by
5571      * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining
5572      * why the filter matched the contact. This column will contain extracts from the contact's
5573      * constituent {@link Data Data} items, formatted in a way that indicates the section of the
5574      * snippet that matched the filter.
5575      *
5576      * <p>
5577      * The following example searches for all contacts that match the query "presi" and requests
5578      * the snippet column as well.
5579      * <pre>
5580      * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
5581      * builder.appendPath("presi");
5582      * // Defer snippeting to the client side if possible, for performance reasons.
5583      * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");
5584      *
5585      * Cursor cursor = getContentResolver().query(builder.build());
5586      *
5587      * Bundle extras = cursor.getExtras();
5588      * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
5589      *     // Do our own snippet formatting.
5590      *     // For a contact with the email address (president@organization.com), the snippet
5591      *     // column will contain the string "president@organization.com".
5592      * } else {
5593      *     // The snippet has already been pre-formatted, we can display it as is.
5594      *     // For a contact with the email address (president@organization.com), the snippet
5595      *     // column will contain the string "[presi]dent@organization.com".
5596      * }
5597      * </pre>
5598      * </p>
5599      */
5600     public static class SearchSnippets {
5601 
5602         /**
5603          * The search snippet constructed by SQLite snippeting functionality.
5604          * <p>
5605          * The snippet may contain (parts of) several data elements belonging to the contact,
5606          * with the matching parts optionally surrounded by special characters that indicate the
5607          * start and end of matching text.
5608          *
5609          * For example, if a contact has an address "123 Main Street", using a filter "mai" would
5610          * return the formatted snippet "123 [Mai]n street".
5611          *
5612          * @see <a href="http://www.sqlite.org/fts3.html#snippet">
5613          *         http://www.sqlite.org/fts3.html#snippet</a>
5614          */
5615         public static final String SNIPPET = "snippet";
5616 
5617         /**
5618          * Comma-separated parameters for the generation of the snippet:
5619          * <ul>
5620          * <li>The "start match" text. Default is '['</li>
5621          * <li>The "end match" text. Default is ']'</li>
5622          * <li>The "ellipsis" text. Default is "..."</li>
5623          * <li>Maximum number of tokens to include in the snippet. Can be either
5624          * a positive or a negative number: A positive number indicates how many
5625          * tokens can be returned in total. A negative number indicates how many
5626          * tokens can be returned per occurrence of the search terms.</li>
5627          * </ul>
5628          *
5629          * @hide
5630          */
5631         public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args";
5632 
5633         /**
5634          * The key to ask the provider to defer the formatting of the snippet to the client if
5635          * possible, for performance reasons.
5636          * A value of 1 indicates true, 0 indicates false. False is the default.
5637          * When a cursor is returned to the client, it should check for an extra with the name
5638          * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client
5639          * should do its own formatting of the snippet. If it doesn't exist, the snippet column
5640          * in the cursor should already contain a formatted snippet.
5641          */
5642         public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting";
5643     }
5644 
5645     /**
5646      * Container for definitions of common data types stored in the {@link ContactsContract.Data}
5647      * table.
5648      */
5649     public static final class CommonDataKinds {
5650         /**
5651          * This utility class cannot be instantiated
5652          */
CommonDataKinds()5653         private CommonDataKinds() {}
5654 
5655         /**
5656          * The {@link Data#RES_PACKAGE} value for common data that should be
5657          * shown using a default style.
5658          *
5659          * @hide RES_PACKAGE is hidden
5660          */
5661         public static final String PACKAGE_COMMON = "common";
5662 
5663         /**
5664          * The base types that all "Typed" data kinds support.
5665          */
5666         public interface BaseTypes {
5667             /**
5668              * A custom type. The custom label should be supplied by user.
5669              */
5670             public static int TYPE_CUSTOM = 0;
5671         }
5672 
5673         /**
5674          * Columns common across the specific types.
5675          */
5676         protected interface CommonColumns extends BaseTypes {
5677             /**
5678              * The data for the contact method.
5679              * <P>Type: TEXT</P>
5680              */
5681             public static final String DATA = DataColumns.DATA1;
5682 
5683             /**
5684              * The type of data, for example Home or Work.
5685              * <P>Type: INTEGER</P>
5686              */
5687             public static final String TYPE = DataColumns.DATA2;
5688 
5689             /**
5690              * The user defined label for the the contact method.
5691              * <P>Type: TEXT</P>
5692              */
5693             public static final String LABEL = DataColumns.DATA3;
5694         }
5695 
5696         /**
5697          * A data kind representing the contact's proper name. You can use all
5698          * columns defined for {@link ContactsContract.Data} as well as the following aliases.
5699          *
5700          * <h2>Column aliases</h2>
5701          * <table class="jd-sumtable">
5702          * <tr>
5703          * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5704          * </tr>
5705          * <tr>
5706          * <td>String</td>
5707          * <td>{@link #DISPLAY_NAME}</td>
5708          * <td>{@link #DATA1}</td>
5709          * <td></td>
5710          * </tr>
5711          * <tr>
5712          * <td>String</td>
5713          * <td>{@link #GIVEN_NAME}</td>
5714          * <td>{@link #DATA2}</td>
5715          * <td></td>
5716          * </tr>
5717          * <tr>
5718          * <td>String</td>
5719          * <td>{@link #FAMILY_NAME}</td>
5720          * <td>{@link #DATA3}</td>
5721          * <td></td>
5722          * </tr>
5723          * <tr>
5724          * <td>String</td>
5725          * <td>{@link #PREFIX}</td>
5726          * <td>{@link #DATA4}</td>
5727          * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
5728          * </tr>
5729          * <tr>
5730          * <td>String</td>
5731          * <td>{@link #MIDDLE_NAME}</td>
5732          * <td>{@link #DATA5}</td>
5733          * <td></td>
5734          * </tr>
5735          * <tr>
5736          * <td>String</td>
5737          * <td>{@link #SUFFIX}</td>
5738          * <td>{@link #DATA6}</td>
5739          * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
5740          * </tr>
5741          * <tr>
5742          * <td>String</td>
5743          * <td>{@link #PHONETIC_GIVEN_NAME}</td>
5744          * <td>{@link #DATA7}</td>
5745          * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
5746          * </tr>
5747          * <tr>
5748          * <td>String</td>
5749          * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
5750          * <td>{@link #DATA8}</td>
5751          * <td></td>
5752          * </tr>
5753          * <tr>
5754          * <td>String</td>
5755          * <td>{@link #PHONETIC_FAMILY_NAME}</td>
5756          * <td>{@link #DATA9}</td>
5757          * <td></td>
5758          * </tr>
5759          * </table>
5760          */
5761         public static final class StructuredName implements DataColumnsWithJoins, ContactCounts {
5762             /**
5763              * This utility class cannot be instantiated
5764              */
StructuredName()5765             private StructuredName() {}
5766 
5767             /** MIME type used when storing this in data table. */
5768             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
5769 
5770             /**
5771              * The name that should be used to display the contact.
5772              * <i>Unstructured component of the name should be consistent with
5773              * its structured representation.</i>
5774              * <p>
5775              * Type: TEXT
5776              */
5777             public static final String DISPLAY_NAME = DATA1;
5778 
5779             /**
5780              * The given name for the contact.
5781              * <P>Type: TEXT</P>
5782              */
5783             public static final String GIVEN_NAME = DATA2;
5784 
5785             /**
5786              * The family name for the contact.
5787              * <P>Type: TEXT</P>
5788              */
5789             public static final String FAMILY_NAME = DATA3;
5790 
5791             /**
5792              * The contact's honorific prefix, e.g. "Sir"
5793              * <P>Type: TEXT</P>
5794              */
5795             public static final String PREFIX = DATA4;
5796 
5797             /**
5798              * The contact's middle name
5799              * <P>Type: TEXT</P>
5800              */
5801             public static final String MIDDLE_NAME = DATA5;
5802 
5803             /**
5804              * The contact's honorific suffix, e.g. "Jr"
5805              */
5806             public static final String SUFFIX = DATA6;
5807 
5808             /**
5809              * The phonetic version of the given name for the contact.
5810              * <P>Type: TEXT</P>
5811              */
5812             public static final String PHONETIC_GIVEN_NAME = DATA7;
5813 
5814             /**
5815              * The phonetic version of the additional name for the contact.
5816              * <P>Type: TEXT</P>
5817              */
5818             public static final String PHONETIC_MIDDLE_NAME = DATA8;
5819 
5820             /**
5821              * The phonetic version of the family name for the contact.
5822              * <P>Type: TEXT</P>
5823              */
5824             public static final String PHONETIC_FAMILY_NAME = DATA9;
5825 
5826             /**
5827              * The style used for combining given/middle/family name into a full name.
5828              * See {@link ContactsContract.FullNameStyle}.
5829              */
5830             public static final String FULL_NAME_STYLE = DATA10;
5831 
5832             /**
5833              * The alphabet used for capturing the phonetic name.
5834              * See ContactsContract.PhoneticNameStyle.
5835              */
5836             public static final String PHONETIC_NAME_STYLE = DATA11;
5837         }
5838 
5839         /**
5840          * <p>A data kind representing the contact's nickname. For example, for
5841          * Bob Parr ("Mr. Incredible"):
5842          * <pre>
5843          * ArrayList&lt;ContentProviderOperation&gt; ops =
5844          *          new ArrayList&lt;ContentProviderOperation&gt;();
5845          *
5846          * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5847          *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
5848          *          .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
5849          *          .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
5850          *          .build());
5851          *
5852          * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5853          *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
5854          *          .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
5855          *          .withValue(Nickname.NAME, "Mr. Incredible")
5856          *          .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
5857          *          .withValue(Nickname.LABEL, "Superhero")
5858          *          .build());
5859          *
5860          * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
5861          * </pre>
5862          * </p>
5863          * <p>
5864          * You can use all columns defined for {@link ContactsContract.Data} as well as the
5865          * following aliases.
5866          * </p>
5867          *
5868          * <h2>Column aliases</h2>
5869          * <table class="jd-sumtable">
5870          * <tr>
5871          * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5872          * </tr>
5873          * <tr>
5874          * <td>String</td>
5875          * <td>{@link #NAME}</td>
5876          * <td>{@link #DATA1}</td>
5877          * <td></td>
5878          * </tr>
5879          * <tr>
5880          * <td>int</td>
5881          * <td>{@link #TYPE}</td>
5882          * <td>{@link #DATA2}</td>
5883          * <td>
5884          * Allowed values are:
5885          * <p>
5886          * <ul>
5887          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5888          * <li>{@link #TYPE_DEFAULT}</li>
5889          * <li>{@link #TYPE_OTHER_NAME}</li>
5890          * <li>{@link #TYPE_MAIDEN_NAME}</li>
5891          * <li>{@link #TYPE_SHORT_NAME}</li>
5892          * <li>{@link #TYPE_INITIALS}</li>
5893          * </ul>
5894          * </p>
5895          * </td>
5896          * </tr>
5897          * <tr>
5898          * <td>String</td>
5899          * <td>{@link #LABEL}</td>
5900          * <td>{@link #DATA3}</td>
5901          * <td></td>
5902          * </tr>
5903          * </table>
5904          */
5905         public static final class Nickname implements DataColumnsWithJoins, CommonColumns,
5906                 ContactCounts{
5907             /**
5908              * This utility class cannot be instantiated
5909              */
Nickname()5910             private Nickname() {}
5911 
5912             /** MIME type used when storing this in data table. */
5913             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
5914 
5915             public static final int TYPE_DEFAULT = 1;
5916             public static final int TYPE_OTHER_NAME = 2;
5917             public static final int TYPE_MAIDEN_NAME = 3;
5918             /** @deprecated Use TYPE_MAIDEN_NAME instead. */
5919             @Deprecated
5920             public static final int TYPE_MAINDEN_NAME = 3;
5921             public static final int TYPE_SHORT_NAME = 4;
5922             public static final int TYPE_INITIALS = 5;
5923 
5924             /**
5925              * The name itself
5926              */
5927             public static final String NAME = DATA;
5928         }
5929 
5930         /**
5931          * <p>
5932          * A data kind representing a telephone number.
5933          * </p>
5934          * <p>
5935          * You can use all columns defined for {@link ContactsContract.Data} as
5936          * well as the following aliases.
5937          * </p>
5938          * <h2>Column aliases</h2>
5939          * <table class="jd-sumtable">
5940          * <tr>
5941          * <th>Type</th>
5942          * <th>Alias</th><th colspan='2'>Data column</th>
5943          * </tr>
5944          * <tr>
5945          * <td>String</td>
5946          * <td>{@link #NUMBER}</td>
5947          * <td>{@link #DATA1}</td>
5948          * <td></td>
5949          * </tr>
5950          * <tr>
5951          * <td>int</td>
5952          * <td>{@link #TYPE}</td>
5953          * <td>{@link #DATA2}</td>
5954          * <td>Allowed values are:
5955          * <p>
5956          * <ul>
5957          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5958          * <li>{@link #TYPE_HOME}</li>
5959          * <li>{@link #TYPE_MOBILE}</li>
5960          * <li>{@link #TYPE_WORK}</li>
5961          * <li>{@link #TYPE_FAX_WORK}</li>
5962          * <li>{@link #TYPE_FAX_HOME}</li>
5963          * <li>{@link #TYPE_PAGER}</li>
5964          * <li>{@link #TYPE_OTHER}</li>
5965          * <li>{@link #TYPE_CALLBACK}</li>
5966          * <li>{@link #TYPE_CAR}</li>
5967          * <li>{@link #TYPE_COMPANY_MAIN}</li>
5968          * <li>{@link #TYPE_ISDN}</li>
5969          * <li>{@link #TYPE_MAIN}</li>
5970          * <li>{@link #TYPE_OTHER_FAX}</li>
5971          * <li>{@link #TYPE_RADIO}</li>
5972          * <li>{@link #TYPE_TELEX}</li>
5973          * <li>{@link #TYPE_TTY_TDD}</li>
5974          * <li>{@link #TYPE_WORK_MOBILE}</li>
5975          * <li>{@link #TYPE_WORK_PAGER}</li>
5976          * <li>{@link #TYPE_ASSISTANT}</li>
5977          * <li>{@link #TYPE_MMS}</li>
5978          * </ul>
5979          * </p>
5980          * </td>
5981          * </tr>
5982          * <tr>
5983          * <td>String</td>
5984          * <td>{@link #LABEL}</td>
5985          * <td>{@link #DATA3}</td>
5986          * <td></td>
5987          * </tr>
5988          * </table>
5989          */
5990         public static final class Phone implements DataColumnsWithJoins, CommonColumns,
5991                 ContactCounts {
5992             /**
5993              * This utility class cannot be instantiated
5994              */
Phone()5995             private Phone() {}
5996 
5997             /** MIME type used when storing this in data table. */
5998             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
5999 
6000             /**
6001              * The MIME type of {@link #CONTENT_URI} providing a directory of
6002              * phones.
6003              */
6004             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
6005 
6006             /**
6007              * The content:// style URI for all data records of the
6008              * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
6009              * associated raw contact and aggregate contact data.
6010              */
6011             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6012                     "phones");
6013 
6014             /**
6015             * URI used for getting all contacts from primary and managed profile.
6016             *
6017             * It supports the same semantics as {@link #CONTENT_URI} and returns the same
6018             * columns.  If the device has no corp profile that is linked to the current profile, it
6019             * behaves in the exact same way as {@link #CONTENT_URI}.  If there is a corp profile
6020             * linked to the current profile, it will merge corp profile and current profile's
6021             * results and return
6022             *
6023             * @hide
6024             */
6025             public static final Uri ENTERPRISE_CONTENT_URI =
6026                     Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones");
6027 
6028             /**
6029              * The content:// style URL for phone lookup using a filter. The filter returns
6030              * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
6031              * to display names as well as phone numbers. The filter argument should be passed
6032              * as an additional path segment after this URI.
6033              */
6034             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
6035                     "filter");
6036 
6037             /**
6038              * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
6039              * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
6040              * parameters, otherwise it will throw IllegalArgumentException.
6041              */
6042             public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
6043                     CONTENT_URI, "filter_enterprise");
6044 
6045             /**
6046              * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
6047              * If "1" or "true", display names are searched.  If "0" or "false", display names
6048              * are not searched.  Default is "1".
6049              */
6050             public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name";
6051 
6052             /**
6053              * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
6054              * If "1" or "true", phone numbers are searched.  If "0" or "false", phone numbers
6055              * are not searched.  Default is "1".
6056              */
6057             public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number";
6058 
6059             public static final int TYPE_HOME = 1;
6060             public static final int TYPE_MOBILE = 2;
6061             public static final int TYPE_WORK = 3;
6062             public static final int TYPE_FAX_WORK = 4;
6063             public static final int TYPE_FAX_HOME = 5;
6064             public static final int TYPE_PAGER = 6;
6065             public static final int TYPE_OTHER = 7;
6066             public static final int TYPE_CALLBACK = 8;
6067             public static final int TYPE_CAR = 9;
6068             public static final int TYPE_COMPANY_MAIN = 10;
6069             public static final int TYPE_ISDN = 11;
6070             public static final int TYPE_MAIN = 12;
6071             public static final int TYPE_OTHER_FAX = 13;
6072             public static final int TYPE_RADIO = 14;
6073             public static final int TYPE_TELEX = 15;
6074             public static final int TYPE_TTY_TDD = 16;
6075             public static final int TYPE_WORK_MOBILE = 17;
6076             public static final int TYPE_WORK_PAGER = 18;
6077             public static final int TYPE_ASSISTANT = 19;
6078             public static final int TYPE_MMS = 20;
6079 
6080             /**
6081              * The phone number as the user entered it.
6082              * <P>Type: TEXT</P>
6083              */
6084             public static final String NUMBER = DATA;
6085 
6086             /**
6087              * The phone number's E164 representation. This value can be omitted in which
6088              * case the provider will try to automatically infer it.  (It'll be left null if the
6089              * provider fails to infer.)
6090              * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise).
6091              * <P>Type: TEXT</P>
6092              */
6093             public static final String NORMALIZED_NUMBER = DATA4;
6094 
6095             /**
6096              * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
6097              * @hide
6098              */
6099             @Deprecated
getDisplayLabel(Context context, int type, CharSequence label, CharSequence[] labelArray)6100             public static final CharSequence getDisplayLabel(Context context, int type,
6101                     CharSequence label, CharSequence[] labelArray) {
6102                 return getTypeLabel(context.getResources(), type, label);
6103             }
6104 
6105             /**
6106              * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
6107              * @hide
6108              */
6109             @Deprecated
getDisplayLabel(Context context, int type, CharSequence label)6110             public static final CharSequence getDisplayLabel(Context context, int type,
6111                     CharSequence label) {
6112                 return getTypeLabel(context.getResources(), type, label);
6113             }
6114 
6115             /**
6116              * Return the string resource that best describes the given
6117              * {@link #TYPE}. Will always return a valid resource.
6118              */
getTypeLabelResource(int type)6119             public static final int getTypeLabelResource(int type) {
6120                 switch (type) {
6121                     case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
6122                     case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
6123                     case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
6124                     case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
6125                     case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
6126                     case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
6127                     case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
6128                     case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
6129                     case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
6130                     case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
6131                     case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
6132                     case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
6133                     case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
6134                     case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
6135                     case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
6136                     case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
6137                     case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
6138                     case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
6139                     case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
6140                     case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
6141                     default: return com.android.internal.R.string.phoneTypeCustom;
6142                 }
6143             }
6144 
6145             /**
6146              * Return a {@link CharSequence} that best describes the given type,
6147              * possibly substituting the given {@link #LABEL} value
6148              * for {@link #TYPE_CUSTOM}.
6149              */
getTypeLabel(Resources res, int type, CharSequence label)6150             public static final CharSequence getTypeLabel(Resources res, int type,
6151                     CharSequence label) {
6152                 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
6153                     return label;
6154                 } else {
6155                     final int labelRes = getTypeLabelResource(type);
6156                     return res.getText(labelRes);
6157                 }
6158             }
6159         }
6160 
6161         /**
6162          * <p>
6163          * A data kind representing an email address.
6164          * </p>
6165          * <p>
6166          * You can use all columns defined for {@link ContactsContract.Data} as
6167          * well as the following aliases.
6168          * </p>
6169          * <h2>Column aliases</h2>
6170          * <table class="jd-sumtable">
6171          * <tr>
6172          * <th>Type</th>
6173          * <th>Alias</th><th colspan='2'>Data column</th>
6174          * </tr>
6175          * <tr>
6176          * <td>String</td>
6177          * <td>{@link #ADDRESS}</td>
6178          * <td>{@link #DATA1}</td>
6179          * <td>Email address itself.</td>
6180          * </tr>
6181          * <tr>
6182          * <td>int</td>
6183          * <td>{@link #TYPE}</td>
6184          * <td>{@link #DATA2}</td>
6185          * <td>Allowed values are:
6186          * <p>
6187          * <ul>
6188          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6189          * <li>{@link #TYPE_HOME}</li>
6190          * <li>{@link #TYPE_WORK}</li>
6191          * <li>{@link #TYPE_OTHER}</li>
6192          * <li>{@link #TYPE_MOBILE}</li>
6193          * </ul>
6194          * </p>
6195          * </td>
6196          * </tr>
6197          * <tr>
6198          * <td>String</td>
6199          * <td>{@link #LABEL}</td>
6200          * <td>{@link #DATA3}</td>
6201          * <td></td>
6202          * </tr>
6203          * </table>
6204          */
6205         public static final class Email implements DataColumnsWithJoins, CommonColumns,
6206                 ContactCounts {
6207             /**
6208              * This utility class cannot be instantiated
6209              */
Email()6210             private Email() {}
6211 
6212             /** MIME type used when storing this in data table. */
6213             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
6214 
6215             /**
6216              * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
6217              */
6218             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
6219 
6220             /**
6221              * The content:// style URI for all data records of the
6222              * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
6223              * associated raw contact and aggregate contact data.
6224              */
6225             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6226                     "emails");
6227 
6228             /**
6229              * <p>
6230              * The content:// style URL for looking up data rows by email address. The
6231              * lookup argument, an email address, should be passed as an additional path segment
6232              * after this URI.
6233              * </p>
6234              * <p>Example:
6235              * <pre>
6236              * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
6237              * Cursor c = getContentResolver().query(uri,
6238              *          new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
6239              *          null, null, null);
6240              * </pre>
6241              * </p>
6242              */
6243             public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
6244                     "lookup");
6245 
6246             /**
6247             * <p>URI used for enterprise email lookup.</p>
6248             *
6249             * <p>
6250             * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same
6251             * columns.  If the device has no corp profile that is linked to the current profile, it
6252             * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}.  If there is a
6253             * corp profile linked to the current profile, it first queries against the personal contact database,
6254             * and if no matching contacts are found there, then queries against the
6255             * corp contacts database.
6256             * </p>
6257             * <p>
6258             * If a result is from the corp profile, it makes the following changes to the data:
6259             * <ul>
6260             *     <li>
6261             *     {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
6262             *     URIs.  Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
6263             *     load pictures from them.
6264             *     {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null.  Do not
6265             *     use them.
6266             *     </li>
6267             *     <li>
6268             *     Corp contacts will get artificial {@link #CONTACT_ID}s.  In order to tell whether
6269             *     a contact
6270             *     is from the corp profile, use
6271             *     {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
6272              *     </li>
6273              *     <li>
6274              *     Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
6275              *     </li>
6276              *     <li>
6277              *     Returned work contact IDs and lookup keys are not accepted in places that not
6278              *     explicitly say to accept them.
6279              *     </li>
6280              * </ul>
6281              * <p>
6282              * A contact lookup URL built by
6283              * {@link ContactsContract.Contacts#getLookupUri(long, String)}
6284              * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
6285              * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
6286              * corp profile.
6287              * </p>
6288             *
6289             * <pre>
6290             * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI,
6291             *         Uri.encode(email));
6292             * </pre>
6293             */
6294             public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI =
6295                     Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise");
6296 
6297             /**
6298              * <p>
6299              * The content:// style URL for email lookup using a filter. The filter returns
6300              * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
6301              * to display names as well as email addresses. The filter argument should be passed
6302              * as an additional path segment after this URI.
6303              * </p>
6304              * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)"
6305              * as well as "Bob Parr (incredible@android.com)".
6306              * <pre>
6307              * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
6308              * Cursor c = getContentResolver().query(uri,
6309              *          new String[]{Email.DISPLAY_NAME, Email.DATA},
6310              *          null, null, null);
6311              * </pre>
6312              * </p>
6313              */
6314             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
6315                     "filter");
6316 
6317             /**
6318              * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
6319              * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
6320              * parameters, otherwise it will throw IllegalArgumentException.
6321              */
6322             public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
6323                     CONTENT_URI, "filter_enterprise");
6324 
6325             /**
6326              * The email address.
6327              * <P>Type: TEXT</P>
6328              */
6329             public static final String ADDRESS = DATA1;
6330 
6331             public static final int TYPE_HOME = 1;
6332             public static final int TYPE_WORK = 2;
6333             public static final int TYPE_OTHER = 3;
6334             public static final int TYPE_MOBILE = 4;
6335 
6336             /**
6337              * The display name for the email address
6338              * <P>Type: TEXT</P>
6339              */
6340             public static final String DISPLAY_NAME = DATA4;
6341 
6342             /**
6343              * Return the string resource that best describes the given
6344              * {@link #TYPE}. Will always return a valid resource.
6345              */
getTypeLabelResource(int type)6346             public static final int getTypeLabelResource(int type) {
6347                 switch (type) {
6348                     case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
6349                     case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
6350                     case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
6351                     case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
6352                     default: return com.android.internal.R.string.emailTypeCustom;
6353                 }
6354             }
6355 
6356             /**
6357              * Return a {@link CharSequence} that best describes the given type,
6358              * possibly substituting the given {@link #LABEL} value
6359              * for {@link #TYPE_CUSTOM}.
6360              */
getTypeLabel(Resources res, int type, CharSequence label)6361             public static final CharSequence getTypeLabel(Resources res, int type,
6362                     CharSequence label) {
6363                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6364                     return label;
6365                 } else {
6366                     final int labelRes = getTypeLabelResource(type);
6367                     return res.getText(labelRes);
6368                 }
6369             }
6370         }
6371 
6372         /**
6373          * <p>
6374          * A data kind representing a postal addresses.
6375          * </p>
6376          * <p>
6377          * You can use all columns defined for {@link ContactsContract.Data} as
6378          * well as the following aliases.
6379          * </p>
6380          * <h2>Column aliases</h2>
6381          * <table class="jd-sumtable">
6382          * <tr>
6383          * <th>Type</th>
6384          * <th>Alias</th><th colspan='2'>Data column</th>
6385          * </tr>
6386          * <tr>
6387          * <td>String</td>
6388          * <td>{@link #FORMATTED_ADDRESS}</td>
6389          * <td>{@link #DATA1}</td>
6390          * <td></td>
6391          * </tr>
6392          * <tr>
6393          * <td>int</td>
6394          * <td>{@link #TYPE}</td>
6395          * <td>{@link #DATA2}</td>
6396          * <td>Allowed values are:
6397          * <p>
6398          * <ul>
6399          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6400          * <li>{@link #TYPE_HOME}</li>
6401          * <li>{@link #TYPE_WORK}</li>
6402          * <li>{@link #TYPE_OTHER}</li>
6403          * </ul>
6404          * </p>
6405          * </td>
6406          * </tr>
6407          * <tr>
6408          * <td>String</td>
6409          * <td>{@link #LABEL}</td>
6410          * <td>{@link #DATA3}</td>
6411          * <td></td>
6412          * </tr>
6413          * <tr>
6414          * <td>String</td>
6415          * <td>{@link #STREET}</td>
6416          * <td>{@link #DATA4}</td>
6417          * <td></td>
6418          * </tr>
6419          * <tr>
6420          * <td>String</td>
6421          * <td>{@link #POBOX}</td>
6422          * <td>{@link #DATA5}</td>
6423          * <td>Post Office Box number</td>
6424          * </tr>
6425          * <tr>
6426          * <td>String</td>
6427          * <td>{@link #NEIGHBORHOOD}</td>
6428          * <td>{@link #DATA6}</td>
6429          * <td></td>
6430          * </tr>
6431          * <tr>
6432          * <td>String</td>
6433          * <td>{@link #CITY}</td>
6434          * <td>{@link #DATA7}</td>
6435          * <td></td>
6436          * </tr>
6437          * <tr>
6438          * <td>String</td>
6439          * <td>{@link #REGION}</td>
6440          * <td>{@link #DATA8}</td>
6441          * <td></td>
6442          * </tr>
6443          * <tr>
6444          * <td>String</td>
6445          * <td>{@link #POSTCODE}</td>
6446          * <td>{@link #DATA9}</td>
6447          * <td></td>
6448          * </tr>
6449          * <tr>
6450          * <td>String</td>
6451          * <td>{@link #COUNTRY}</td>
6452          * <td>{@link #DATA10}</td>
6453          * <td></td>
6454          * </tr>
6455          * </table>
6456          */
6457         public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns,
6458                 ContactCounts {
6459             /**
6460              * This utility class cannot be instantiated
6461              */
StructuredPostal()6462             private StructuredPostal() {
6463             }
6464 
6465             /** MIME type used when storing this in data table. */
6466             public static final String CONTENT_ITEM_TYPE =
6467                     "vnd.android.cursor.item/postal-address_v2";
6468 
6469             /**
6470              * The MIME type of {@link #CONTENT_URI} providing a directory of
6471              * postal addresses.
6472              */
6473             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
6474 
6475             /**
6476              * The content:// style URI for all data records of the
6477              * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
6478              */
6479             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6480                     "postals");
6481 
6482             public static final int TYPE_HOME = 1;
6483             public static final int TYPE_WORK = 2;
6484             public static final int TYPE_OTHER = 3;
6485 
6486             /**
6487              * The full, unstructured postal address. <i>This field must be
6488              * consistent with any structured data.</i>
6489              * <p>
6490              * Type: TEXT
6491              */
6492             public static final String FORMATTED_ADDRESS = DATA;
6493 
6494             /**
6495              * Can be street, avenue, road, etc. This element also includes the
6496              * house number and room/apartment/flat/floor number.
6497              * <p>
6498              * Type: TEXT
6499              */
6500             public static final String STREET = DATA4;
6501 
6502             /**
6503              * Covers actual P.O. boxes, drawers, locked bags, etc. This is
6504              * usually but not always mutually exclusive with street.
6505              * <p>
6506              * Type: TEXT
6507              */
6508             public static final String POBOX = DATA5;
6509 
6510             /**
6511              * This is used to disambiguate a street address when a city
6512              * contains more than one street with the same name, or to specify a
6513              * small place whose mail is routed through a larger postal town. In
6514              * China it could be a county or a minor city.
6515              * <p>
6516              * Type: TEXT
6517              */
6518             public static final String NEIGHBORHOOD = DATA6;
6519 
6520             /**
6521              * Can be city, village, town, borough, etc. This is the postal town
6522              * and not necessarily the place of residence or place of business.
6523              * <p>
6524              * Type: TEXT
6525              */
6526             public static final String CITY = DATA7;
6527 
6528             /**
6529              * A state, province, county (in Ireland), Land (in Germany),
6530              * departement (in France), etc.
6531              * <p>
6532              * Type: TEXT
6533              */
6534             public static final String REGION = DATA8;
6535 
6536             /**
6537              * Postal code. Usually country-wide, but sometimes specific to the
6538              * city (e.g. "2" in "Dublin 2, Ireland" addresses).
6539              * <p>
6540              * Type: TEXT
6541              */
6542             public static final String POSTCODE = DATA9;
6543 
6544             /**
6545              * The name or code of the country.
6546              * <p>
6547              * Type: TEXT
6548              */
6549             public static final String COUNTRY = DATA10;
6550 
6551             /**
6552              * Return the string resource that best describes the given
6553              * {@link #TYPE}. Will always return a valid resource.
6554              */
getTypeLabelResource(int type)6555             public static final int getTypeLabelResource(int type) {
6556                 switch (type) {
6557                     case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
6558                     case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
6559                     case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
6560                     default: return com.android.internal.R.string.postalTypeCustom;
6561                 }
6562             }
6563 
6564             /**
6565              * Return a {@link CharSequence} that best describes the given type,
6566              * possibly substituting the given {@link #LABEL} value
6567              * for {@link #TYPE_CUSTOM}.
6568              */
getTypeLabel(Resources res, int type, CharSequence label)6569             public static final CharSequence getTypeLabel(Resources res, int type,
6570                     CharSequence label) {
6571                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6572                     return label;
6573                 } else {
6574                     final int labelRes = getTypeLabelResource(type);
6575                     return res.getText(labelRes);
6576                 }
6577             }
6578         }
6579 
6580         /**
6581          * <p>
6582          * A data kind representing an IM address
6583          * </p>
6584          * <p>
6585          * You can use all columns defined for {@link ContactsContract.Data} as
6586          * well as the following aliases.
6587          * </p>
6588          * <h2>Column aliases</h2>
6589          * <table class="jd-sumtable">
6590          * <tr>
6591          * <th>Type</th>
6592          * <th>Alias</th><th colspan='2'>Data column</th>
6593          * </tr>
6594          * <tr>
6595          * <td>String</td>
6596          * <td>{@link #DATA}</td>
6597          * <td>{@link #DATA1}</td>
6598          * <td></td>
6599          * </tr>
6600          * <tr>
6601          * <td>int</td>
6602          * <td>{@link #TYPE}</td>
6603          * <td>{@link #DATA2}</td>
6604          * <td>Allowed values are:
6605          * <p>
6606          * <ul>
6607          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6608          * <li>{@link #TYPE_HOME}</li>
6609          * <li>{@link #TYPE_WORK}</li>
6610          * <li>{@link #TYPE_OTHER}</li>
6611          * </ul>
6612          * </p>
6613          * </td>
6614          * </tr>
6615          * <tr>
6616          * <td>String</td>
6617          * <td>{@link #LABEL}</td>
6618          * <td>{@link #DATA3}</td>
6619          * <td></td>
6620          * </tr>
6621          * <tr>
6622          * <td>String</td>
6623          * <td>{@link #PROTOCOL}</td>
6624          * <td>{@link #DATA5}</td>
6625          * <td>
6626          * <p>
6627          * Allowed values:
6628          * <ul>
6629          * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
6630          * as {@link #CUSTOM_PROTOCOL}.</li>
6631          * <li>{@link #PROTOCOL_AIM}</li>
6632          * <li>{@link #PROTOCOL_MSN}</li>
6633          * <li>{@link #PROTOCOL_YAHOO}</li>
6634          * <li>{@link #PROTOCOL_SKYPE}</li>
6635          * <li>{@link #PROTOCOL_QQ}</li>
6636          * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
6637          * <li>{@link #PROTOCOL_ICQ}</li>
6638          * <li>{@link #PROTOCOL_JABBER}</li>
6639          * <li>{@link #PROTOCOL_NETMEETING}</li>
6640          * </ul>
6641          * </p>
6642          * </td>
6643          * </tr>
6644          * <tr>
6645          * <td>String</td>
6646          * <td>{@link #CUSTOM_PROTOCOL}</td>
6647          * <td>{@link #DATA6}</td>
6648          * <td></td>
6649          * </tr>
6650          * </table>
6651          */
6652         public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts {
6653             /**
6654              * This utility class cannot be instantiated
6655              */
Im()6656             private Im() {}
6657 
6658             /** MIME type used when storing this in data table. */
6659             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
6660 
6661             public static final int TYPE_HOME = 1;
6662             public static final int TYPE_WORK = 2;
6663             public static final int TYPE_OTHER = 3;
6664 
6665             /**
6666              * This column should be populated with one of the defined
6667              * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
6668              * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
6669              * should contain the name of the custom protocol.
6670              */
6671             public static final String PROTOCOL = DATA5;
6672 
6673             public static final String CUSTOM_PROTOCOL = DATA6;
6674 
6675             /*
6676              * The predefined IM protocol types.
6677              */
6678             public static final int PROTOCOL_CUSTOM = -1;
6679             public static final int PROTOCOL_AIM = 0;
6680             public static final int PROTOCOL_MSN = 1;
6681             public static final int PROTOCOL_YAHOO = 2;
6682             public static final int PROTOCOL_SKYPE = 3;
6683             public static final int PROTOCOL_QQ = 4;
6684             public static final int PROTOCOL_GOOGLE_TALK = 5;
6685             public static final int PROTOCOL_ICQ = 6;
6686             public static final int PROTOCOL_JABBER = 7;
6687             public static final int PROTOCOL_NETMEETING = 8;
6688 
6689             /**
6690              * Return the string resource that best describes the given
6691              * {@link #TYPE}. Will always return a valid resource.
6692              */
getTypeLabelResource(int type)6693             public static final int getTypeLabelResource(int type) {
6694                 switch (type) {
6695                     case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
6696                     case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
6697                     case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
6698                     default: return com.android.internal.R.string.imTypeCustom;
6699                 }
6700             }
6701 
6702             /**
6703              * Return a {@link CharSequence} that best describes the given type,
6704              * possibly substituting the given {@link #LABEL} value
6705              * for {@link #TYPE_CUSTOM}.
6706              */
getTypeLabel(Resources res, int type, CharSequence label)6707             public static final CharSequence getTypeLabel(Resources res, int type,
6708                     CharSequence label) {
6709                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6710                     return label;
6711                 } else {
6712                     final int labelRes = getTypeLabelResource(type);
6713                     return res.getText(labelRes);
6714                 }
6715             }
6716 
6717             /**
6718              * Return the string resource that best describes the given
6719              * {@link #PROTOCOL}. Will always return a valid resource.
6720              */
getProtocolLabelResource(int type)6721             public static final int getProtocolLabelResource(int type) {
6722                 switch (type) {
6723                     case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
6724                     case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
6725                     case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
6726                     case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
6727                     case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
6728                     case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
6729                     case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
6730                     case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
6731                     case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
6732                     default: return com.android.internal.R.string.imProtocolCustom;
6733                 }
6734             }
6735 
6736             /**
6737              * Return a {@link CharSequence} that best describes the given
6738              * protocol, possibly substituting the given
6739              * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
6740              */
getProtocolLabel(Resources res, int type, CharSequence label)6741             public static final CharSequence getProtocolLabel(Resources res, int type,
6742                     CharSequence label) {
6743                 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
6744                     return label;
6745                 } else {
6746                     final int labelRes = getProtocolLabelResource(type);
6747                     return res.getText(labelRes);
6748                 }
6749             }
6750         }
6751 
6752         /**
6753          * <p>
6754          * A data kind representing an organization.
6755          * </p>
6756          * <p>
6757          * You can use all columns defined for {@link ContactsContract.Data} as
6758          * well as the following aliases.
6759          * </p>
6760          * <h2>Column aliases</h2>
6761          * <table class="jd-sumtable">
6762          * <tr>
6763          * <th>Type</th>
6764          * <th>Alias</th><th colspan='2'>Data column</th>
6765          * </tr>
6766          * <tr>
6767          * <td>String</td>
6768          * <td>{@link #COMPANY}</td>
6769          * <td>{@link #DATA1}</td>
6770          * <td></td>
6771          * </tr>
6772          * <tr>
6773          * <td>int</td>
6774          * <td>{@link #TYPE}</td>
6775          * <td>{@link #DATA2}</td>
6776          * <td>Allowed values are:
6777          * <p>
6778          * <ul>
6779          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6780          * <li>{@link #TYPE_WORK}</li>
6781          * <li>{@link #TYPE_OTHER}</li>
6782          * </ul>
6783          * </p>
6784          * </td>
6785          * </tr>
6786          * <tr>
6787          * <td>String</td>
6788          * <td>{@link #LABEL}</td>
6789          * <td>{@link #DATA3}</td>
6790          * <td></td>
6791          * </tr>
6792          * <tr>
6793          * <td>String</td>
6794          * <td>{@link #TITLE}</td>
6795          * <td>{@link #DATA4}</td>
6796          * <td></td>
6797          * </tr>
6798          * <tr>
6799          * <td>String</td>
6800          * <td>{@link #DEPARTMENT}</td>
6801          * <td>{@link #DATA5}</td>
6802          * <td></td>
6803          * </tr>
6804          * <tr>
6805          * <td>String</td>
6806          * <td>{@link #JOB_DESCRIPTION}</td>
6807          * <td>{@link #DATA6}</td>
6808          * <td></td>
6809          * </tr>
6810          * <tr>
6811          * <td>String</td>
6812          * <td>{@link #SYMBOL}</td>
6813          * <td>{@link #DATA7}</td>
6814          * <td></td>
6815          * </tr>
6816          * <tr>
6817          * <td>String</td>
6818          * <td>{@link #PHONETIC_NAME}</td>
6819          * <td>{@link #DATA8}</td>
6820          * <td></td>
6821          * </tr>
6822          * <tr>
6823          * <td>String</td>
6824          * <td>{@link #OFFICE_LOCATION}</td>
6825          * <td>{@link #DATA9}</td>
6826          * <td></td>
6827          * </tr>
6828          * <tr>
6829          * <td>String</td>
6830          * <td>PHONETIC_NAME_STYLE</td>
6831          * <td>{@link #DATA10}</td>
6832          * <td></td>
6833          * </tr>
6834          * </table>
6835          */
6836         public static final class Organization implements DataColumnsWithJoins, CommonColumns,
6837                 ContactCounts {
6838             /**
6839              * This utility class cannot be instantiated
6840              */
Organization()6841             private Organization() {}
6842 
6843             /** MIME type used when storing this in data table. */
6844             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
6845 
6846             public static final int TYPE_WORK = 1;
6847             public static final int TYPE_OTHER = 2;
6848 
6849             /**
6850              * The company as the user entered it.
6851              * <P>Type: TEXT</P>
6852              */
6853             public static final String COMPANY = DATA;
6854 
6855             /**
6856              * The position title at this company as the user entered it.
6857              * <P>Type: TEXT</P>
6858              */
6859             public static final String TITLE = DATA4;
6860 
6861             /**
6862              * The department at this company as the user entered it.
6863              * <P>Type: TEXT</P>
6864              */
6865             public static final String DEPARTMENT = DATA5;
6866 
6867             /**
6868              * The job description at this company as the user entered it.
6869              * <P>Type: TEXT</P>
6870              */
6871             public static final String JOB_DESCRIPTION = DATA6;
6872 
6873             /**
6874              * The symbol of this company as the user entered it.
6875              * <P>Type: TEXT</P>
6876              */
6877             public static final String SYMBOL = DATA7;
6878 
6879             /**
6880              * The phonetic name of this company as the user entered it.
6881              * <P>Type: TEXT</P>
6882              */
6883             public static final String PHONETIC_NAME = DATA8;
6884 
6885             /**
6886              * The office location of this organization.
6887              * <P>Type: TEXT</P>
6888              */
6889             public static final String OFFICE_LOCATION = DATA9;
6890 
6891             /**
6892              * The alphabet used for capturing the phonetic name.
6893              * See {@link ContactsContract.PhoneticNameStyle}.
6894              */
6895             public static final String PHONETIC_NAME_STYLE = DATA10;
6896 
6897             /**
6898              * Return the string resource that best describes the given
6899              * {@link #TYPE}. Will always return a valid resource.
6900              */
getTypeLabelResource(int type)6901             public static final int getTypeLabelResource(int type) {
6902                 switch (type) {
6903                     case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
6904                     case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
6905                     default: return com.android.internal.R.string.orgTypeCustom;
6906                 }
6907             }
6908 
6909             /**
6910              * Return a {@link CharSequence} that best describes the given type,
6911              * possibly substituting the given {@link #LABEL} value
6912              * for {@link #TYPE_CUSTOM}.
6913              */
getTypeLabel(Resources res, int type, CharSequence label)6914             public static final CharSequence getTypeLabel(Resources res, int type,
6915                     CharSequence label) {
6916                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6917                     return label;
6918                 } else {
6919                     final int labelRes = getTypeLabelResource(type);
6920                     return res.getText(labelRes);
6921                 }
6922             }
6923         }
6924 
6925         /**
6926          * <p>
6927          * A data kind representing a relation.
6928          * </p>
6929          * <p>
6930          * You can use all columns defined for {@link ContactsContract.Data} as
6931          * well as the following aliases.
6932          * </p>
6933          * <h2>Column aliases</h2>
6934          * <table class="jd-sumtable">
6935          * <tr>
6936          * <th>Type</th>
6937          * <th>Alias</th><th colspan='2'>Data column</th>
6938          * </tr>
6939          * <tr>
6940          * <td>String</td>
6941          * <td>{@link #NAME}</td>
6942          * <td>{@link #DATA1}</td>
6943          * <td></td>
6944          * </tr>
6945          * <tr>
6946          * <td>int</td>
6947          * <td>{@link #TYPE}</td>
6948          * <td>{@link #DATA2}</td>
6949          * <td>Allowed values are:
6950          * <p>
6951          * <ul>
6952          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6953          * <li>{@link #TYPE_ASSISTANT}</li>
6954          * <li>{@link #TYPE_BROTHER}</li>
6955          * <li>{@link #TYPE_CHILD}</li>
6956          * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
6957          * <li>{@link #TYPE_FATHER}</li>
6958          * <li>{@link #TYPE_FRIEND}</li>
6959          * <li>{@link #TYPE_MANAGER}</li>
6960          * <li>{@link #TYPE_MOTHER}</li>
6961          * <li>{@link #TYPE_PARENT}</li>
6962          * <li>{@link #TYPE_PARTNER}</li>
6963          * <li>{@link #TYPE_REFERRED_BY}</li>
6964          * <li>{@link #TYPE_RELATIVE}</li>
6965          * <li>{@link #TYPE_SISTER}</li>
6966          * <li>{@link #TYPE_SPOUSE}</li>
6967          * </ul>
6968          * </p>
6969          * </td>
6970          * </tr>
6971          * <tr>
6972          * <td>String</td>
6973          * <td>{@link #LABEL}</td>
6974          * <td>{@link #DATA3}</td>
6975          * <td></td>
6976          * </tr>
6977          * </table>
6978          */
6979         public static final class Relation implements DataColumnsWithJoins, CommonColumns,
6980                 ContactCounts {
6981             /**
6982              * This utility class cannot be instantiated
6983              */
Relation()6984             private Relation() {}
6985 
6986             /** MIME type used when storing this in data table. */
6987             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
6988 
6989             public static final int TYPE_ASSISTANT = 1;
6990             public static final int TYPE_BROTHER = 2;
6991             public static final int TYPE_CHILD = 3;
6992             public static final int TYPE_DOMESTIC_PARTNER = 4;
6993             public static final int TYPE_FATHER = 5;
6994             public static final int TYPE_FRIEND = 6;
6995             public static final int TYPE_MANAGER = 7;
6996             public static final int TYPE_MOTHER = 8;
6997             public static final int TYPE_PARENT = 9;
6998             public static final int TYPE_PARTNER = 10;
6999             public static final int TYPE_REFERRED_BY = 11;
7000             public static final int TYPE_RELATIVE = 12;
7001             public static final int TYPE_SISTER = 13;
7002             public static final int TYPE_SPOUSE = 14;
7003 
7004             /**
7005              * The name of the relative as the user entered it.
7006              * <P>Type: TEXT</P>
7007              */
7008             public static final String NAME = DATA;
7009 
7010             /**
7011              * Return the string resource that best describes the given
7012              * {@link #TYPE}. Will always return a valid resource.
7013              */
getTypeLabelResource(int type)7014             public static final int getTypeLabelResource(int type) {
7015                 switch (type) {
7016                     case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant;
7017                     case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother;
7018                     case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild;
7019                     case TYPE_DOMESTIC_PARTNER:
7020                             return com.android.internal.R.string.relationTypeDomesticPartner;
7021                     case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather;
7022                     case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend;
7023                     case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager;
7024                     case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother;
7025                     case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent;
7026                     case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner;
7027                     case TYPE_REFERRED_BY:
7028                             return com.android.internal.R.string.relationTypeReferredBy;
7029                     case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative;
7030                     case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister;
7031                     case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse;
7032                     default: return com.android.internal.R.string.orgTypeCustom;
7033                 }
7034             }
7035 
7036             /**
7037              * Return a {@link CharSequence} that best describes the given type,
7038              * possibly substituting the given {@link #LABEL} value
7039              * for {@link #TYPE_CUSTOM}.
7040              */
getTypeLabel(Resources res, int type, CharSequence label)7041             public static final CharSequence getTypeLabel(Resources res, int type,
7042                     CharSequence label) {
7043                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7044                     return label;
7045                 } else {
7046                     final int labelRes = getTypeLabelResource(type);
7047                     return res.getText(labelRes);
7048                 }
7049             }
7050         }
7051 
7052         /**
7053          * <p>
7054          * A data kind representing an event.
7055          * </p>
7056          * <p>
7057          * You can use all columns defined for {@link ContactsContract.Data} as
7058          * well as the following aliases.
7059          * </p>
7060          * <h2>Column aliases</h2>
7061          * <table class="jd-sumtable">
7062          * <tr>
7063          * <th>Type</th>
7064          * <th>Alias</th><th colspan='2'>Data column</th>
7065          * </tr>
7066          * <tr>
7067          * <td>String</td>
7068          * <td>{@link #START_DATE}</td>
7069          * <td>{@link #DATA1}</td>
7070          * <td></td>
7071          * </tr>
7072          * <tr>
7073          * <td>int</td>
7074          * <td>{@link #TYPE}</td>
7075          * <td>{@link #DATA2}</td>
7076          * <td>Allowed values are:
7077          * <p>
7078          * <ul>
7079          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7080          * <li>{@link #TYPE_ANNIVERSARY}</li>
7081          * <li>{@link #TYPE_OTHER}</li>
7082          * <li>{@link #TYPE_BIRTHDAY}</li>
7083          * </ul>
7084          * </p>
7085          * </td>
7086          * </tr>
7087          * <tr>
7088          * <td>String</td>
7089          * <td>{@link #LABEL}</td>
7090          * <td>{@link #DATA3}</td>
7091          * <td></td>
7092          * </tr>
7093          * </table>
7094          */
7095         public static final class Event implements DataColumnsWithJoins, CommonColumns,
7096                 ContactCounts {
7097             /**
7098              * This utility class cannot be instantiated
7099              */
Event()7100             private Event() {}
7101 
7102             /** MIME type used when storing this in data table. */
7103             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
7104 
7105             public static final int TYPE_ANNIVERSARY = 1;
7106             public static final int TYPE_OTHER = 2;
7107             public static final int TYPE_BIRTHDAY = 3;
7108 
7109             /**
7110              * The event start date as the user entered it.
7111              * <P>Type: TEXT</P>
7112              */
7113             public static final String START_DATE = DATA;
7114 
7115             /**
7116              * Return the string resource that best describes the given
7117              * {@link #TYPE}. Will always return a valid resource.
7118              */
getTypeResource(Integer type)7119             public static int getTypeResource(Integer type) {
7120                 if (type == null) {
7121                     return com.android.internal.R.string.eventTypeOther;
7122                 }
7123                 switch (type) {
7124                     case TYPE_ANNIVERSARY:
7125                         return com.android.internal.R.string.eventTypeAnniversary;
7126                     case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
7127                     case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
7128                     default: return com.android.internal.R.string.eventTypeCustom;
7129                 }
7130             }
7131 
7132             /**
7133              * Return a {@link CharSequence} that best describes the given type,
7134              * possibly substituting the given {@link #LABEL} value
7135              * for {@link #TYPE_CUSTOM}.
7136              */
getTypeLabel(Resources res, int type, CharSequence label)7137             public static final CharSequence getTypeLabel(Resources res, int type,
7138                     CharSequence label) {
7139                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7140                     return label;
7141                 } else {
7142                     final int labelRes = getTypeResource(type);
7143                     return res.getText(labelRes);
7144                 }
7145             }
7146         }
7147 
7148         /**
7149          * <p>
7150          * A data kind representing a photo for the contact.
7151          * </p>
7152          * <p>
7153          * Some sync adapters will choose to download photos in a separate
7154          * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
7155          * through {@link ContactsContract.Data#SYNC4} to store temporary
7156          * data, e.g. the image URL or ID, state of download, server-side version
7157          * of the image.  It is allowed for the {@link #PHOTO} to be null.
7158          * </p>
7159          * <p>
7160          * You can use all columns defined for {@link ContactsContract.Data} as
7161          * well as the following aliases.
7162          * </p>
7163          * <h2>Column aliases</h2>
7164          * <table class="jd-sumtable">
7165          * <tr>
7166          * <th>Type</th>
7167          * <th>Alias</th><th colspan='2'>Data column</th>
7168          * </tr>
7169          * <tr>
7170          * <td>NUMBER</td>
7171          * <td>{@link #PHOTO_FILE_ID}</td>
7172          * <td>{@link #DATA14}</td>
7173          * <td>ID of the hi-res photo file.</td>
7174          * </tr>
7175          * <tr>
7176          * <td>BLOB</td>
7177          * <td>{@link #PHOTO}</td>
7178          * <td>{@link #DATA15}</td>
7179          * <td>By convention, binary data is stored in DATA15.  The thumbnail of the
7180          * photo is stored in this column.</td>
7181          * </tr>
7182          * </table>
7183          */
7184         public static final class Photo implements DataColumnsWithJoins, ContactCounts {
7185             /**
7186              * This utility class cannot be instantiated
7187              */
Photo()7188             private Photo() {}
7189 
7190             /** MIME type used when storing this in data table. */
7191             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
7192 
7193             /**
7194              * Photo file ID for the display photo of the raw contact.
7195              * See {@link ContactsContract.DisplayPhoto}.
7196              * <p>
7197              * Type: NUMBER
7198              */
7199             public static final String PHOTO_FILE_ID = DATA14;
7200 
7201             /**
7202              * Thumbnail photo of the raw contact. This is the raw bytes of an image
7203              * that could be inflated using {@link android.graphics.BitmapFactory}.
7204              * <p>
7205              * Type: BLOB
7206              */
7207             public static final String PHOTO = DATA15;
7208         }
7209 
7210         /**
7211          * <p>
7212          * Notes about the contact.
7213          * </p>
7214          * <p>
7215          * You can use all columns defined for {@link ContactsContract.Data} as
7216          * well as the following aliases.
7217          * </p>
7218          * <h2>Column aliases</h2>
7219          * <table class="jd-sumtable">
7220          * <tr>
7221          * <th>Type</th>
7222          * <th>Alias</th><th colspan='2'>Data column</th>
7223          * </tr>
7224          * <tr>
7225          * <td>String</td>
7226          * <td>{@link #NOTE}</td>
7227          * <td>{@link #DATA1}</td>
7228          * <td></td>
7229          * </tr>
7230          * </table>
7231          */
7232         public static final class Note implements DataColumnsWithJoins, ContactCounts {
7233             /**
7234              * This utility class cannot be instantiated
7235              */
Note()7236             private Note() {}
7237 
7238             /** MIME type used when storing this in data table. */
7239             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
7240 
7241             /**
7242              * The note text.
7243              * <P>Type: TEXT</P>
7244              */
7245             public static final String NOTE = DATA1;
7246         }
7247 
7248         /**
7249          * <p>
7250          * Group Membership.
7251          * </p>
7252          * <p>
7253          * You can use all columns defined for {@link ContactsContract.Data} as
7254          * well as the following aliases.
7255          * </p>
7256          * <h2>Column aliases</h2>
7257          * <table class="jd-sumtable">
7258          * <tr>
7259          * <th>Type</th>
7260          * <th>Alias</th><th colspan='2'>Data column</th>
7261          * </tr>
7262          * <tr>
7263          * <td>long</td>
7264          * <td>{@link #GROUP_ROW_ID}</td>
7265          * <td>{@link #DATA1}</td>
7266          * <td></td>
7267          * </tr>
7268          * <tr>
7269          * <td>String</td>
7270          * <td>{@link #GROUP_SOURCE_ID}</td>
7271          * <td>none</td>
7272          * <td>
7273          * <p>
7274          * The sourceid of the group that this group membership refers to.
7275          * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
7276          * inserting a row.
7277          * </p>
7278          * <p>
7279          * If this field is specified, the provider will first try to
7280          * look up a group with this {@link Groups Groups.SOURCE_ID}.  If such a group
7281          * is found, it will use the corresponding row id.  If the group is not
7282          * found, it will create one.
7283          * </td>
7284          * </tr>
7285          * </table>
7286          */
7287         public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts {
7288             /**
7289              * This utility class cannot be instantiated
7290              */
GroupMembership()7291             private GroupMembership() {}
7292 
7293             /** MIME type used when storing this in data table. */
7294             public static final String CONTENT_ITEM_TYPE =
7295                     "vnd.android.cursor.item/group_membership";
7296 
7297             /**
7298              * The row id of the group that this group membership refers to. Exactly one of
7299              * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
7300              * <P>Type: INTEGER</P>
7301              */
7302             public static final String GROUP_ROW_ID = DATA1;
7303 
7304             /**
7305              * The sourceid of the group that this group membership refers to.  Exactly one of
7306              * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
7307              * <P>Type: TEXT</P>
7308              */
7309             public static final String GROUP_SOURCE_ID = "group_sourceid";
7310         }
7311 
7312         /**
7313          * <p>
7314          * A data kind representing a website related to the contact.
7315          * </p>
7316          * <p>
7317          * You can use all columns defined for {@link ContactsContract.Data} as
7318          * well as the following aliases.
7319          * </p>
7320          * <h2>Column aliases</h2>
7321          * <table class="jd-sumtable">
7322          * <tr>
7323          * <th>Type</th>
7324          * <th>Alias</th><th colspan='2'>Data column</th>
7325          * </tr>
7326          * <tr>
7327          * <td>String</td>
7328          * <td>{@link #URL}</td>
7329          * <td>{@link #DATA1}</td>
7330          * <td></td>
7331          * </tr>
7332          * <tr>
7333          * <td>int</td>
7334          * <td>{@link #TYPE}</td>
7335          * <td>{@link #DATA2}</td>
7336          * <td>Allowed values are:
7337          * <p>
7338          * <ul>
7339          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7340          * <li>{@link #TYPE_HOMEPAGE}</li>
7341          * <li>{@link #TYPE_BLOG}</li>
7342          * <li>{@link #TYPE_PROFILE}</li>
7343          * <li>{@link #TYPE_HOME}</li>
7344          * <li>{@link #TYPE_WORK}</li>
7345          * <li>{@link #TYPE_FTP}</li>
7346          * <li>{@link #TYPE_OTHER}</li>
7347          * </ul>
7348          * </p>
7349          * </td>
7350          * </tr>
7351          * <tr>
7352          * <td>String</td>
7353          * <td>{@link #LABEL}</td>
7354          * <td>{@link #DATA3}</td>
7355          * <td></td>
7356          * </tr>
7357          * </table>
7358          */
7359         public static final class Website implements DataColumnsWithJoins, CommonColumns,
7360                 ContactCounts {
7361             /**
7362              * This utility class cannot be instantiated
7363              */
Website()7364             private Website() {}
7365 
7366             /** MIME type used when storing this in data table. */
7367             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
7368 
7369             public static final int TYPE_HOMEPAGE = 1;
7370             public static final int TYPE_BLOG = 2;
7371             public static final int TYPE_PROFILE = 3;
7372             public static final int TYPE_HOME = 4;
7373             public static final int TYPE_WORK = 5;
7374             public static final int TYPE_FTP = 6;
7375             public static final int TYPE_OTHER = 7;
7376 
7377             /**
7378              * The website URL string.
7379              * <P>Type: TEXT</P>
7380              */
7381             public static final String URL = DATA;
7382         }
7383 
7384         /**
7385          * <p>
7386          * A data kind representing a SIP address for the contact.
7387          * </p>
7388          * <p>
7389          * You can use all columns defined for {@link ContactsContract.Data} as
7390          * well as the following aliases.
7391          * </p>
7392          * <h2>Column aliases</h2>
7393          * <table class="jd-sumtable">
7394          * <tr>
7395          * <th>Type</th>
7396          * <th>Alias</th><th colspan='2'>Data column</th>
7397          * </tr>
7398          * <tr>
7399          * <td>String</td>
7400          * <td>{@link #SIP_ADDRESS}</td>
7401          * <td>{@link #DATA1}</td>
7402          * <td></td>
7403          * </tr>
7404          * <tr>
7405          * <td>int</td>
7406          * <td>{@link #TYPE}</td>
7407          * <td>{@link #DATA2}</td>
7408          * <td>Allowed values are:
7409          * <p>
7410          * <ul>
7411          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7412          * <li>{@link #TYPE_HOME}</li>
7413          * <li>{@link #TYPE_WORK}</li>
7414          * <li>{@link #TYPE_OTHER}</li>
7415          * </ul>
7416          * </p>
7417          * </td>
7418          * </tr>
7419          * <tr>
7420          * <td>String</td>
7421          * <td>{@link #LABEL}</td>
7422          * <td>{@link #DATA3}</td>
7423          * <td></td>
7424          * </tr>
7425          * </table>
7426          */
7427         public static final class SipAddress implements DataColumnsWithJoins, CommonColumns,
7428                 ContactCounts {
7429             /**
7430              * This utility class cannot be instantiated
7431              */
SipAddress()7432             private SipAddress() {}
7433 
7434             /** MIME type used when storing this in data table. */
7435             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address";
7436 
7437             public static final int TYPE_HOME = 1;
7438             public static final int TYPE_WORK = 2;
7439             public static final int TYPE_OTHER = 3;
7440 
7441             /**
7442              * The SIP address.
7443              * <P>Type: TEXT</P>
7444              */
7445             public static final String SIP_ADDRESS = DATA1;
7446             // ...and TYPE and LABEL come from the CommonColumns interface.
7447 
7448             /**
7449              * Return the string resource that best describes the given
7450              * {@link #TYPE}. Will always return a valid resource.
7451              */
getTypeLabelResource(int type)7452             public static final int getTypeLabelResource(int type) {
7453                 switch (type) {
7454                     case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome;
7455                     case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork;
7456                     case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther;
7457                     default: return com.android.internal.R.string.sipAddressTypeCustom;
7458                 }
7459             }
7460 
7461             /**
7462              * Return a {@link CharSequence} that best describes the given type,
7463              * possibly substituting the given {@link #LABEL} value
7464              * for {@link #TYPE_CUSTOM}.
7465              */
getTypeLabel(Resources res, int type, CharSequence label)7466             public static final CharSequence getTypeLabel(Resources res, int type,
7467                     CharSequence label) {
7468                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7469                     return label;
7470                 } else {
7471                     final int labelRes = getTypeLabelResource(type);
7472                     return res.getText(labelRes);
7473                 }
7474             }
7475         }
7476 
7477         /**
7478          * A data kind representing an Identity related to the contact.
7479          * <p>
7480          * This can be used as a signal by the aggregator to combine raw contacts into
7481          * contacts, e.g. if two contacts have Identity rows with
7482          * the same NAMESPACE and IDENTITY values the aggregator can know that they refer
7483          * to the same person.
7484          * </p>
7485          */
7486         public static final class Identity implements DataColumnsWithJoins, ContactCounts {
7487             /**
7488              * This utility class cannot be instantiated
7489              */
Identity()7490             private Identity() {}
7491 
7492             /** MIME type used when storing this in data table. */
7493             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity";
7494 
7495             /**
7496              * The identity string.
7497              * <P>Type: TEXT</P>
7498              */
7499             public static final String IDENTITY = DataColumns.DATA1;
7500 
7501             /**
7502              * The namespace of the identity string, e.g. "com.google"
7503              * <P>Type: TEXT</P>
7504              */
7505             public static final String NAMESPACE = DataColumns.DATA2;
7506         }
7507 
7508         /**
7509          * <p>
7510          * Convenient functionalities for "callable" data. Note that, this is NOT a separate data
7511          * kind.
7512          * </p>
7513          * <p>
7514          * This URI allows the ContactsProvider to return a unified result for "callable" data
7515          * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the
7516          * current examples for "callable", but may be expanded to the other types.
7517          * </p>
7518          * <p>
7519          * Each returned row may have a different MIMETYPE and thus different interpretation for
7520          * each column. For example the meaning for {@link Phone}'s type is different than
7521          * {@link SipAddress}'s.
7522          * </p>
7523          */
7524         public static final class Callable implements DataColumnsWithJoins, CommonColumns,
7525                 ContactCounts {
7526             /**
7527              * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only
7528              * phone numbers.
7529              */
7530             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7531                     "callables");
7532             /**
7533              * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable
7534              * data.
7535              */
7536             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
7537                     "filter");
7538 
7539             /**
7540              * Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter
7541              * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
7542              * parameters, otherwise it will throw IllegalArgumentException.
7543              */
7544             public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
7545                     CONTENT_URI, "filter_enterprise");
7546         }
7547 
7548         /**
7549          * A special class of data items, used to refer to types of data that can be used to attempt
7550          * to start communicating with a person ({@link Phone} and {@link Email}). Note that this
7551          * is NOT a separate data kind.
7552          *
7553          * This URI allows the ContactsProvider to return a unified result for data items that users
7554          * can use to initiate communications with another contact. {@link Phone} and {@link Email}
7555          * are the current data types in this category.
7556          */
7557         public static final class Contactables implements DataColumnsWithJoins, CommonColumns,
7558                 ContactCounts {
7559             /**
7560              * The content:// style URI for these data items, which requests a directory of data
7561              * rows matching the selection criteria.
7562              */
7563             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7564                     "contactables");
7565 
7566             /**
7567              * The content:// style URI for these data items, which allows for a query parameter to
7568              * be appended onto the end to filter for data items matching the query.
7569              */
7570             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
7571                     Contactables.CONTENT_URI, "filter");
7572 
7573             /**
7574              * A boolean parameter for {@link Data#CONTENT_URI}.
7575              * This specifies whether or not the returned data items should be filtered to show
7576              * data items belonging to visible contacts only.
7577              */
7578             public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
7579         }
7580     }
7581 
7582     /**
7583      * @see Groups
7584      */
7585     protected interface GroupsColumns {
7586         /**
7587          * The data set within the account that this group belongs to.  This allows
7588          * multiple sync adapters for the same account type to distinguish between
7589          * each others' group data.
7590          *
7591          * This is empty by default, and is completely optional.  It only needs to
7592          * be populated if multiple sync adapters are entering distinct group data
7593          * for the same account type and account name.
7594          * <P>Type: TEXT</P>
7595          */
7596         public static final String DATA_SET = "data_set";
7597 
7598         /**
7599          * A concatenation of the account type and data set (delimited by a forward
7600          * slash) - if the data set is empty, this will be the same as the account
7601          * type.  For applications that need to be aware of the data set, this can
7602          * be used instead of account type to distinguish sets of data.  This is
7603          * never intended to be used for specifying accounts.
7604          * @hide
7605          */
7606         public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
7607 
7608         /**
7609          * The display title of this group.
7610          * <p>
7611          * Type: TEXT
7612          */
7613         public static final String TITLE = "title";
7614 
7615         /**
7616          * The package name to use when creating {@link Resources} objects for
7617          * this group. This value is only designed for use when building user
7618          * interfaces, and should not be used to infer the owner.
7619          */
7620         public static final String RES_PACKAGE = "res_package";
7621 
7622         /**
7623          * The display title of this group to load as a resource from
7624          * {@link #RES_PACKAGE}, which may be localized.
7625          * <P>Type: TEXT</P>
7626          */
7627         public static final String TITLE_RES = "title_res";
7628 
7629         /**
7630          * Notes about the group.
7631          * <p>
7632          * Type: TEXT
7633          */
7634         public static final String NOTES = "notes";
7635 
7636         /**
7637          * The ID of this group if it is a System Group, i.e. a group that has a special meaning
7638          * to the sync adapter, null otherwise.
7639          * <P>Type: TEXT</P>
7640          */
7641         public static final String SYSTEM_ID = "system_id";
7642 
7643         /**
7644          * The total number of {@link Contacts} that have
7645          * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
7646          * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
7647          * <p>
7648          * Type: INTEGER
7649          */
7650         public static final String SUMMARY_COUNT = "summ_count";
7651 
7652         /**
7653          * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}.
7654          * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}.
7655          *
7656          * @hide
7657          */
7658         public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT =
7659                 "return_group_count_per_account";
7660 
7661         /**
7662          * The total number of groups of the account that a group belongs to.
7663          * This column is available only when the parameter
7664          * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in
7665          * {@link Groups#CONTENT_SUMMARY_URI}.
7666          *
7667          * For example, when the account "A" has two groups "group1" and "group2", and the account
7668          * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for
7669          * "group3" returns "1" for this column.
7670          *
7671          * Note: This counts only non-favorites, non-auto-add, and not deleted groups.
7672          *
7673          * Type: INTEGER
7674          * @hide
7675          */
7676         public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account";
7677 
7678         /**
7679          * The total number of {@link Contacts} that have both
7680          * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
7681          * Read-only value that is only present when querying
7682          * {@link Groups#CONTENT_SUMMARY_URI}.
7683          * <p>
7684          * Type: INTEGER
7685          */
7686         public static final String SUMMARY_WITH_PHONES = "summ_phones";
7687 
7688         /**
7689          * Flag indicating if the contacts belonging to this group should be
7690          * visible in any user interface.
7691          * <p>
7692          * Type: INTEGER (boolean)
7693          */
7694         public static final String GROUP_VISIBLE = "group_visible";
7695 
7696         /**
7697          * The "deleted" flag: "0" by default, "1" if the row has been marked
7698          * for deletion. When {@link android.content.ContentResolver#delete} is
7699          * called on a group, it is marked for deletion. The sync adaptor
7700          * deletes the group on the server and then calls ContactResolver.delete
7701          * once more, this time setting the the
7702          * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
7703          * finalize the data removal.
7704          * <P>Type: INTEGER</P>
7705          */
7706         public static final String DELETED = "deleted";
7707 
7708         /**
7709          * Whether this group should be synced if the SYNC_EVERYTHING settings
7710          * is false for this group's account.
7711          * <p>
7712          * Type: INTEGER (boolean)
7713          */
7714         public static final String SHOULD_SYNC = "should_sync";
7715 
7716         /**
7717          * Any newly created contacts will automatically be added to groups that have this
7718          * flag set to true.
7719          * <p>
7720          * Type: INTEGER (boolean)
7721          */
7722         public static final String AUTO_ADD = "auto_add";
7723 
7724         /**
7725          * When a contacts is marked as a favorites it will be automatically added
7726          * to the groups that have this flag set, and when it is removed from favorites
7727          * it will be removed from these groups.
7728          * <p>
7729          * Type: INTEGER (boolean)
7730          */
7731         public static final String FAVORITES = "favorites";
7732 
7733         /**
7734          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
7735          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
7736          * <P>Type: INTEGER</P>
7737          */
7738         public static final String GROUP_IS_READ_ONLY = "group_is_read_only";
7739     }
7740 
7741     /**
7742      * Constants for the groups table. Only per-account groups are supported.
7743      * <h2>Columns</h2>
7744      * <table class="jd-sumtable">
7745      * <tr>
7746      * <th colspan='4'>Groups</th>
7747      * </tr>
7748      * <tr>
7749      * <td>long</td>
7750      * <td>{@link #_ID}</td>
7751      * <td>read-only</td>
7752      * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
7753      * In other words, it would be a really bad idea to delete and reinsert a
7754      * group. A sync adapter should always do an update instead.</td>
7755      * </tr>
7756      # <tr>
7757      * <td>String</td>
7758      * <td>{@link #DATA_SET}</td>
7759      * <td>read/write-once</td>
7760      * <td>
7761      * <p>
7762      * The data set within the account that this group belongs to.  This allows
7763      * multiple sync adapters for the same account type to distinguish between
7764      * each others' group data.  The combination of {@link #ACCOUNT_TYPE},
7765      * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
7766      * that is associated with a single sync adapter.
7767      * </p>
7768      * <p>
7769      * This is empty by default, and is completely optional.  It only needs to
7770      * be populated if multiple sync adapters are entering distinct data for
7771      * the same account type and account name.
7772      * </p>
7773      * <p>
7774      * It should be set at the time the group is inserted and never changed
7775      * afterwards.
7776      * </p>
7777      * </td>
7778      * </tr>
7779      * <tr>
7780      * <td>String</td>
7781      * <td>{@link #TITLE}</td>
7782      * <td>read/write</td>
7783      * <td>The display title of this group.</td>
7784      * </tr>
7785      * <tr>
7786      * <td>String</td>
7787      * <td>{@link #NOTES}</td>
7788      * <td>read/write</td>
7789      * <td>Notes about the group.</td>
7790      * </tr>
7791      * <tr>
7792      * <td>String</td>
7793      * <td>{@link #SYSTEM_ID}</td>
7794      * <td>read/write</td>
7795      * <td>The ID of this group if it is a System Group, i.e. a group that has a
7796      * special meaning to the sync adapter, null otherwise.</td>
7797      * </tr>
7798      * <tr>
7799      * <td>int</td>
7800      * <td>{@link #SUMMARY_COUNT}</td>
7801      * <td>read-only</td>
7802      * <td>The total number of {@link Contacts} that have
7803      * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
7804      * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
7805      * </tr>
7806      * <tr>
7807      * <td>int</td>
7808      * <td>{@link #SUMMARY_WITH_PHONES}</td>
7809      * <td>read-only</td>
7810      * <td>The total number of {@link Contacts} that have both
7811      * {@link CommonDataKinds.GroupMembership} in this group, and also have
7812      * phone numbers. Read-only value that is only present when querying
7813      * {@link Groups#CONTENT_SUMMARY_URI}.</td>
7814      * </tr>
7815      * <tr>
7816      * <td>int</td>
7817      * <td>{@link #GROUP_VISIBLE}</td>
7818      * <td>read-only</td>
7819      * <td>Flag indicating if the contacts belonging to this group should be
7820      * visible in any user interface. Allowed values: 0 and 1.</td>
7821      * </tr>
7822      * <tr>
7823      * <td>int</td>
7824      * <td>{@link #DELETED}</td>
7825      * <td>read/write</td>
7826      * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
7827      * for deletion. When {@link android.content.ContentResolver#delete} is
7828      * called on a group, it is marked for deletion. The sync adaptor deletes
7829      * the group on the server and then calls ContactResolver.delete once more,
7830      * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
7831      * query parameter to finalize the data removal.</td>
7832      * </tr>
7833      * <tr>
7834      * <td>int</td>
7835      * <td>{@link #SHOULD_SYNC}</td>
7836      * <td>read/write</td>
7837      * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
7838      * is false for this group's account.</td>
7839      * </tr>
7840      * </table>
7841      */
7842     public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
7843         /**
7844          * This utility class cannot be instantiated
7845          */
Groups()7846         private Groups() {
7847         }
7848 
7849         /**
7850          * The content:// style URI for this table
7851          */
7852         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
7853 
7854         /**
7855          * The content:// style URI for this table joined with details data from
7856          * {@link ContactsContract.Data}.
7857          */
7858         public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
7859                 "groups_summary");
7860 
7861         /**
7862          * The MIME type of a directory of groups.
7863          */
7864         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
7865 
7866         /**
7867          * The MIME type of a single group.
7868          */
7869         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
7870 
newEntityIterator(Cursor cursor)7871         public static EntityIterator newEntityIterator(Cursor cursor) {
7872             return new EntityIteratorImpl(cursor);
7873         }
7874 
7875         private static class EntityIteratorImpl extends CursorEntityIterator {
EntityIteratorImpl(Cursor cursor)7876             public EntityIteratorImpl(Cursor cursor) {
7877                 super(cursor);
7878             }
7879 
7880             @Override
getEntityAndIncrementCursor(Cursor cursor)7881             public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
7882                 // we expect the cursor is already at the row we need to read from
7883                 final ContentValues values = new ContentValues();
7884                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
7885                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
7886                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
7887                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
7888                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
7889                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
7890                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
7891                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
7892                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
7893                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
7894                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
7895                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
7896                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
7897                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
7898                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
7899                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
7900                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
7901                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
7902                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES);
7903                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD);
7904                 cursor.moveToNext();
7905                 return new Entity(values);
7906             }
7907         }
7908     }
7909 
7910     /**
7911      * <p>
7912      * Constants for the contact aggregation exceptions table, which contains
7913      * aggregation rules overriding those used by automatic aggregation. This
7914      * type only supports query and update. Neither insert nor delete are
7915      * supported.
7916      * </p>
7917      * <h2>Columns</h2>
7918      * <table class="jd-sumtable">
7919      * <tr>
7920      * <th colspan='4'>AggregationExceptions</th>
7921      * </tr>
7922      * <tr>
7923      * <td>int</td>
7924      * <td>{@link #TYPE}</td>
7925      * <td>read/write</td>
7926      * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
7927      * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
7928      * </tr>
7929      * <tr>
7930      * <td>long</td>
7931      * <td>{@link #RAW_CONTACT_ID1}</td>
7932      * <td>read/write</td>
7933      * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
7934      * the rule applies to.</td>
7935      * </tr>
7936      * <tr>
7937      * <td>long</td>
7938      * <td>{@link #RAW_CONTACT_ID2}</td>
7939      * <td>read/write</td>
7940      * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
7941      * that the rule applies to.</td>
7942      * </tr>
7943      * </table>
7944      */
7945     public static final class AggregationExceptions implements BaseColumns {
7946         /**
7947          * This utility class cannot be instantiated
7948          */
AggregationExceptions()7949         private AggregationExceptions() {}
7950 
7951         /**
7952          * The content:// style URI for this table
7953          */
7954         public static final Uri CONTENT_URI =
7955                 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
7956 
7957         /**
7958          * The MIME type of {@link #CONTENT_URI} providing a directory of data.
7959          */
7960         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
7961 
7962         /**
7963          * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
7964          */
7965         public static final String CONTENT_ITEM_TYPE =
7966                 "vnd.android.cursor.item/aggregation_exception";
7967 
7968         /**
7969          * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
7970          * {@link #TYPE_AUTOMATIC}.
7971          *
7972          * <P>Type: INTEGER</P>
7973          */
7974         public static final String TYPE = "type";
7975 
7976         /**
7977          * Allows the provider to automatically decide whether the specified raw contacts should
7978          * be included in the same aggregate contact or not.
7979          */
7980         public static final int TYPE_AUTOMATIC = 0;
7981 
7982         /**
7983          * Makes sure that the specified raw contacts are included in the same
7984          * aggregate contact.
7985          */
7986         public static final int TYPE_KEEP_TOGETHER = 1;
7987 
7988         /**
7989          * Makes sure that the specified raw contacts are NOT included in the same
7990          * aggregate contact.
7991          */
7992         public static final int TYPE_KEEP_SEPARATE = 2;
7993 
7994         /**
7995          * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
7996          */
7997         public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
7998 
7999         /**
8000          * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
8001          * applies to.
8002          */
8003         public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
8004     }
8005 
8006     /**
8007      * @see Settings
8008      */
8009     protected interface SettingsColumns {
8010         /**
8011          * The name of the account instance to which this row belongs.
8012          * <P>Type: TEXT</P>
8013          */
8014         public static final String ACCOUNT_NAME = "account_name";
8015 
8016         /**
8017          * The type of account to which this row belongs, which when paired with
8018          * {@link #ACCOUNT_NAME} identifies a specific account.
8019          * <P>Type: TEXT</P>
8020          */
8021         public static final String ACCOUNT_TYPE = "account_type";
8022 
8023         /**
8024          * The data set within the account that this row belongs to.  This allows
8025          * multiple sync adapters for the same account type to distinguish between
8026          * each others' data.
8027          *
8028          * This is empty by default, and is completely optional.  It only needs to
8029          * be populated if multiple sync adapters are entering distinct data for
8030          * the same account type and account name.
8031          * <P>Type: TEXT</P>
8032          */
8033         public static final String DATA_SET = "data_set";
8034 
8035         /**
8036          * Depending on the mode defined by the sync-adapter, this flag controls
8037          * the top-level sync behavior for this data source.
8038          * <p>
8039          * Type: INTEGER (boolean)
8040          */
8041         public static final String SHOULD_SYNC = "should_sync";
8042 
8043         /**
8044          * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
8045          * entries should be visible in any user interface.
8046          * <p>
8047          * Type: INTEGER (boolean)
8048          */
8049         public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
8050 
8051         /**
8052          * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
8053          * {@link Groups#SHOULD_SYNC} under this account have been marked as
8054          * unsynced.
8055          */
8056         public static final String ANY_UNSYNCED = "any_unsynced";
8057 
8058         /**
8059          * Read-only count of {@link Contacts} from a specific source that have
8060          * no {@link CommonDataKinds.GroupMembership} entries.
8061          * <p>
8062          * Type: INTEGER
8063          */
8064         public static final String UNGROUPED_COUNT = "summ_count";
8065 
8066         /**
8067          * Read-only count of {@link Contacts} from a specific source that have
8068          * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
8069          * <p>
8070          * Type: INTEGER
8071          */
8072         public static final String UNGROUPED_WITH_PHONES = "summ_phones";
8073     }
8074 
8075     /**
8076      * <p>
8077      * Contacts-specific settings for various {@link Account}'s.
8078      * </p>
8079      * <h2>Columns</h2>
8080      * <table class="jd-sumtable">
8081      * <tr>
8082      * <th colspan='4'>Settings</th>
8083      * </tr>
8084      * <tr>
8085      * <td>String</td>
8086      * <td>{@link #ACCOUNT_NAME}</td>
8087      * <td>read/write-once</td>
8088      * <td>The name of the account instance to which this row belongs.</td>
8089      * </tr>
8090      * <tr>
8091      * <td>String</td>
8092      * <td>{@link #ACCOUNT_TYPE}</td>
8093      * <td>read/write-once</td>
8094      * <td>The type of account to which this row belongs, which when paired with
8095      * {@link #ACCOUNT_NAME} identifies a specific account.</td>
8096      * </tr>
8097      * <tr>
8098      * <td>int</td>
8099      * <td>{@link #SHOULD_SYNC}</td>
8100      * <td>read/write</td>
8101      * <td>Depending on the mode defined by the sync-adapter, this flag controls
8102      * the top-level sync behavior for this data source.</td>
8103      * </tr>
8104      * <tr>
8105      * <td>int</td>
8106      * <td>{@link #UNGROUPED_VISIBLE}</td>
8107      * <td>read/write</td>
8108      * <td>Flag indicating if contacts without any
8109      * {@link CommonDataKinds.GroupMembership} entries should be visible in any
8110      * user interface.</td>
8111      * </tr>
8112      * <tr>
8113      * <td>int</td>
8114      * <td>{@link #ANY_UNSYNCED}</td>
8115      * <td>read-only</td>
8116      * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
8117      * {@link Groups#SHOULD_SYNC} under this account have been marked as
8118      * unsynced.</td>
8119      * </tr>
8120      * <tr>
8121      * <td>int</td>
8122      * <td>{@link #UNGROUPED_COUNT}</td>
8123      * <td>read-only</td>
8124      * <td>Read-only count of {@link Contacts} from a specific source that have
8125      * no {@link CommonDataKinds.GroupMembership} entries.</td>
8126      * </tr>
8127      * <tr>
8128      * <td>int</td>
8129      * <td>{@link #UNGROUPED_WITH_PHONES}</td>
8130      * <td>read-only</td>
8131      * <td>Read-only count of {@link Contacts} from a specific source that have
8132      * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
8133      * numbers.</td>
8134      * </tr>
8135      * </table>
8136      */
8137     public static final class Settings implements SettingsColumns {
8138         /**
8139          * This utility class cannot be instantiated
8140          */
Settings()8141         private Settings() {
8142         }
8143 
8144         /**
8145          * The content:// style URI for this table
8146          */
8147         public static final Uri CONTENT_URI =
8148                 Uri.withAppendedPath(AUTHORITY_URI, "settings");
8149 
8150         /**
8151          * The MIME-type of {@link #CONTENT_URI} providing a directory of
8152          * settings.
8153          */
8154         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
8155 
8156         /**
8157          * The MIME-type of {@link #CONTENT_URI} providing a single setting.
8158          */
8159         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
8160     }
8161 
8162     /**
8163      * API for inquiring about the general status of the provider.
8164      */
8165     public static final class ProviderStatus {
8166 
8167         /**
8168          * Not instantiable.
8169          */
ProviderStatus()8170         private ProviderStatus() {
8171         }
8172 
8173         /**
8174          * The content:// style URI for this table.  Requests to this URI can be
8175          * performed on the UI thread because they are always unblocking.
8176          */
8177         public static final Uri CONTENT_URI =
8178                 Uri.withAppendedPath(AUTHORITY_URI, "provider_status");
8179 
8180         /**
8181          * The MIME-type of {@link #CONTENT_URI} providing a directory of
8182          * settings.
8183          */
8184         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status";
8185 
8186         /**
8187          * An integer representing the current status of the provider.
8188          */
8189         public static final String STATUS = "status";
8190 
8191         /**
8192          * Default status of the provider.
8193          */
8194         public static final int STATUS_NORMAL = 0;
8195 
8196         /**
8197          * The provider won't respond to queries. It is in the middle of a long running task, such
8198          * as a database upgrade or locale change.
8199          */
8200         public static final int STATUS_BUSY = 1;
8201 
8202         /**
8203          * The status that indicates that there are no accounts and no contacts
8204          * on the device.
8205          */
8206         public static final int STATUS_EMPTY = 2;
8207 
8208         /**
8209          * Timestamp (milliseconds since epoch) of when the provider's database was created.
8210          *
8211          * <P>Type: long
8212          */
8213         public static final String DATABASE_CREATION_TIMESTAMP = "database_creation_timestamp";
8214     }
8215 
8216     /**
8217      * <p>
8218      * API allowing applications to send usage information for each {@link Data} row to the
8219      * Contacts Provider.  Applications can also clear all usage information.
8220      * </p>
8221      * <p>
8222      * With the feedback, Contacts Provider may return more contextually appropriate results for
8223      * Data listing, typically supplied with
8224      * {@link ContactsContract.Contacts#CONTENT_FILTER_URI},
8225      * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI},
8226      * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit
8227      * from better ranked (sorted) lists in applications that show auto-complete list.
8228      * </p>
8229      * <p>
8230      * There is no guarantee for how this feedback is used, or even whether it is used at all.
8231      * The ranking algorithm will make best efforts to use the feedback data, but the exact
8232      * implementation, the storage data structures as well as the resulting sort order is device
8233      * and version specific and can change over time.
8234      * </p>
8235      * <p>
8236      * When updating usage information, users of this API need to use
8237      * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed
8238      * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as
8239      * its last path. They also need to append a query parameter to the Uri, to specify the type of
8240      * the communication, which enables the Contacts Provider to differentiate between kinds of
8241      * interactions using the same contact data field (for example a phone number can be used to
8242      * make phone calls or send SMS).
8243      * </p>
8244      * <p>
8245      * Selection and selectionArgs are ignored and must be set to null. To get data ids,
8246      * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)}
8247      * toward {@link Data#CONTENT_URI}.
8248      * </p>
8249      * <p>
8250      * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive
8251      * integer when successful, and returns 0 if no contact with that id was found.
8252      * </p>
8253      * <p>
8254      * Example:
8255      * <pre>
8256      * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
8257      *         .appendPath(TextUtils.join(",", dataIds))
8258      *         .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
8259      *                 DataUsageFeedback.USAGE_TYPE_CALL)
8260      *         .build();
8261      * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0;
8262      * </pre>
8263      * </p>
8264      * <p>
8265      * Applications can also clear all usage information with:
8266      * <pre>
8267      * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0;
8268      * </pre>
8269      * </p>
8270      */
8271     public static final class DataUsageFeedback {
8272 
8273         /**
8274          * The content:// style URI for sending usage feedback.
8275          * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}.
8276          */
8277         public static final Uri FEEDBACK_URI =
8278                 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback");
8279 
8280         /**
8281          * The content:// style URI for deleting all usage information.
8282          * Must be used with {@link ContentResolver#delete(Uri, String, String[])}.
8283          * The {@code where} and {@code selectionArgs} parameters are ignored.
8284          */
8285         public static final Uri DELETE_USAGE_URI =
8286                 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage");
8287 
8288         /**
8289          * <p>
8290          * Name for query parameter specifying the type of data usage.
8291          * </p>
8292          */
8293         public static final String USAGE_TYPE = "type";
8294 
8295         /**
8296          * <p>
8297          * Type of usage for voice interaction, which includes phone call, voice chat, and
8298          * video chat.
8299          * </p>
8300          */
8301         public static final String USAGE_TYPE_CALL = "call";
8302 
8303         /**
8304          * <p>
8305          * Type of usage for text interaction involving longer messages, which includes email.
8306          * </p>
8307          */
8308         public static final String USAGE_TYPE_LONG_TEXT = "long_text";
8309 
8310         /**
8311          * <p>
8312          * Type of usage for text interaction involving shorter messages, which includes SMS,
8313          * text chat with email addresses.
8314          * </p>
8315          */
8316         public static final String USAGE_TYPE_SHORT_TEXT = "short_text";
8317     }
8318 
8319     /**
8320      * <p>
8321      * Contact-specific information about whether or not a contact has been pinned by the user
8322      * at a particular position within the system contact application's user interface.
8323      * </p>
8324      *
8325      * <p>
8326      * This pinning information can be used by individual applications to customize how
8327      * they order particular pinned contacts. For example, a Dialer application could
8328      * use pinned information to order user-pinned contacts in a top row of favorites.
8329      * </p>
8330      *
8331      * <p>
8332      * It is possible for two or more contacts to occupy the same pinned position (due
8333      * to aggregation and sync), so this pinning information should be used on a best-effort
8334      * basis to order contacts in-application rather than an absolute guide on where a contact
8335      * should be positioned. Contacts returned by the ContactsProvider will not be ordered based
8336      * on this information, so it is up to the client application to reorder these contacts within
8337      * their own UI adhering to (or ignoring as appropriate) information stored in the pinned
8338      * column.
8339      * </p>
8340      *
8341      * <p>
8342      * By default, unpinned contacts will have a pinned position of
8343      * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive
8344      * integers that are greater than 1.
8345      * </p>
8346      */
8347     public static final class PinnedPositions {
8348         /**
8349          * The method to invoke in order to undemote a formerly demoted contact. The contact id of
8350          * the contact must be provided as an argument. If the contact was not previously demoted,
8351          * nothing will be done.
8352          * @hide
8353          */
8354         public static final String UNDEMOTE_METHOD = "undemote";
8355 
8356         /**
8357          * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing
8358          * will be done.
8359          *
8360          * @param contentResolver to perform the undemote operation on.
8361          * @param contactId the id of the contact to undemote.
8362          */
undemote(ContentResolver contentResolver, long contactId)8363         public static void undemote(ContentResolver contentResolver, long contactId) {
8364             contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD,
8365                     String.valueOf(contactId), null);
8366         }
8367 
8368         /**
8369          * Pins a contact at a provided position, or unpins a contact.
8370          *
8371          * @param contentResolver to perform the pinning operation on.
8372          * @param pinnedPosition the position to pin the contact at. To unpin a contact, use
8373          *         {@link PinnedPositions#UNPINNED}.
8374          */
pin( ContentResolver contentResolver, long contactId, int pinnedPosition)8375         public static void pin(
8376                 ContentResolver contentResolver, long contactId, int pinnedPosition) {
8377             final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId));
8378             final ContentValues values = new ContentValues();
8379             values.put(Contacts.PINNED, pinnedPosition);
8380             contentResolver.update(uri, values, null, null);
8381         }
8382 
8383         /**
8384          * Default value for the pinned position of an unpinned contact.
8385          */
8386         public static final int UNPINNED = 0;
8387 
8388         /**
8389          * Value of pinned position for a contact that a user has indicated should be considered
8390          * of the lowest priority. It is up to the client application to determine how to present
8391          * such a contact - for example all the way at the bottom of a contact list, or simply
8392          * just hidden from view.
8393          */
8394         public static final int DEMOTED = -1;
8395     }
8396 
8397     /**
8398      * Helper methods to display QuickContact dialogs that display all the information belonging to
8399      * a specific {@link Contacts} entry.
8400      */
8401     public static final class QuickContact {
8402         /**
8403          * Action used to launch the system contacts application and bring up a QuickContact dialog
8404          * for the provided {@link Contacts} entry.
8405          */
8406         @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
8407         public static final String ACTION_QUICK_CONTACT =
8408                 "android.provider.action.QUICK_CONTACT";
8409 
8410         /**
8411          * Extra used to specify pivot dialog location in screen coordinates.
8412          * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
8413          * @hide
8414          */
8415         @Deprecated
8416         public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT";
8417 
8418         /**
8419          * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts
8420          * will respect this extra's value.
8421          *
8422          * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
8423          */
8424         public static final String EXTRA_MODE = "android.provider.extra.MODE";
8425 
8426         /**
8427          * Extra used to specify which mimetype should be prioritized in the QuickContacts UI.
8428          * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can
8429          * cause phone numbers to be displayed more prominently in QuickContacts.
8430          */
8431         public static final String EXTRA_PRIORITIZED_MIMETYPE
8432                 = "android.provider.extra.PRIORITIZED_MIMETYPE";
8433 
8434         /**
8435          * Extra used to indicate a list of specific MIME-types to exclude and not display in the
8436          * QuickContacts dialog. Stored as a {@link String} array.
8437          */
8438         public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES";
8439 
8440         /**
8441          * Small QuickContact mode, usually presented with minimal actions.
8442          */
8443         public static final int MODE_SMALL = 1;
8444 
8445         /**
8446          * Medium QuickContact mode, includes actions and light summary describing
8447          * the {@link Contacts} entry being shown. This may include social
8448          * status and presence details.
8449          */
8450         public static final int MODE_MEDIUM = 2;
8451 
8452         /**
8453          * Large QuickContact mode, includes actions and larger, card-like summary
8454          * of the {@link Contacts} entry being shown. This may include detailed
8455          * information, such as a photo.
8456          */
8457         public static final int MODE_LARGE = 3;
8458 
8459         /** @hide */
8460         public static final int MODE_DEFAULT = MODE_LARGE;
8461 
8462         /**
8463          * Constructs the QuickContacts intent with a view's rect.
8464          * @hide
8465          */
composeQuickContactsIntent(Context context, View target, Uri lookupUri, int mode, String[] excludeMimes)8466         public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri,
8467                 int mode, String[] excludeMimes) {
8468             // Find location and bounds of target view, adjusting based on the
8469             // assumed local density.
8470             final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
8471             final int[] pos = new int[2];
8472             target.getLocationOnScreen(pos);
8473 
8474             final Rect rect = new Rect();
8475             rect.left = (int) (pos[0] * appScale + 0.5f);
8476             rect.top = (int) (pos[1] * appScale + 0.5f);
8477             rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
8478             rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
8479 
8480             return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes);
8481         }
8482 
8483         /**
8484          * Constructs the QuickContacts intent.
8485          * @hide
8486          */
composeQuickContactsIntent(Context context, Rect target, Uri lookupUri, int mode, String[] excludeMimes)8487         public static Intent composeQuickContactsIntent(Context context, Rect target,
8488                 Uri lookupUri, int mode, String[] excludeMimes) {
8489             // When launching from an Activiy, we don't want to start a new task, but otherwise
8490             // we *must* start a new task.  (Otherwise startActivity() would crash.)
8491             Context actualContext = context;
8492             while ((actualContext instanceof ContextWrapper)
8493                     && !(actualContext instanceof Activity)) {
8494                 actualContext = ((ContextWrapper) actualContext).getBaseContext();
8495             }
8496             final int intentFlags = ((actualContext instanceof Activity)
8497                     ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
8498                     // Workaround for b/16898764. Declaring singleTop in manifest doesn't work.
8499                     | Intent.FLAG_ACTIVITY_SINGLE_TOP;
8500 
8501             // Launch pivot dialog through intent for now
8502             final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
8503 
8504             // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync.
8505             intent.setData(lookupUri);
8506             intent.setSourceBounds(target);
8507             intent.putExtra(EXTRA_MODE, mode);
8508             intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
8509             return intent;
8510         }
8511 
8512         /**
8513          * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager
8514          * to strip off anything not necessary.
8515          *
8516          * @hide
8517          */
rebuildManagedQuickContactsIntent(String lookupKey, long contactId, boolean isContactIdIgnored, long directoryId, Intent originalIntent)8518         public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId,
8519                 boolean isContactIdIgnored, long directoryId, Intent originalIntent) {
8520             final Intent intent = new Intent(ACTION_QUICK_CONTACT);
8521             // Rebuild the URI from a lookup key and a contact ID.
8522             Uri uri = null;
8523             if (!TextUtils.isEmpty(lookupKey)) {
8524                 uri = isContactIdIgnored
8525                         ? Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey)
8526                         : Contacts.getLookupUri(contactId, lookupKey);
8527             }
8528             if (uri != null && directoryId != Directory.DEFAULT) {
8529                 uri = uri.buildUpon().appendQueryParameter(
8530                         ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build();
8531             }
8532             intent.setData(uri);
8533 
8534             // Copy flags and always set NEW_TASK because it won't have a parent activity.
8535             intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
8536 
8537             // Copy extras.
8538             intent.setSourceBounds(originalIntent.getSourceBounds());
8539             intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT));
8540             intent.putExtra(EXTRA_EXCLUDE_MIMES,
8541                     originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES));
8542             return intent;
8543         }
8544 
8545 
8546         /**
8547          * Trigger a dialog that lists the various methods of interacting with
8548          * the requested {@link Contacts} entry. This may be based on available
8549          * {@link ContactsContract.Data} rows under that contact, and may also
8550          * include social status and presence details.
8551          *
8552          * @param context The parent {@link Context} that may be used as the
8553          *            parent for this dialog.
8554          * @param target Specific {@link View} from your layout that this dialog
8555          *            should be centered around. In particular, if the dialog
8556          *            has a "callout" arrow, it will be pointed and centered
8557          *            around this {@link View}.
8558          * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
8559          *            {@link Uri} that describes a specific contact to feature
8560          *            in this dialog. A work lookup uri is supported here,
8561          *            see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
8562          *            {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
8563          * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8564          *            {@link #MODE_LARGE}, indicating the desired dialog size,
8565          *            when supported.
8566          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8567          *            to exclude when showing this dialog. For example, when
8568          *            already viewing the contact details card, this can be used
8569          *            to omit the details entry from the dialog.
8570          */
showQuickContact(Context context, View target, Uri lookupUri, int mode, String[] excludeMimes)8571         public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
8572                 String[] excludeMimes) {
8573             // Trigger with obtained rectangle
8574             Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8575                     excludeMimes);
8576             ContactsInternal.startQuickContactWithErrorToast(context, intent);
8577         }
8578 
8579         /**
8580          * Trigger a dialog that lists the various methods of interacting with
8581          * the requested {@link Contacts} entry. This may be based on available
8582          * {@link ContactsContract.Data} rows under that contact, and may also
8583          * include social status and presence details.
8584          *
8585          * @param context The parent {@link Context} that may be used as the
8586          *            parent for this dialog.
8587          * @param target Specific {@link Rect} that this dialog should be
8588          *            centered around, in screen coordinates. In particular, if
8589          *            the dialog has a "callout" arrow, it will be pointed and
8590          *            centered around this {@link Rect}. If you are running at a
8591          *            non-native density, you need to manually adjust using
8592          *            {@link DisplayMetrics#density} before calling.
8593          * @param lookupUri A
8594          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
8595          *            {@link Uri} that describes a specific contact to feature
8596          *            in this dialog. A work lookup uri is supported here,
8597          *            see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
8598          *            {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
8599          * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8600          *            {@link #MODE_LARGE}, indicating the desired dialog size,
8601          *            when supported.
8602          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8603          *            to exclude when showing this dialog. For example, when
8604          *            already viewing the contact details card, this can be used
8605          *            to omit the details entry from the dialog.
8606          */
showQuickContact(Context context, Rect target, Uri lookupUri, int mode, String[] excludeMimes)8607         public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
8608                 String[] excludeMimes) {
8609             Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8610                     excludeMimes);
8611             ContactsInternal.startQuickContactWithErrorToast(context, intent);
8612         }
8613 
8614         /**
8615          * Trigger a dialog that lists the various methods of interacting with
8616          * the requested {@link Contacts} entry. This may be based on available
8617          * {@link ContactsContract.Data} rows under that contact, and may also
8618          * include social status and presence details.
8619          *
8620          * @param context The parent {@link Context} that may be used as the
8621          *            parent for this dialog.
8622          * @param target Specific {@link View} from your layout that this dialog
8623          *            should be centered around. In particular, if the dialog
8624          *            has a "callout" arrow, it will be pointed and centered
8625          *            around this {@link View}.
8626          * @param lookupUri A
8627          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
8628          *            {@link Uri} that describes a specific contact to feature
8629          *            in this dialog. A work lookup uri is supported here,
8630          *            see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
8631          *            {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
8632          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8633          *            to exclude when showing this dialog. For example, when
8634          *            already viewing the contact details card, this can be used
8635          *            to omit the details entry from the dialog.
8636          * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI.
8637          *             For example, passing the value
8638          *             {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be
8639          *             displayed more prominently in QuickContacts.
8640          */
showQuickContact(Context context, View target, Uri lookupUri, String[] excludeMimes, String prioritizedMimeType)8641         public static void showQuickContact(Context context, View target, Uri lookupUri,
8642                 String[] excludeMimes, String prioritizedMimeType) {
8643             // Use MODE_LARGE instead of accepting mode as a parameter. The different mode
8644             // values defined in ContactsContract only affect very old implementations
8645             // of QuickContacts.
8646             Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
8647                     excludeMimes);
8648             intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
8649             ContactsInternal.startQuickContactWithErrorToast(context, intent);
8650         }
8651 
8652         /**
8653          * Trigger a dialog that lists the various methods of interacting with
8654          * the requested {@link Contacts} entry. This may be based on available
8655          * {@link ContactsContract.Data} rows under that contact, and may also
8656          * include social status and presence details.
8657          *
8658          * @param context The parent {@link Context} that may be used as the
8659          *            parent for this dialog.
8660          * @param target Specific {@link Rect} that this dialog should be
8661          *            centered around, in screen coordinates. In particular, if
8662          *            the dialog has a "callout" arrow, it will be pointed and
8663          *            centered around this {@link Rect}. If you are running at a
8664          *            non-native density, you need to manually adjust using
8665          *            {@link DisplayMetrics#density} before calling.
8666          * @param lookupUri A
8667          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
8668          *            {@link Uri} that describes a specific contact to feature
8669          *            in this dialog. A work lookup uri is supported here,
8670          *            see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
8671          *            {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
8672          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8673          *            to exclude when showing this dialog. For example, when
8674          *            already viewing the contact details card, this can be used
8675          *            to omit the details entry from the dialog.
8676          * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI.
8677          *             For example, passing the value
8678          *             {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be
8679          *             displayed more prominently in QuickContacts.
8680          */
showQuickContact(Context context, Rect target, Uri lookupUri, String[] excludeMimes, String prioritizedMimeType)8681         public static void showQuickContact(Context context, Rect target, Uri lookupUri,
8682                 String[] excludeMimes, String prioritizedMimeType) {
8683             // Use MODE_LARGE instead of accepting mode as a parameter. The different mode
8684             // values defined in ContactsContract only affect very old implementations
8685             // of QuickContacts.
8686             Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
8687                     excludeMimes);
8688             intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
8689             ContactsInternal.startQuickContactWithErrorToast(context, intent);
8690         }
8691     }
8692 
8693     /**
8694      * Helper class for accessing full-size photos by photo file ID.
8695      * <p>
8696      * Usage example:
8697      * <dl>
8698      * <dt>Retrieving a full-size photo by photo file ID (see
8699      * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID})
8700      * </dt>
8701      * <dd>
8702      * <pre>
8703      * public InputStream openDisplayPhoto(long photoFileId) {
8704      *     Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
8705      *     try {
8706      *         AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
8707      *             displayPhotoUri, "r");
8708      *         return fd.createInputStream();
8709      *     } catch (IOException e) {
8710      *         return null;
8711      *     }
8712      * }
8713      * </pre>
8714      * </dd>
8715      * </dl>
8716      * </p>
8717      */
8718     public static final class DisplayPhoto {
8719         /**
8720          * no public constructor since this is a utility class
8721          */
DisplayPhoto()8722         private DisplayPhoto() {}
8723 
8724         /**
8725          * The content:// style URI for this class, which allows access to full-size photos,
8726          * given a key.
8727          */
8728         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo");
8729 
8730         /**
8731          * This URI allows the caller to query for the maximum dimensions of a display photo
8732          * or thumbnail.  Requests to this URI can be performed on the UI thread because
8733          * they are always unblocking.
8734          */
8735         public static final Uri CONTENT_MAX_DIMENSIONS_URI =
8736                 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions");
8737 
8738         /**
8739          * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8740          * contain this column, populated with the maximum height and width (in pixels)
8741          * that will be stored for a display photo.  Larger photos will be down-sized to
8742          * fit within a square of this many pixels.
8743          */
8744         public static final String DISPLAY_MAX_DIM = "display_max_dim";
8745 
8746         /**
8747          * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8748          * contain this column, populated with the height and width (in pixels) for photo
8749          * thumbnails.
8750          */
8751         public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim";
8752     }
8753 
8754     /**
8755      * Contains helper classes used to create or manage {@link android.content.Intent Intents}
8756      * that involve contacts.
8757      */
8758     public static final class Intents {
8759         /**
8760          * This is the intent that is fired when a search suggestion is clicked on.
8761          */
8762         public static final String SEARCH_SUGGESTION_CLICKED =
8763                 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
8764 
8765         /**
8766          * This is the intent that is fired when a search suggestion for dialing a number
8767          * is clicked on.
8768          */
8769         public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
8770                 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
8771 
8772         /**
8773          * This is the intent that is fired when a search suggestion for creating a contact
8774          * is clicked on.
8775          */
8776         public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
8777                 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
8778 
8779         /**
8780          * This is the intent that is fired when the contacts database is created. <p> The
8781          * READ_CONTACT permission is required to receive these broadcasts.
8782          *
8783          * <p>Because this is an implicit broadcast, apps targeting Android O will no longer
8784          * receive this broadcast via a manifest broadcast receiver.  (Broadcast receivers
8785          * registered at runtime with
8786          * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)} will still receive it.)
8787          * Instead, an app can use {@link ProviderStatus#DATABASE_CREATION_TIMESTAMP} to see if the
8788          * contacts database has been initialized when it starts.
8789          */
8790         public static final String CONTACTS_DATABASE_CREATED =
8791                 "android.provider.Contacts.DATABASE_CREATED";
8792 
8793         /**
8794          * Starts an Activity that lets the user pick a contact to attach an image to.
8795          * After picking the contact it launches the image cropper in face detection mode.
8796          */
8797         public static final String ATTACH_IMAGE =
8798                 "com.android.contacts.action.ATTACH_IMAGE";
8799 
8800         /**
8801          * This is the intent that is fired when the user clicks the "invite to the network" button
8802          * on a contact.  Only sent to an activity which is explicitly registered by a contact
8803          * provider which supports the "invite to the network" feature.
8804          * <p>
8805          * {@link Intent#getData()} contains the lookup URI for the contact.
8806          */
8807         public static final String INVITE_CONTACT =
8808                 "com.android.contacts.action.INVITE_CONTACT";
8809 
8810         /**
8811          * Takes as input a data URI with a mailto: or tel: scheme. If a single
8812          * contact exists with the given data it will be shown. If no contact
8813          * exists, a dialog will ask the user if they want to create a new
8814          * contact with the provided details filled in. If multiple contacts
8815          * share the data the user will be prompted to pick which contact they
8816          * want to view.
8817          * <p>
8818          * For <code>mailto:</code> URIs, the scheme specific portion must be a
8819          * raw email address, such as one built using
8820          * {@link Uri#fromParts(String, String, String)}.
8821          * <p>
8822          * For <code>tel:</code> URIs, the scheme specific portion is compared
8823          * to existing numbers using the standard caller ID lookup algorithm.
8824          * The number must be properly encoded, for example using
8825          * {@link Uri#fromParts(String, String, String)}.
8826          * <p>
8827          * Any extras from the {@link Insert} class will be passed along to the
8828          * create activity if there are no contacts to show.
8829          * <p>
8830          * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
8831          * prompting the user when the contact doesn't exist.
8832          */
8833         public static final String SHOW_OR_CREATE_CONTACT =
8834                 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
8835 
8836         /**
8837          * Activity Action: Initiate a message to someone by voice. The message could be text,
8838          * audio, video or image(photo). This action supports messaging with a specific contact
8839          * regardless of the underlying messaging protocol used.
8840          * <p>
8841          * The action could be originated from the Voice Assistant as a voice interaction. In such
8842          * case, a receiving activity that supports {@link android.content.Intent#CATEGORY_VOICE}
8843          * could check return value of {@link android.app.Activity#isVoiceInteractionRoot} before
8844          * proceeding. By doing this check the activity verifies that the action indeed was
8845          * initiated by Voice Assistant and could send a message right away, without any further
8846          * input from the user. This allows for a smooth user experience when sending a message by
8847          * voice. Note: this activity must also support the {@link
8848          * android.content.Intent#CATEGORY_DEFAULT} so it can be found by {@link
8849          * android.service.voice.VoiceInteractionSession#startVoiceActivity}.
8850          * <p>
8851          * When the action was not initiated by Voice Assistant or when the receiving activity does
8852          * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity must confirm
8853          * with the user before sending the message (because in this case it is unknown which app
8854          * sent the intent, it could be malicious).
8855          * <p>
8856          * To allow the Voice Assistant to help users with contacts disambiguation, the messaging
8857          * app may choose to integrate with the Contacts Provider. You will need to specify a new
8858          * MIME type in order to store your app’s unique contact IDs and optional human readable
8859          * labels in the Data table. The Voice Assistant needs to know this MIME type and {@link
8860          * RawContacts#ACCOUNT_TYPE} that you are using in order to provide the smooth contact
8861          * disambiguation user experience. The following convention should be met when performing
8862          * such integration:
8863          * <ul>
8864          * <li>This activity should have a string meta-data field associated with it, {@link
8865          * #METADATA_ACCOUNT_TYPE}, which defines {@link RawContacts#ACCOUNT_TYPE} for your Contacts
8866          * Provider implementation. The account type should be globally unique, for example you can
8867          * use your app package name as the account type.</li>
8868          * <li>This activity should have a string meta-data field associated with it, {@link
8869          * #METADATA_MIMETYPE}, which defines {@link DataColumns#MIMETYPE} for your Contacts
8870          * Provider implementation. For example, you can use
8871          * "vnd.android.cursor.item/vnd.{$app_package_name}.profile" as MIME type.</li>
8872          * <li>When filling Data table row for METADATA_MIMETYPE, column {@link DataColumns#DATA1}
8873          * should store the unique contact ID as understood by the app. This value will be used in
8874          * the {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID}.</li>
8875          * <li>Optionally, when filling Data table row for METADATA_MIMETYPE, column {@link
8876          * DataColumns#DATA3} could store a human readable label for the ID. For example it could be
8877          * phone number or human readable username/user_id like "a_super_cool_user_name". This label
8878          * may be shown below the Contact Name by the Voice Assistant as the user completes the
8879          * voice action. If DATA3 is empty, the ID in DATA1 may be shown instead.</li>
8880          * <li><em>Note: Do not use DATA3 to store the Contact Name. The Voice Assistant will
8881          * already get the Contact Name from the RawContact’s display_name.</em></li>
8882          * <li><em>Note: Some apps may choose to use phone number as the unique contact ID in DATA1.
8883          * If this applies to you and you’d like phone number to be shown below the Contact Name by
8884          * the Voice Assistant, then you may choose to leave DATA3 empty.</em></li>
8885          * <li><em>Note: If your app also uses DATA3 to display contact details in the Contacts App,
8886          * make sure it does not include prefix text such as "Message +<phone>" or "Free Message
8887          * +<phone>", etc. If you must show the prefix text in the Contacts App, please use a
8888          * different DATA# column, and update your contacts.xml to point to this new column. </em>
8889          * </li>
8890          * <li>Everytime the user sends a message to a contact, your app may choose to update the
8891          * {@link ContactOptionsColumns#TIMES_CONTACTED} entry through DataUsageFeedback class.
8892          * Doing this will allow Voice Assistant to bias speech recognition to contacts frequently
8893          * contacted, this is particularly useful for contact names that are hard to pronounce.</li>
8894          * </ul>
8895          * If the app chooses not to integrate with the Contacts Provider (in particular, when
8896          * either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant
8897          * will use existing phone number entries as contact ID's for such app.
8898          * <p>
8899          * Input: {@link android.content.Intent#getType} is the MIME type of the data being sent.
8900          * The intent sender will always put the concrete mime type in the intent type, like
8901          * "text/plain" or "audio/wav" for example. If the MIME type is "text/plain", message to
8902          * sent will be provided via {@link android.content.Intent#EXTRA_TEXT} as a styled
8903          * CharSequence. Otherwise, the message content will be supplied through {@link
8904          * android.content.Intent#setClipData(ClipData)} as a content provider URI(s). In the latter
8905          * case, EXTRA_TEXT could still be supplied optionally; for example, for audio messages
8906          * ClipData will contain URI of a recording and EXTRA_TEXT could contain the text
8907          * transcription of this recording.
8908          * <p>
8909          * The message can have n recipients. The n-th recipient of the message will be provided as
8910          * n-th elements of {@link #EXTRA_RECIPIENT_CONTACT_URI}, {@link
8911          * #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and {@link #EXTRA_RECIPIENT_CONTACT_NAME} (as a
8912          * consequence, EXTRA_RECIPIENT_CONTACT_URI, EXTRA_RECIPIENT_CONTACT_CHAT_ID and
8913          * EXTRA_RECIPIENT_CONTACT_NAME should all be of length n). If neither of these 3 elements
8914          * is provided (e.g. all 3 are null) for the recipient or if the information provided is
8915          * ambiguous then the activity should prompt the user for the recipient to send the message
8916          * to.
8917          * <p>
8918          * Output: nothing
8919          *
8920          * @see #EXTRA_RECIPIENT_CONTACT_URI
8921          * @see #EXTRA_RECIPIENT_CONTACT_CHAT_ID
8922          * @see #EXTRA_RECIPIENT_CONTACT_NAME
8923          * @see #METADATA_ACCOUNT_TYPE
8924          * @see #METADATA_MIMETYPE
8925          */
8926         @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
8927         public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS =
8928                 "android.provider.action.VOICE_SEND_MESSAGE_TO_CONTACTS";
8929 
8930         /**
8931          * This extra specifies a content provider uri(s) for the contact(s) (if the contacts were
8932          * located in the Contacts Provider), used with {@link
8933          * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this
8934          * extra is a {@code String[]}. The number of elements in the array should be equal to
8935          * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and
8936          * {@link #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular
8937          * recipient is absent, it will be set to null.
8938          * <p>
8939          * <em>Note: one contact may have multiple accounts (e.g. Chat IDs) on a specific messaging
8940          * platform, so this may be ambiguous. E.g., one contact “John Smith” could have two
8941          * accounts on the same messaging app.</em>
8942          * <p>
8943          * <em>Example value: {"content://com.android.contacts/contacts/16"}</em>
8944          */
8945         public static final String EXTRA_RECIPIENT_CONTACT_URI =
8946                 "android.provider.extra.RECIPIENT_CONTACT_URI";
8947 
8948         /**
8949          * This extra specifies a messaging app’s unique ID(s) for the contact(s), used with {@link
8950          * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this
8951          * extra is a {@code String[]}. The number of elements in the array should be equal to
8952          * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link
8953          * #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular
8954          * recipient is absent, it will be set to null.
8955          * <p>
8956          * The value of the elements comes from the {@link DataColumns#DATA1} column in Contacts
8957          * Provider with {@link DataColumns#MIMETYPE} from {@link #METADATA_MIMETYPE} (if both
8958          * {@link #METADATA_ACCOUNT_TYPE} and {@link #METADATA_MIMETYPE} are specified by the app;
8959          * otherwise, the value will be a phone number), and should be the unambiguous contact
8960          * endpoint. This value is app-specific, it could be some proprietary ID or a phone number.
8961          */
8962         public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID =
8963                 "android.provider.extra.RECIPIENT_CONTACT_CHAT_ID";
8964 
8965         /**
8966          * This extra specifies the contact name (full name from the Contacts Provider), used with
8967          * {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient. The value of this
8968          * extra is a {@code String[]}. The number of elements in the array should be equal to
8969          * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link
8970          * #EXTRA_RECIPIENT_CONTACT_CHAT_ID}). When the value of the element for the particular
8971          * recipient is absent, it will be set to null.
8972          * <p>
8973          * The value of the elements comes from RawContact's display_name column.
8974          * <p>
8975          * <em>Example value: {"Jane Doe"}</em>
8976          */
8977         public static final String EXTRA_RECIPIENT_CONTACT_NAME =
8978                 "android.provider.extra.RECIPIENT_CONTACT_NAME";
8979 
8980         /**
8981          * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity
8982          * describing {@link RawContacts#ACCOUNT_TYPE} for the corresponding Contacts Provider
8983          * implementation.
8984          */
8985         public static final String METADATA_ACCOUNT_TYPE = "android.provider.account_type";
8986 
8987         /**
8988          * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity
8989          * describing {@link DataColumns#MIMETYPE} for the corresponding Contacts Provider
8990          * implementation.
8991          */
8992         public static final String METADATA_MIMETYPE = "android.provider.mimetype";
8993 
8994         /**
8995          * Starts an Activity that lets the user select the multiple phones from a
8996          * list of phone numbers which come from the contacts or
8997          * {@link #EXTRA_PHONE_URIS}.
8998          * <p>
8999          * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS}
9000          * could belong to the contacts or not, and will be selected by default.
9001          * <p>
9002          * The user's selection will be returned from
9003          * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
9004          * if the resultCode is
9005          * {@link android.app.Activity#RESULT_OK}, the array of picked phone
9006          * numbers are in the Intent's
9007          * {@link #EXTRA_PHONE_URIS}; otherwise, the
9008          * {@link android.app.Activity#RESULT_CANCELED} is returned if the user
9009          * left the Activity without changing the selection.
9010          *
9011          * @hide
9012          */
9013         public static final String ACTION_GET_MULTIPLE_PHONES =
9014                 "com.android.contacts.action.GET_MULTIPLE_PHONES";
9015 
9016         /**
9017          * A broadcast action which is sent when any change has been made to the profile, such
9018          * as the profile name or the picture.  A receiver must have
9019          * the android.permission.READ_PROFILE permission.
9020          *
9021          * @hide
9022          */
9023         public static final String ACTION_PROFILE_CHANGED =
9024                 "android.provider.Contacts.PROFILE_CHANGED";
9025 
9026         /**
9027          * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
9028          * contact if no matching contact found. Otherwise, default behavior is
9029          * to prompt user with dialog before creating.
9030          * <p>
9031          * Type: BOOLEAN
9032          */
9033         public static final String EXTRA_FORCE_CREATE =
9034                 "com.android.contacts.action.FORCE_CREATE";
9035 
9036         /**
9037          * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
9038          * description to be shown when prompting user about creating a new
9039          * contact.
9040          * <p>
9041          * Type: STRING
9042          */
9043         public static final String EXTRA_CREATE_DESCRIPTION =
9044             "com.android.contacts.action.CREATE_DESCRIPTION";
9045 
9046         /**
9047          * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value.
9048          * <p>
9049          * The phone numbers want to be picked by default should be passed in as
9050          * input value. These phone numbers could belong to the contacts or not.
9051          * <p>
9052          * The phone numbers which were picked by the user are returned as output
9053          * value.
9054          * <p>
9055          * Type: array of URIs, the tel URI is used for the phone numbers which don't
9056          * belong to any contact, the content URI is used for phone id in contacts.
9057          *
9058          * @hide
9059          */
9060         public static final String EXTRA_PHONE_URIS =
9061             "com.android.contacts.extra.PHONE_URIS";
9062 
9063         /**
9064          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
9065          * dialog location using screen coordinates. When not specified, the
9066          * dialog will be centered.
9067          *
9068          * @hide
9069          */
9070         @Deprecated
9071         public static final String EXTRA_TARGET_RECT = "target_rect";
9072 
9073         /**
9074          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
9075          * desired dialog style, usually a variation on size. One of
9076          * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
9077          *
9078          * @hide
9079          */
9080         @Deprecated
9081         public static final String EXTRA_MODE = "mode";
9082 
9083         /**
9084          * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
9085          *
9086          * @hide
9087          */
9088         @Deprecated
9089         public static final int MODE_SMALL = 1;
9090 
9091         /**
9092          * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
9093          *
9094          * @hide
9095          */
9096         @Deprecated
9097         public static final int MODE_MEDIUM = 2;
9098 
9099         /**
9100          * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
9101          *
9102          * @hide
9103          */
9104         @Deprecated
9105         public static final int MODE_LARGE = 3;
9106 
9107         /**
9108          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
9109          * a list of specific MIME-types to exclude and not display. Stored as a
9110          * {@link String} array.
9111          *
9112          * @hide
9113          */
9114         @Deprecated
9115         public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
9116 
9117         /**
9118          * Convenience class that contains string constants used
9119          * to create contact {@link android.content.Intent Intents}.
9120          */
9121         public static final class Insert {
9122             /** The action code to use when adding a contact */
9123             public static final String ACTION = Intent.ACTION_INSERT;
9124 
9125             /**
9126              * If present, forces a bypass of quick insert mode.
9127              */
9128             public static final String FULL_MODE = "full_mode";
9129 
9130             /**
9131              * The extra field for the contact name.
9132              * <P>Type: String</P>
9133              */
9134             public static final String NAME = "name";
9135 
9136             // TODO add structured name values here.
9137 
9138             /**
9139              * The extra field for the contact phonetic name.
9140              * <P>Type: String</P>
9141              */
9142             public static final String PHONETIC_NAME = "phonetic_name";
9143 
9144             /**
9145              * The extra field for the contact company.
9146              * <P>Type: String</P>
9147              */
9148             public static final String COMPANY = "company";
9149 
9150             /**
9151              * The extra field for the contact job title.
9152              * <P>Type: String</P>
9153              */
9154             public static final String JOB_TITLE = "job_title";
9155 
9156             /**
9157              * The extra field for the contact notes.
9158              * <P>Type: String</P>
9159              */
9160             public static final String NOTES = "notes";
9161 
9162             /**
9163              * The extra field for the contact phone number.
9164              * <P>Type: String</P>
9165              */
9166             public static final String PHONE = "phone";
9167 
9168             /**
9169              * The extra field for the contact phone number type.
9170              * <P>Type: Either an integer value from
9171              * {@link CommonDataKinds.Phone},
9172              *  or a string specifying a custom label.</P>
9173              */
9174             public static final String PHONE_TYPE = "phone_type";
9175 
9176             /**
9177              * The extra field for the phone isprimary flag.
9178              * <P>Type: boolean</P>
9179              */
9180             public static final String PHONE_ISPRIMARY = "phone_isprimary";
9181 
9182             /**
9183              * The extra field for an optional second contact phone number.
9184              * <P>Type: String</P>
9185              */
9186             public static final String SECONDARY_PHONE = "secondary_phone";
9187 
9188             /**
9189              * The extra field for an optional second contact phone number type.
9190              * <P>Type: Either an integer value from
9191              * {@link CommonDataKinds.Phone},
9192              *  or a string specifying a custom label.</P>
9193              */
9194             public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
9195 
9196             /**
9197              * The extra field for an optional third contact phone number.
9198              * <P>Type: String</P>
9199              */
9200             public static final String TERTIARY_PHONE = "tertiary_phone";
9201 
9202             /**
9203              * The extra field for an optional third contact phone number type.
9204              * <P>Type: Either an integer value from
9205              * {@link CommonDataKinds.Phone},
9206              *  or a string specifying a custom label.</P>
9207              */
9208             public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
9209 
9210             /**
9211              * The extra field for the contact email address.
9212              * <P>Type: String</P>
9213              */
9214             public static final String EMAIL = "email";
9215 
9216             /**
9217              * The extra field for the contact email type.
9218              * <P>Type: Either an integer value from
9219              * {@link CommonDataKinds.Email}
9220              *  or a string specifying a custom label.</P>
9221              */
9222             public static final String EMAIL_TYPE = "email_type";
9223 
9224             /**
9225              * The extra field for the email isprimary flag.
9226              * <P>Type: boolean</P>
9227              */
9228             public static final String EMAIL_ISPRIMARY = "email_isprimary";
9229 
9230             /**
9231              * The extra field for an optional second contact email address.
9232              * <P>Type: String</P>
9233              */
9234             public static final String SECONDARY_EMAIL = "secondary_email";
9235 
9236             /**
9237              * The extra field for an optional second contact email type.
9238              * <P>Type: Either an integer value from
9239              * {@link CommonDataKinds.Email}
9240              *  or a string specifying a custom label.</P>
9241              */
9242             public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
9243 
9244             /**
9245              * The extra field for an optional third contact email address.
9246              * <P>Type: String</P>
9247              */
9248             public static final String TERTIARY_EMAIL = "tertiary_email";
9249 
9250             /**
9251              * The extra field for an optional third contact email type.
9252              * <P>Type: Either an integer value from
9253              * {@link CommonDataKinds.Email}
9254              *  or a string specifying a custom label.</P>
9255              */
9256             public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
9257 
9258             /**
9259              * The extra field for the contact postal address.
9260              * <P>Type: String</P>
9261              */
9262             public static final String POSTAL = "postal";
9263 
9264             /**
9265              * The extra field for the contact postal address type.
9266              * <P>Type: Either an integer value from
9267              * {@link CommonDataKinds.StructuredPostal}
9268              *  or a string specifying a custom label.</P>
9269              */
9270             public static final String POSTAL_TYPE = "postal_type";
9271 
9272             /**
9273              * The extra field for the postal isprimary flag.
9274              * <P>Type: boolean</P>
9275              */
9276             public static final String POSTAL_ISPRIMARY = "postal_isprimary";
9277 
9278             /**
9279              * The extra field for an IM handle.
9280              * <P>Type: String</P>
9281              */
9282             public static final String IM_HANDLE = "im_handle";
9283 
9284             /**
9285              * The extra field for the IM protocol
9286              */
9287             public static final String IM_PROTOCOL = "im_protocol";
9288 
9289             /**
9290              * The extra field for the IM isprimary flag.
9291              * <P>Type: boolean</P>
9292              */
9293             public static final String IM_ISPRIMARY = "im_isprimary";
9294 
9295             /**
9296              * The extra field that allows the client to supply multiple rows of
9297              * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT}
9298              * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of
9299              * {@link ContentValues}, one per data row. Supplying this extra is
9300              * similar to inserting multiple rows into the {@link Data} table,
9301              * except the user gets a chance to see and edit them before saving.
9302              * Each ContentValues object must have a value for {@link Data#MIMETYPE}.
9303              * If supplied values are not visible in the editor UI, they will be
9304              * dropped.  Duplicate data will dropped.  Some fields
9305              * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically
9306              * adjusted to comply with the constraints of the specific account type.
9307              * For example, an Exchange contact can only have one phone numbers of type Home,
9308              * so the contact editor may choose a different type for this phone number to
9309              * avoid dropping the valueable part of the row, which is the phone number.
9310              * <p>
9311              * Example:
9312              * <pre>
9313              *  ArrayList&lt;ContentValues&gt; data = new ArrayList&lt;ContentValues&gt;();
9314              *
9315              *  ContentValues row1 = new ContentValues();
9316              *  row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE);
9317              *  row1.put(Organization.COMPANY, "Android");
9318              *  data.add(row1);
9319              *
9320              *  ContentValues row2 = new ContentValues();
9321              *  row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
9322              *  row2.put(Email.TYPE, Email.TYPE_CUSTOM);
9323              *  row2.put(Email.LABEL, "Green Bot");
9324              *  row2.put(Email.ADDRESS, "android@android.com");
9325              *  data.add(row2);
9326              *
9327              *  Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
9328              *  intent.putParcelableArrayListExtra(Insert.DATA, data);
9329              *
9330              *  startActivity(intent);
9331              * </pre>
9332              */
9333             public static final String DATA = "data";
9334 
9335             /**
9336              * Used to specify the account in which to create the new contact.
9337              * <p>
9338              * If this value is not provided, the user is presented with a disambiguation
9339              * dialog to chose an account
9340              * <p>
9341              * Type: {@link Account}
9342              */
9343             public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT";
9344 
9345             /**
9346              * Used to specify the data set within the account in which to create the
9347              * new contact.
9348              * <p>
9349              * This value is optional - if it is not specified, the contact will be
9350              * created in the base account, with no data set.
9351              * <p>
9352              * Type: String
9353              */
9354             public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET";
9355         }
9356     }
9357 
9358     /**
9359      * @hide
9360      */
9361     @SystemApi
9362     protected interface MetadataSyncColumns {
9363 
9364         /**
9365          * The raw contact backup id.
9366          * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the
9367          * persistent unique id for each raw contact within its source system.
9368          */
9369         public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id";
9370 
9371         /**
9372          * The account type to which the raw_contact of this item is associated. See
9373          * {@link RawContacts#ACCOUNT_TYPE}
9374          */
9375         public static final String ACCOUNT_TYPE = "account_type";
9376 
9377         /**
9378          * The account name to which the raw_contact of this item is associated. See
9379          * {@link RawContacts#ACCOUNT_NAME}
9380          */
9381         public static final String ACCOUNT_NAME = "account_name";
9382 
9383         /**
9384          * The data set within the account that the raw_contact of this row belongs to. This allows
9385          * multiple sync adapters for the same account type to distinguish between
9386          * each others' data.
9387          * {@link RawContacts#DATA_SET}
9388          */
9389         public static final String DATA_SET = "data_set";
9390 
9391         /**
9392          * A text column contains the Json string got from People API. The Json string contains
9393          * all the metadata related to the raw contact, i.e., all the data fields and
9394          * aggregation exceptions.
9395          *
9396          * Here is an example of the Json string got from the actual schema.
9397          * <pre>
9398          *     {
9399          *       "unique_contact_id": {
9400          *         "account_type": "CUSTOM_ACCOUNT",
9401          *         "custom_account_type": "facebook",
9402          *         "account_name": "android-test",
9403          *         "contact_id": "1111111",
9404          *         "data_set": "FOCUS"
9405          *       },
9406          *       "contact_prefs": {
9407          *         "send_to_voicemail": true,
9408          *         "starred": false,
9409          *         "pinned": 2
9410          *       },
9411          *       "aggregation_data": [
9412          *         {
9413          *           "type": "TOGETHER",
9414          *           "contact_ids": [
9415          *             {
9416          *               "account_type": "GOOGLE_ACCOUNT",
9417          *               "account_name": "android-test2",
9418          *               "contact_id": "2222222",
9419          *               "data_set": "GOOGLE_PLUS"
9420          *             },
9421          *             {
9422          *               "account_type": "GOOGLE_ACCOUNT",
9423          *               "account_name": "android-test3",
9424          *               "contact_id": "3333333",
9425          *               "data_set": "CUSTOM",
9426          *               "custom_data_set": "custom type"
9427          *             }
9428          *           ]
9429          *         }
9430          *       ],
9431          *       "field_data": [
9432          *         {
9433          *           "field_data_id": "1001",
9434          *           "field_data_prefs": {
9435          *             "is_primary": true,
9436          *             "is_super_primary": true
9437          *           },
9438          *           "usage_stats": [
9439          *             {
9440          *               "usage_type": "CALL",
9441          *               "last_time_used": 10000001,
9442          *               "usage_count": 10
9443          *             }
9444          *           ]
9445          *         }
9446          *       ]
9447          *     }
9448          * </pre>
9449          */
9450         public static final String DATA = "data";
9451 
9452         /**
9453          * The "deleted" flag: "0" by default, "1" if the row has been marked
9454          * for deletion. When {@link android.content.ContentResolver#delete} is
9455          * called on a raw contact, updating MetadataSync table to set the flag of the raw contact
9456          * as "1", then metadata sync adapter deletes the raw contact metadata on the server.
9457          * <P>Type: INTEGER</P>
9458          */
9459         public static final String DELETED = "deleted";
9460     }
9461 
9462     /**
9463      * Constants for the metadata sync table. This table is used to cache the metadata_sync data
9464      * from server before it is merged into other CP2 tables.
9465      *
9466      * @hide
9467      */
9468     @SystemApi
9469     public static final class MetadataSync implements BaseColumns, MetadataSyncColumns {
9470 
9471         /** The authority for the contacts metadata */
9472         public static final String METADATA_AUTHORITY = "com.android.contacts.metadata";
9473 
9474         /** A content:// style uri to the authority for the contacts metadata */
9475         public static final Uri METADATA_AUTHORITY_URI = Uri.parse(
9476                 "content://" + METADATA_AUTHORITY);
9477 
9478         /**
9479          * This utility class cannot be instantiated
9480          */
MetadataSync()9481         private MetadataSync() {
9482         }
9483 
9484         /**
9485          * The content:// style URI for this table.
9486          */
9487         public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI,
9488                 "metadata_sync");
9489 
9490         /**
9491          * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata
9492          */
9493         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata";
9494 
9495         /**
9496          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata.
9497          */
9498         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata";
9499     }
9500 
9501     /**
9502      * @hide
9503      */
9504     @SystemApi
9505     protected interface MetadataSyncStateColumns {
9506 
9507         /**
9508          * A reference to the name of the account to which this state belongs
9509          * <P>Type: STRING</P>
9510          */
9511         public static final String ACCOUNT_TYPE = "account_type";
9512 
9513         /**
9514          * A reference to the type of the account to which this state belongs
9515          * <P>Type: STRING</P>
9516          */
9517         public static final String ACCOUNT_NAME = "account_name";
9518 
9519         /**
9520          * A reference to the data set within the account to which this state belongs
9521          * <P>Type: STRING</P>
9522          */
9523         public static final String DATA_SET = "data_set";
9524 
9525         /**
9526          * The sync state associated with this account.
9527          * <P>Type: Blob</P>
9528          */
9529         public static final String STATE = "state";
9530     }
9531 
9532     /**
9533      * Constants for the metadata_sync_state table. This table is used to store the metadata
9534      * sync state for a set of accounts.
9535      *
9536      * @hide
9537      */
9538     @SystemApi
9539     public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns {
9540 
9541         /**
9542          * This utility class cannot be instantiated
9543          */
MetadataSyncState()9544         private MetadataSyncState() {
9545         }
9546 
9547         /**
9548          * The content:// style URI for this table.
9549          */
9550         public static final Uri CONTENT_URI =
9551                 Uri.withAppendedPath(MetadataSync.METADATA_AUTHORITY_URI, "metadata_sync_state");
9552 
9553         /**
9554          * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata sync
9555          * states.
9556          */
9557         public static final String CONTENT_TYPE =
9558                 "vnd.android.cursor.dir/contact_metadata_sync_state";
9559 
9560         /**
9561          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata sync
9562          * state.
9563          */
9564         public static final String CONTENT_ITEM_TYPE =
9565                 "vnd.android.cursor.item/contact_metadata_sync_state";
9566     }
9567 }
9568