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