ContactsContract.java revision 53de90462b1f9b5390a80d5ff6a1522293e1b3d6
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.content.ContentProviderClient;
21import android.content.ContentProviderOperation;
22import android.content.ContentResolver;
23import android.content.ContentUris;
24import android.content.ContentValues;
25import android.content.Context;
26import android.content.CursorEntityIterator;
27import android.content.Entity;
28import android.content.EntityIterator;
29import android.content.Intent;
30import android.content.res.Resources;
31import android.database.Cursor;
32import android.database.DatabaseUtils;
33import android.database.sqlite.SQLiteException;
34import android.graphics.Rect;
35import android.net.Uri;
36import android.os.RemoteException;
37import android.text.TextUtils;
38import android.util.DisplayMetrics;
39import android.util.Pair;
40import android.view.View;
41
42import java.io.ByteArrayInputStream;
43import java.io.InputStream;
44
45/**
46 * <p>
47 * The contract between the contacts provider and applications. Contains
48 * definitions for the supported URIs and columns. These APIs supersede
49 * {@link Contacts}.
50 * </p>
51 * <h3>Overview</h3>
52 * <p>
53 * ContactsContract defines an extensible database of contact-related
54 * information. Contact information is stored in a three-tier data model:
55 * </p>
56 * <ul>
57 * <li>
58 * A row in the {@link Data} table can store any kind of personal data, such
59 * as a phone number or email addresses.  The set of data kinds that can be
60 * stored in this table is open-ended. There is a predefined set of common
61 * kinds, but any application can add its own data kinds.
62 * </li>
63 * <li>
64 * A row in the {@link RawContacts} table represents a set of data describing a
65 * person and associated with a single account (for example, one of the user's
66 * Gmail accounts).
67 * </li>
68 * <li>
69 * A row in the {@link Contacts} table represents an aggregate of one or more
70 * RawContacts presumably describing the same person.  When data in or associated with
71 * the RawContacts table is changed, the affected aggregate contacts are updated as
72 * necessary.
73 * </li>
74 * </ul>
75 * <p>
76 * Other tables include:
77 * </p>
78 * <ul>
79 * <li>
80 * {@link Groups}, which contains information about raw contact groups
81 * such as Gmail contact groups.  The
82 * current API does not support the notion of groups spanning multiple accounts.
83 * </li>
84 * <li>
85 * {@link StatusUpdates}, which contains social status updates including IM
86 * availability.
87 * </li>
88 * <li>
89 * {@link AggregationExceptions}, which is used for manual aggregation and
90 * disaggregation of raw contacts
91 * </li>
92 * <li>
93 * {@link Settings}, which contains visibility and sync settings for accounts
94 * and groups.
95 * </li>
96 * <li>
97 * {@link SyncState}, which contains free-form data maintained on behalf of sync
98 * adapters
99 * </li>
100 * <li>
101 * {@link PhoneLookup}, which is used for quick caller-ID lookup</li>
102 * </ul>
103 */
104@SuppressWarnings("unused")
105public final class ContactsContract {
106    /** The authority for the contacts provider */
107    public static final String AUTHORITY = "com.android.contacts";
108    /** A content:// style uri to the authority for the contacts provider */
109    public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
110
111    /**
112     * An optional URI parameter for insert, update, or delete queries
113     * that allows the caller
114     * to specify that it is a sync adapter. The default value is false. If true
115     * {@link RawContacts#DIRTY} is not automatically set and the
116     * "syncToNetwork" parameter is set to false when calling
117     * {@link
118     * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
119     * This prevents an unnecessary extra synchronization, see the discussion of
120     * the delete operation in {@link RawContacts}.
121     */
122    public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
123
124    /**
125     * A query parameter key used to specify the package that is requesting a query.
126     * This is used for restricting data based on package name.
127     *
128     * @hide
129     */
130    public static final String REQUESTING_PACKAGE_PARAM_KEY = "requesting_package";
131
132    /**
133     * @hide
134     */
135    public static final class Preferences {
136
137        /**
138         * A key in the {@link android.provider.Settings android.provider.Settings} provider
139         * that stores the preferred sorting order for contacts (by given name vs. by family name).
140         *
141         * @hide
142         */
143        public static final String SORT_ORDER = "android.contacts.SORT_ORDER";
144
145        /**
146         * The value for the SORT_ORDER key corresponding to sorting by given name first.
147         *
148         * @hide
149         */
150        public static final int SORT_ORDER_PRIMARY = 1;
151
152        /**
153         * The value for the SORT_ORDER key corresponding to sorting by family name first.
154         *
155         * @hide
156         */
157        public static final int SORT_ORDER_ALTERNATIVE = 2;
158
159        /**
160         * A key in the {@link android.provider.Settings android.provider.Settings} provider
161         * that stores the preferred display order for contacts (given name first vs. family
162         * name first).
163         *
164         * @hide
165         */
166        public static final String DISPLAY_ORDER = "android.contacts.DISPLAY_ORDER";
167
168        /**
169         * The value for the DISPLAY_ORDER key corresponding to showing the given name first.
170         *
171         * @hide
172         */
173        public static final int DISPLAY_ORDER_PRIMARY = 1;
174
175        /**
176         * The value for the DISPLAY_ORDER key corresponding to showing the family name first.
177         *
178         * @hide
179         */
180        public static final int DISPLAY_ORDER_ALTERNATIVE = 2;
181    }
182
183    /**
184     * @hide should be removed when users are updated to refer to SyncState
185     * @deprecated use SyncState instead
186     */
187    @Deprecated
188    public interface SyncStateColumns extends SyncStateContract.Columns {
189    }
190
191    /**
192     * A table provided for sync adapters to use for storing private sync state data.
193     *
194     * @see SyncStateContract
195     */
196    public static final class SyncState implements SyncStateContract.Columns {
197        /**
198         * This utility class cannot be instantiated
199         */
200        private SyncState() {}
201
202        public static final String CONTENT_DIRECTORY =
203                SyncStateContract.Constants.CONTENT_DIRECTORY;
204
205        /**
206         * The content:// style URI for this table
207         */
208        public static final Uri CONTENT_URI =
209                Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
210
211        /**
212         * @see android.provider.SyncStateContract.Helpers#get
213         */
214        public static byte[] get(ContentProviderClient provider, Account account)
215                throws RemoteException {
216            return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
217        }
218
219        /**
220         * @see android.provider.SyncStateContract.Helpers#get
221         */
222        public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
223                throws RemoteException {
224            return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
225        }
226
227        /**
228         * @see android.provider.SyncStateContract.Helpers#set
229         */
230        public static void set(ContentProviderClient provider, Account account, byte[] data)
231                throws RemoteException {
232            SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
233        }
234
235        /**
236         * @see android.provider.SyncStateContract.Helpers#newSetOperation
237         */
238        public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
239            return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
240        }
241    }
242
243    /**
244     * Generic columns for use by sync adapters. The specific functions of
245     * these columns are private to the sync adapter. Other clients of the API
246     * should not attempt to either read or write this column.
247     *
248     * @see RawContacts
249     * @see Groups
250     */
251    protected interface BaseSyncColumns {
252
253        /** Generic column for use by sync adapters. */
254        public static final String SYNC1 = "sync1";
255        /** Generic column for use by sync adapters. */
256        public static final String SYNC2 = "sync2";
257        /** Generic column for use by sync adapters. */
258        public static final String SYNC3 = "sync3";
259        /** Generic column for use by sync adapters. */
260        public static final String SYNC4 = "sync4";
261    }
262
263    /**
264     * Columns that appear when each row of a table belongs to a specific
265     * account, including sync information that an account may need.
266     *
267     * @see RawContacts
268     * @see Groups
269     */
270    protected interface SyncColumns extends BaseSyncColumns {
271        /**
272         * The name of the account instance to which this row belongs, which when paired with
273         * {@link #ACCOUNT_TYPE} identifies a specific account.
274         * <P>Type: TEXT</P>
275         */
276        public static final String ACCOUNT_NAME = "account_name";
277
278        /**
279         * The type of account to which this row belongs, which when paired with
280         * {@link #ACCOUNT_NAME} identifies a specific account.
281         * <P>Type: TEXT</P>
282         */
283        public static final String ACCOUNT_TYPE = "account_type";
284
285        /**
286         * String that uniquely identifies this row to its source account.
287         * <P>Type: TEXT</P>
288         */
289        public static final String SOURCE_ID = "sourceid";
290
291        /**
292         * Version number that is updated whenever this row or its related data
293         * changes.
294         * <P>Type: INTEGER</P>
295         */
296        public static final String VERSION = "version";
297
298        /**
299         * Flag indicating that {@link #VERSION} has changed, and this row needs
300         * to be synchronized by its owning account.
301         * <P>Type: INTEGER (boolean)</P>
302         */
303        public static final String DIRTY = "dirty";
304    }
305
306    /**
307     * Columns of {@link ContactsContract.Contacts} that track the user's
308     * preferences for, or interactions with, the contact.
309     *
310     * @see Contacts
311     * @see RawContacts
312     * @see ContactsContract.Data
313     * @see PhoneLookup
314     * @see ContactsContract.Contacts.AggregationSuggestions
315     */
316    protected interface ContactOptionsColumns {
317        /**
318         * The number of times a contact has been contacted
319         * <P>Type: INTEGER</P>
320         */
321        public static final String TIMES_CONTACTED = "times_contacted";
322
323        /**
324         * The last time a contact was contacted.
325         * <P>Type: INTEGER</P>
326         */
327        public static final String LAST_TIME_CONTACTED = "last_time_contacted";
328
329        /**
330         * Is the contact starred?
331         * <P>Type: INTEGER (boolean)</P>
332         */
333        public static final String STARRED = "starred";
334
335        /**
336         * URI for a custom ringtone associated with the contact. If null or missing,
337         * the default ringtone is used.
338         * <P>Type: TEXT (URI to the ringtone)</P>
339         */
340        public static final String CUSTOM_RINGTONE = "custom_ringtone";
341
342        /**
343         * Whether the contact should always be sent to voicemail. If missing,
344         * defaults to false.
345         * <P>Type: INTEGER (0 for false, 1 for true)</P>
346         */
347        public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
348    }
349
350    /**
351     * Columns of {@link ContactsContract.Contacts} that refer to intrinsic
352     * properties of the contact, as opposed to the user-specified options
353     * found in {@link ContactOptionsColumns}.
354     *
355     * @see Contacts
356     * @see ContactsContract.Data
357     * @see PhoneLookup
358     * @see ContactsContract.Contacts.AggregationSuggestions
359     */
360    protected interface ContactsColumns {
361        /**
362         * The display name for the contact.
363         * <P>Type: TEXT</P>
364         */
365        public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY;
366
367        /**
368         * Reference to the row in the RawContacts table holding the contact name.
369         * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P>
370         * @hide
371         */
372        public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
373
374        /**
375         * Reference to the row in the data table holding the photo.
376         * <P>Type: INTEGER REFERENCES data(_id)</P>
377         */
378        public static final String PHOTO_ID = "photo_id";
379
380        /**
381         * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of
382         * any {@link CommonDataKinds.GroupMembership} for this contact.
383         */
384        public static final String IN_VISIBLE_GROUP = "in_visible_group";
385
386        /**
387         * An indicator of whether this contact has at least one phone number. "1" if there is
388         * at least one phone number, "0" otherwise.
389         * <P>Type: INTEGER</P>
390         */
391        public static final String HAS_PHONE_NUMBER = "has_phone_number";
392
393        /**
394         * An opaque value that contains hints on how to find the contact if
395         * its row id changed as a result of a sync or aggregation.
396         */
397        public static final String LOOKUP_KEY = "lookup";
398    }
399
400    /**
401     * @see Contacts
402     */
403    protected interface ContactStatusColumns {
404        /**
405         * Contact presence status. See {@link StatusUpdates} for individual status
406         * definitions.
407         * <p>Type: NUMBER</p>
408         */
409        public static final String CONTACT_PRESENCE = "contact_presence";
410
411        /**
412         * Contact's latest status update.
413         * <p>Type: TEXT</p>
414         */
415        public static final String CONTACT_STATUS = "contact_status";
416
417        /**
418         * The absolute time in milliseconds when the latest status was
419         * inserted/updated.
420         * <p>Type: NUMBER</p>
421         */
422        public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
423
424        /**
425         * The package containing resources for this status: label and icon.
426         * <p>Type: TEXT</p>
427         */
428        public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
429
430        /**
431         * The resource ID of the label describing the source of contact
432         * status, e.g. "Google Talk". This resource is scoped by the
433         * {@link #CONTACT_STATUS_RES_PACKAGE}.
434         * <p>Type: NUMBER</p>
435         */
436        public static final String CONTACT_STATUS_LABEL = "contact_status_label";
437
438        /**
439         * The resource ID of the icon for the source of contact status. This
440         * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
441         * <p>Type: NUMBER</p>
442         */
443        public static final String CONTACT_STATUS_ICON = "contact_status_icon";
444    }
445
446    /**
447     * Constants for various styles of combining given name, family name etc into
448     * a full name.  For example, the western tradition follows the pattern
449     * 'given name' 'middle name' 'family name' with the alternative pattern being
450     * 'family name', 'given name' 'middle name'.  The CJK tradition is
451     * 'family name' 'middle name' 'given name', with Japanese favoring a space between
452     * the names and Chinese omitting the space.
453     * @hide
454     */
455    public interface FullNameStyle {
456        public static final int UNDEFINED = 0;
457        public static final int WESTERN = 1;
458
459        /**
460         * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
461         * which specific language it belongs to: Chinese, Japanese or Korean.
462         */
463        public static final int CJK = 2;
464
465        public static final int CHINESE = 3;
466        public static final int JAPANESE = 4;
467        public static final int KOREAN = 5;
468    }
469
470    /**
471     * Constants for various styles of capturing the pronunciation of a person's name.
472     * @hide
473     */
474    public interface PhoneticNameStyle {
475        public static final int UNDEFINED = 0;
476
477        /**
478         * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
479         * shown in UIs, but used for searches and sorting.
480         */
481        public static final int PINYIN = 3;
482
483        /**
484         * Hiragana and Katakana are two common styles of writing out the pronunciation
485         * of a Japanese names.
486         */
487        public static final int JAPANESE = 4;
488
489        /**
490         * Hangul is the Korean phonetic alphabet.
491         */
492        public static final int KOREAN = 5;
493    }
494
495    /**
496     * Types of data used to produce the display name for a contact. Listed in the order
497     * of increasing priority.
498     *
499     * @hide
500     */
501    public interface DisplayNameSources {
502        public static final int UNDEFINED = 0;
503        public static final int EMAIL = 10;
504        public static final int PHONE = 20;
505        public static final int ORGANIZATION = 30;
506        public static final int NICKNAME = 35;
507        public static final int STRUCTURED_NAME = 40;
508    }
509
510    /**
511     * Contact name and contact name metadata columns in the RawContacts table.
512     *
513     * @see Contacts
514     * @see RawContacts
515     * @hide
516     */
517    protected interface ContactNameColumns {
518
519        /**
520         * The kind of data that is used as the display name for the contact, such as
521         * structured name or email address.  See DisplayNameSources.
522         *
523         * TODO: convert DisplayNameSources to a link after it is un-hidden
524         */
525        public static final String DISPLAY_NAME_SOURCE = "display_name_source";
526
527        /**
528         * <p>
529         * The standard text shown as the contact's display name, based on the best
530         * available information for the contact (for example, it might be the email address
531         * if the name is not available).
532         * The information actually used to compute the name is stored in
533         * {@link #DISPLAY_NAME_SOURCE}.
534         * </p>
535         * <p>
536         * A contacts provider is free to choose whatever representation makes most
537         * sense for its target market.
538         * For example in the default Android Open Source Project implementation,
539         * if the display name is
540         * based on the structured name and the structured name follows
541         * the Western full-name style, then this field contains the "given name first"
542         * version of the full name.
543         * <p>
544         *
545         * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE
546         */
547        public static final String DISPLAY_NAME_PRIMARY = "display_name";
548
549        /**
550         * <p>
551         * An alternative representation of the display name, such as "family name first"
552         * instead of "given name first" for Western names.  If an alternative is not
553         * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}.
554         * </p>
555         * <p>
556         * A contacts provider is free to provide alternatives as necessary for
557         * its target market.
558         * For example the default Android Open Source Project contacts provider
559         * currently provides an
560         * alternative in a single case:  if the display name is
561         * based on the structured name and the structured name follows
562         * the Western full name style, then the field contains the "family name first"
563         * version of the full name.
564         * Other cases may be added later.
565         * </p>
566         */
567        public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
568
569        /**
570         * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}.  See
571         * PhoneticNameStyle.
572         *
573         * TODO: convert PhoneticNameStyle to a link after it is un-hidden
574         */
575        public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
576
577        /**
578         * <p>
579         * Pronunciation of the full name in the phonetic alphabet specified by
580         * {@link #PHONETIC_NAME_STYLE}.
581         * </p>
582         * <p>
583         * The value may be set manually by the user.
584         * This capability is is of interest only in countries
585         * with commonly used phonetic
586         * alphabets, such as Japan and Korea.  See PhoneticNameStyle.
587         * </p>
588         *
589         * TODO: convert PhoneticNameStyle to a link after it is un-hidden
590         */
591        public static final String PHONETIC_NAME = "phonetic_name";
592
593        /**
594         * Sort key that takes into account locale-based traditions for sorting
595         * names in address books.  The default
596         * sort key is {@link #DISPLAY_NAME_PRIMARY}.  For Chinese names
597         * the sort key is the name's Pinyin spelling, and for Japanese names
598         * it is the Hiragana version of the phonetic name.
599         */
600        public static final String SORT_KEY_PRIMARY = "sort_key";
601
602        /**
603         * Sort key based on the alternative representation of the full name,
604         * {@link #DISPLAY_NAME_ALTERNATIVE}.  Thus for Western names,
605         * it is the one using the "family name first" format.
606         */
607        public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
608    }
609
610    /**
611     * URI parameter and cursor extras that return counts of rows grouped by the
612     * address book index, which is usually the first letter of the sort key.
613     * When this parameter is supplied, the row counts are returned in the
614     * cursor extras bundle.
615     *
616     * @hide
617     */
618    public final static class ContactCounts {
619
620        /**
621         * Add this query parameter to a URI to get back row counts grouped by
622         * the address book index as cursor extras. For most languages it is the
623         * first letter of the sort key. This parameter does not affect the main
624         * content of the cursor.
625         *
626         * @hide
627         */
628        public static final String ADDRESS_BOOK_INDEX_EXTRAS = "address_book_index_extras";
629
630        /**
631         * The array of address book index titles, which are returned in the
632         * same order as the data in the cursor.
633         * <p>TYPE: String[]</p>
634         *
635         * @hide
636         */
637        public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "address_book_index_titles";
638
639        /**
640         * The array of group counts for the corresponding group.  Contains the same number
641         * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
642         * <p>TYPE: int[]</p>
643         *
644         * @hide
645         */
646        public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "address_book_index_counts";
647    }
648
649    /**
650     * Constants for the contacts table, which contains a record per aggregate
651     * of raw contacts representing the same person.
652     * <h3>Operations</h3>
653     * <dl>
654     * <dt><b>Insert</b></dt>
655     * <dd>A Contact cannot be created explicitly. When a raw contact is
656     * inserted, the provider will first try to find a Contact representing the
657     * same person. If one is found, the raw contact's
658     * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
659     * Contact. If no match is found, the provider automatically inserts a new
660     * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
661     * of the newly inserted raw contact.</dd>
662     * <dt><b>Update</b></dt>
663     * <dd>Only certain columns of Contact are modifiable:
664     * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
665     * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
666     * these columns on the Contact also changes them on all constituent raw
667     * contacts.</dd>
668     * <dt><b>Delete</b></dt>
669     * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
670     * deletes all constituent raw contacts. The corresponding sync adapters
671     * will notice the deletions of their respective raw contacts and remove
672     * them from their back end storage.</dd>
673     * <dt><b>Query</b></dt>
674     * <dd>
675     * <ul>
676     * <li>If you need to read an individual contact, consider using
677     * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
678     * <li>If you need to look up a contact by the phone number, use
679     * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
680     * which is optimized for this purpose.</li>
681     * <li>If you need to look up a contact by partial name, e.g. to produce
682     * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
683     * <li>If you need to look up a contact by some data element like email
684     * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
685     * The result will contain contact ID, name etc.
686     * </ul>
687     * </dd>
688     * </dl>
689     * <h2>Columns</h2>
690     * <table class="jd-sumtable">
691     * <tr>
692     * <th colspan='4'>Contacts</th>
693     * </tr>
694     * <tr>
695     * <td>long</td>
696     * <td>{@link #_ID}</td>
697     * <td>read-only</td>
698     * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
699     * </tr>
700     * <tr>
701     * <td>String</td>
702     * <td>{@link #LOOKUP_KEY}</td>
703     * <td>read-only</td>
704     * <td>An opaque value that contains hints on how to find the contact if its
705     * row id changed as a result of a sync or aggregation.</td>
706     * </tr>
707     * <tr>
708     * <td>long</td>
709     * <td>NAME_RAW_CONTACT_ID</td>
710     * <td>read-only</td>
711     * <td>The ID of the raw contact that contributes the display name
712     * to the aggregate contact. During aggregation one of the constituent
713     * raw contacts is chosen using a heuristic: a longer name or a name
714     * with more diacritic marks or more upper case characters is chosen.</td>
715     * </tr>
716     * <tr>
717     * <td>String</td>
718     * <td>DISPLAY_NAME_PRIMARY</td>
719     * <td>read-only</td>
720     * <td>The display name for the contact. It is the display name
721     * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
722     * column.</td>
723     * </tr>
724     * <tr>
725     * <td>long</td>
726     * <td>{@link #PHOTO_ID}</td>
727     * <td>read-only</td>
728     * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
729     * That row has the mime type
730     * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
731     * is computed automatically based on the
732     * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
733     * that mime type.</td>
734     * </tr>
735     * <tr>
736     * <td>int</td>
737     * <td>{@link #IN_VISIBLE_GROUP}</td>
738     * <td>read-only</td>
739     * <td>An indicator of whether this contact is supposed to be visible in the
740     * UI. "1" if the contact has at least one raw contact that belongs to a
741     * visible group; "0" otherwise.</td>
742     * </tr>
743     * <tr>
744     * <td>int</td>
745     * <td>{@link #HAS_PHONE_NUMBER}</td>
746     * <td>read-only</td>
747     * <td>An indicator of whether this contact has at least one phone number.
748     * "1" if there is at least one phone number, "0" otherwise.</td>
749     * </tr>
750     * <tr>
751     * <td>int</td>
752     * <td>{@link #TIMES_CONTACTED}</td>
753     * <td>read/write</td>
754     * <td>The number of times the contact has been contacted. See
755     * {@link #markAsContacted}. When raw contacts are aggregated, this field is
756     * computed automatically as the maximum number of times contacted among all
757     * constituent raw contacts. Setting this field automatically changes the
758     * corresponding field on all constituent raw contacts.</td>
759     * </tr>
760     * <tr>
761     * <td>long</td>
762     * <td>{@link #LAST_TIME_CONTACTED}</td>
763     * <td>read/write</td>
764     * <td>The timestamp of the last time the contact was contacted. See
765     * {@link #markAsContacted}. Setting this field also automatically
766     * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
767     * this field is computed automatically as the latest time contacted of all
768     * constituent raw contacts. Setting this field automatically changes the
769     * corresponding field on all constituent raw contacts.</td>
770     * </tr>
771     * <tr>
772     * <td>int</td>
773     * <td>{@link #STARRED}</td>
774     * <td>read/write</td>
775     * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
776     * When raw contacts are aggregated, this field is automatically computed:
777     * if any constituent raw contacts are starred, then this field is set to
778     * '1'. Setting this field automatically changes the corresponding field on
779     * all constituent raw contacts.</td>
780     * </tr>
781     * <tr>
782     * <td>String</td>
783     * <td>{@link #CUSTOM_RINGTONE}</td>
784     * <td>read/write</td>
785     * <td>A custom ringtone associated with a contact. Typically this is the
786     * URI returned by an activity launched with the
787     * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
788     * </tr>
789     * <tr>
790     * <td>int</td>
791     * <td>{@link #SEND_TO_VOICEMAIL}</td>
792     * <td>read/write</td>
793     * <td>An indicator of whether calls from this contact should be forwarded
794     * directly to voice mail ('1') or not ('0'). When raw contacts are
795     * aggregated, this field is automatically computed: if <i>all</i>
796     * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
797     * to '1'. Setting this field automatically changes the corresponding field
798     * on all constituent raw contacts.</td>
799     * </tr>
800     * <tr>
801     * <td>int</td>
802     * <td>{@link #CONTACT_PRESENCE}</td>
803     * <td>read-only</td>
804     * <td>Contact IM presence status. See {@link StatusUpdates} for individual
805     * status definitions. Automatically computed as the highest presence of all
806     * constituent raw contacts. The provider may choose not to store this value
807     * in persistent storage. The expectation is that presence status will be
808     * updated on a regular basic.</td>
809     * </tr>
810     * <tr>
811     * <td>String</td>
812     * <td>{@link #CONTACT_STATUS}</td>
813     * <td>read-only</td>
814     * <td>Contact's latest status update. Automatically computed as the latest
815     * of all constituent raw contacts' status updates.</td>
816     * </tr>
817     * <tr>
818     * <td>long</td>
819     * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
820     * <td>read-only</td>
821     * <td>The absolute time in milliseconds when the latest status was
822     * inserted/updated.</td>
823     * </tr>
824     * <tr>
825     * <td>String</td>
826     * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
827     * <td>read-only</td>
828     * <td> The package containing resources for this status: label and icon.</td>
829     * </tr>
830     * <tr>
831     * <td>long</td>
832     * <td>{@link #CONTACT_STATUS_LABEL}</td>
833     * <td>read-only</td>
834     * <td>The resource ID of the label describing the source of contact status,
835     * e.g. "Google Talk". This resource is scoped by the
836     * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
837     * </tr>
838     * <tr>
839     * <td>long</td>
840     * <td>{@link #CONTACT_STATUS_ICON}</td>
841     * <td>read-only</td>
842     * <td>The resource ID of the icon for the source of contact status. This
843     * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
844     * </tr>
845     * </table>
846     */
847    public static class Contacts implements BaseColumns, ContactsColumns,
848            ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
849        /**
850         * This utility class cannot be instantiated
851         */
852        private Contacts()  {}
853
854        /**
855         * The content:// style URI for this table
856         */
857        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
858
859        /**
860         * A content:// style URI for this table that should be used to create
861         * shortcuts or otherwise create long-term links to contacts. This URI
862         * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
863         * It can optionally also have a "/" and last known contact ID appended after
864         * that. This "complete" format is an important optimization and is highly recommended.
865         * <p>
866         * As long as the contact's row ID remains the same, this URI is
867         * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
868         * as a result of a sync or aggregation, this URI will look up the
869         * contact using indirect information (sync IDs or constituent raw
870         * contacts).
871         * <p>
872         * Lookup key should be appended unencoded - it is stored in the encoded
873         * form, ready for use in a URI.
874         */
875        public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
876                "lookup");
877
878        /**
879         * Base {@link Uri} for referencing a single {@link Contacts} entry,
880         * created by appending {@link #LOOKUP_KEY} using
881         * {@link Uri#withAppendedPath(Uri, String)}. Provides
882         * {@link OpenableColumns} columns when queried, or returns the
883         * referenced contact formatted as a vCard when opened through
884         * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
885         */
886        public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
887                "as_vcard");
888
889        /**
890         * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
891         * requested {@link Contacts} entry.
892         *
893         * @param contactUri A {@link #CONTENT_URI} row, or an existing
894         *            {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
895         */
896        public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
897            final Cursor c = resolver.query(contactUri, new String[] {
898                    Contacts.LOOKUP_KEY, Contacts._ID
899            }, null, null, null);
900            if (c == null) {
901                return null;
902            }
903
904            try {
905                if (c.moveToFirst()) {
906                    final String lookupKey = c.getString(0);
907                    final long contactId = c.getLong(1);
908                    return getLookupUri(contactId, lookupKey);
909                }
910            } finally {
911                c.close();
912            }
913            return null;
914        }
915
916        /**
917         * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
918         * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
919         */
920        public static Uri getLookupUri(long contactId, String lookupKey) {
921            return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
922                    lookupKey), contactId);
923        }
924
925        /**
926         * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
927         * <p>
928         * Returns null if the contact cannot be found.
929         */
930        public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
931            if (lookupUri == null) {
932                return null;
933            }
934
935            Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
936            if (c == null) {
937                return null;
938            }
939
940            try {
941                if (c.moveToFirst()) {
942                    long contactId = c.getLong(0);
943                    return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
944                }
945            } finally {
946                c.close();
947            }
948            return null;
949        }
950
951        /**
952         * Mark a contact as having been contacted.  This updates the
953         * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED} for the
954         * contact, plus the corresponding values of any associated raw
955         * contacts.
956         *
957         * @param resolver the ContentResolver to use
958         * @param contactId the person who was contacted
959         */
960        public static void markAsContacted(ContentResolver resolver, long contactId) {
961            Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
962            ContentValues values = new ContentValues();
963            // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
964            values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
965            resolver.update(uri, values, null, null);
966        }
967
968        /**
969         * The content:// style URI used for "type-to-filter" functionality on the
970         * {@link #CONTENT_URI} URI. The filter string will be used to match
971         * various parts of the contact name. The filter argument should be passed
972         * as an additional path segment after this URI.
973         */
974        public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
975                CONTENT_URI, "filter");
976
977        /**
978         * The content:// style URI for this table joined with useful data from
979         * {@link ContactsContract.Data}, filtered to include only starred contacts
980         * and the most frequently contacted contacts.
981         */
982        public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
983                CONTENT_URI, "strequent");
984
985        /**
986         * The content:// style URI used for "type-to-filter" functionality on the
987         * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
988         * various parts of the contact name. The filter argument should be passed
989         * as an additional path segment after this URI.
990         */
991        public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
992                CONTENT_STREQUENT_URI, "filter");
993
994        public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
995                CONTENT_URI, "group");
996
997        /**
998         * The MIME type of {@link #CONTENT_URI} providing a directory of
999         * people.
1000         */
1001        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
1002
1003        /**
1004         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1005         * person.
1006         */
1007        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
1008
1009        /**
1010         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1011         * person.
1012         */
1013        public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
1014
1015        /**
1016         * A sub-directory of a single contact that contains all of the constituent raw contact
1017         * {@link ContactsContract.Data} rows.
1018         */
1019        public static final class Data implements BaseColumns, DataColumns {
1020            /**
1021             * no public constructor since this is a utility class
1022             */
1023            private Data() {}
1024
1025            /**
1026             * The directory twig for this sub-table
1027             */
1028            public static final String CONTENT_DIRECTORY = "data";
1029        }
1030
1031        /**
1032         * <p>
1033         * A <i>read-only</i> sub-directory of a single contact aggregate that
1034         * contains all aggregation suggestions (other contacts). The
1035         * aggregation suggestions are computed based on approximate data
1036         * matches with this contact.
1037         * </p>
1038         * <p>
1039         * <i>Note: this query may be expensive! If you need to use it in bulk,
1040         * make sure the user experience is acceptable when the query runs for a
1041         * long time.</i>
1042         * <p>
1043         * Usage example:
1044         *
1045         * <pre>
1046         * Uri uri = Contacts.CONTENT_URI.buildUpon()
1047         *          .appendEncodedPath(String.valueOf(contactId))
1048         *          .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
1049         *          .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
1050         *          .build()
1051         * Cursor cursor = getContentResolver().query(suggestionsUri,
1052         *          new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
1053         *          null, null, null);
1054         * </pre>
1055         *
1056         * </p>
1057         */
1058        // TODO: add ContactOptionsColumns, ContactStatusColumns
1059        public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
1060            /**
1061             * No public constructor since this is a utility class
1062             */
1063            private AggregationSuggestions() {}
1064
1065            /**
1066             * The directory twig for this sub-table. The URI can be followed by an optional
1067             * type-to-filter, similar to
1068             * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
1069             */
1070            public static final String CONTENT_DIRECTORY = "suggestions";
1071        }
1072
1073        /**
1074         * A <i>read-only</i> sub-directory of a single contact that contains
1075         * the contact's primary photo.
1076         * <p>
1077         * Usage example:
1078         *
1079         * <pre>
1080         * public InputStream openPhoto(long contactId) {
1081         *     Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1082         *     Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
1083         *     Cursor cursor = getContentResolver().query(photoUri,
1084         *          new String[] {Contacts.Photo.PHOTO}, null, null, null);
1085         *     if (cursor == null) {
1086         *         return null;
1087         *     }
1088         *     try {
1089         *         if (cursor.moveToFirst()) {
1090         *             byte[] data = cursor.getBlob(0);
1091         *             if (data != null) {
1092         *                 return new ByteArrayInputStream(data);
1093         *             }
1094         *         }
1095         *     } finally {
1096         *         cursor.close();
1097         *     }
1098         *     return null;
1099         * }
1100         * </pre>
1101         *
1102         * </p>
1103         * <p>You should also consider using the convenience method
1104         * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri)}
1105         * </p>
1106         */
1107        // TODO: change DataColumns to DataColumnsWithJoins
1108        public static final class Photo implements BaseColumns, DataColumns {
1109            /**
1110             * no public constructor since this is a utility class
1111             */
1112            private Photo() {}
1113
1114            /**
1115             * The directory twig for this sub-table
1116             */
1117            public static final String CONTENT_DIRECTORY = "photo";
1118
1119            /**
1120             * Thumbnail photo of the raw contact. This is the raw bytes of an image
1121             * that could be inflated using {@link android.graphics.BitmapFactory}.
1122             * <p>
1123             * Type: BLOB
1124             * @hide TODO: Unhide in a separate CL
1125             */
1126            public static final String PHOTO = DATA15;
1127        }
1128
1129        /**
1130         * Opens an InputStream for the contacts's default photo and returns the
1131         * photo as a byte stream. If there is not photo null will be returned.
1132         *
1133         * @param contactUri the contact whose photo should be used
1134         * @return an InputStream of the photo, or null if no photo is present
1135         */
1136        public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
1137            Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
1138            if (photoUri == null) {
1139                return null;
1140            }
1141            Cursor cursor = cr.query(photoUri,
1142                    new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
1143            try {
1144                if (cursor == null || !cursor.moveToNext()) {
1145                    return null;
1146                }
1147                byte[] data = cursor.getBlob(0);
1148                if (data == null) {
1149                    return null;
1150                }
1151                return new ByteArrayInputStream(data);
1152            } finally {
1153                if (cursor != null) {
1154                    cursor.close();
1155                }
1156            }
1157        }
1158    }
1159
1160    protected interface RawContactsColumns {
1161        /**
1162         * A reference to the {@link ContactsContract.Contacts#_ID} that this
1163         * data belongs to.
1164         * <P>Type: INTEGER</P>
1165         */
1166        public static final String CONTACT_ID = "contact_id";
1167
1168        /**
1169         * Flag indicating that this {@link RawContacts} entry and its children have
1170         * been restricted to specific platform apps.
1171         * <P>Type: INTEGER (boolean)</P>
1172         *
1173         * @hide until finalized in future platform release
1174         */
1175        public static final String IS_RESTRICTED = "is_restricted";
1176
1177        /**
1178         * The aggregation mode for this contact.
1179         * <P>Type: INTEGER</P>
1180         */
1181        public static final String AGGREGATION_MODE = "aggregation_mode";
1182
1183        /**
1184         * The "deleted" flag: "0" by default, "1" if the row has been marked
1185         * for deletion. When {@link android.content.ContentResolver#delete} is
1186         * called on a raw contact, it is marked for deletion and removed from its
1187         * aggregate contact. The sync adaptor deletes the raw contact on the server and
1188         * then calls ContactResolver.delete once more, this time passing the
1189         * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
1190         * the data removal.
1191         * <P>Type: INTEGER</P>
1192         */
1193        public static final String DELETED = "deleted";
1194
1195        /**
1196         * The "name_verified" flag: "1" means that the name fields on this raw
1197         * contact can be trusted and therefore should be used for the entire
1198         * aggregated contact.
1199         * <p>
1200         * If an aggregated contact contains more than one raw contact with a
1201         * verified name, one of those verified names is chosen at random.
1202         * If an aggregated contact contains no verified names, the
1203         * name is chosen randomly from the constituent raw contacts.
1204         * </p>
1205         * <p>
1206         * Updating this flag from "0" to "1" automatically resets it to "0" on
1207         * all other raw contacts in the same aggregated contact.
1208         * </p>
1209         * <p>
1210         * Sync adapters should only specify a value for this column when
1211         * inserting a raw contact and leave it out when doing an update.
1212         * </p>
1213         * <p>
1214         * The default value is "0"
1215         * </p>
1216         * <p>Type: INTEGER</p>
1217         *
1218         * @hide
1219         */
1220        public static final String NAME_VERIFIED = "name_verified";
1221    }
1222
1223    /**
1224     * Constants for the raw contacts table, which contains one row of contact
1225     * information for each person in each synced account. Sync adapters and
1226     * contact management apps
1227     * are the primary consumers of this API.
1228     *
1229     * <h3>Aggregation</h3>
1230     * <p>
1231     * As soon as a raw contact is inserted or whenever its constituent data
1232     * changes, the provider will check if the raw contact matches other
1233     * existing raw contacts and if so will aggregate it with those. The
1234     * aggregation is reflected in the {@link RawContacts} table by the change of the
1235     * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
1236     * </p>
1237     * <p>
1238     * Changes to the structured name, organization, phone number, email address,
1239     * or nickname trigger a re-aggregation.
1240     * </p>
1241     * <p>
1242     * See also {@link AggregationExceptions} for a mechanism to control
1243     * aggregation programmatically.
1244     * </p>
1245     *
1246     * <h3>Operations</h3>
1247     * <dl>
1248     * <dt><b>Insert</b></dt>
1249     * <dd>
1250     * <p>
1251     * Raw contacts can be inserted incrementally or in a batch.
1252     * The incremental method is more traditional but less efficient.
1253     * It should be used
1254     * only if no {@link Data} values are available at the time the raw contact is created:
1255     * <pre>
1256     * ContentValues values = new ContentValues();
1257     * values.put(RawContacts.ACCOUNT_TYPE, accountType);
1258     * values.put(RawContacts.ACCOUNT_NAME, accountName);
1259     * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
1260     * long rawContactId = ContentUris.parseId(rawContactUri);
1261     * </pre>
1262     * </p>
1263     * <p>
1264     * Once {@link Data} values become available, insert those.
1265     * For example, here's how you would insert a name:
1266     *
1267     * <pre>
1268     * values.clear();
1269     * values.put(Data.RAW_CONTACT_ID, rawContactId);
1270     * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
1271     * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
1272     * getContentResolver().insert(Data.CONTENT_URI, values);
1273     * </pre>
1274     * </p>
1275     * <p>
1276     * The batch method is by far preferred.  It inserts the raw contact and its
1277     * constituent data rows in a single database transaction
1278     * and causes at most one aggregation pass.
1279     * <pre>
1280     * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
1281     * ...
1282     * int rawContactInsertIndex = ops.size();
1283     * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
1284     *          .withValue(RawContacts.ACCOUNT_TYPE, accountType)
1285     *          .withValue(RawContacts.ACCOUNT_NAME, accountName)
1286     *          .build());
1287     *
1288     * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
1289     *          .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
1290     *          .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
1291     *          .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
1292     *          .build());
1293     *
1294     * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
1295     * </pre>
1296     * </p>
1297     * <p>
1298     * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
1299     * to refer to the as-yet-unknown index value of the raw contact inserted in the
1300     * first operation.
1301     * </p>
1302     *
1303     * <dt><b>Update</b></dt>
1304     * <dd><p>
1305     * Raw contacts can be updated incrementally or in a batch.
1306     * Batch mode should be used whenever possible.
1307     * The procedures and considerations are analogous to those documented above for inserts.
1308     * </p></dd>
1309     * <dt><b>Delete</b></dt>
1310     * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
1311     * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
1312     * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
1313     * itself is also deleted automatically.
1314     * </p>
1315     * <p>
1316     * The invocation of {@code resolver.delete(...)}, does not immediately delete
1317     * a raw contacts row.
1318     * Instead, it sets the {@link #DELETED} flag on the raw contact and
1319     * removes the raw contact from its aggregate contact.
1320     * The sync adapter then deletes the raw contact from the server and
1321     * finalizes phone-side deletion by calling {@code resolver.delete(...)}
1322     * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
1323     * <p>Some sync adapters are read-only, meaning that they only sync server-side
1324     * changes to the phone, but not the reverse.  If one of those raw contacts
1325     * is marked for deletion, it will remain on the phone.  However it will be
1326     * effectively invisible, because it will not be part of any aggregate contact.
1327     * </dd>
1328     *
1329     * <dt><b>Query</b></dt>
1330     * <dd>
1331     * <p>
1332     * It is easy to find all raw contacts in a Contact:
1333     * <pre>
1334     * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
1335     *          new String[]{RawContacts._ID},
1336     *          RawContacts.CONTACT_ID + "=?",
1337     *          new String[]{String.valueOf(contactId)}, null);
1338     * </pre>
1339     * </p>
1340     * <p>
1341     * To find raw contacts within a specific account,
1342     * you can either put the account name and type in the selection or pass them as query
1343     * parameters.  The latter approach is preferable, especially when you can reuse the
1344     * URI:
1345     * <pre>
1346     * Uri rawContactUri = RawContacts.URI.buildUpon()
1347     *          .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
1348     *          .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
1349     *          .build();
1350     * Cursor c1 = getContentResolver().query(rawContactUri,
1351     *          RawContacts.STARRED + "&lt;&gt;0", null, null, null);
1352     * ...
1353     * Cursor c2 = getContentResolver().query(rawContactUri,
1354     *          RawContacts.DELETED + "&lt;&gt;0", null, null, null);
1355     * </pre>
1356     * </p>
1357     * <p>The best way to read a raw contact along with all the data associated with it is
1358     * by using the {@link Entity} directory. If the raw contact has data rows,
1359     * the Entity cursor will contain a row for each data row.  If the raw contact has no
1360     * data rows, the cursor will still contain one row with the raw contact-level information.
1361     * <pre>
1362     * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
1363     * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
1364     * Cursor c = getContentResolver().query(entityUri,
1365     *          new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
1366     *          null, null, null);
1367     * try {
1368     *     while (c.moveToNext()) {
1369     *         String sourceId = c.getString(0);
1370     *         if (!c.isNull(1)) {
1371     *             String mimeType = c.getString(2);
1372     *             String data = c.getString(3);
1373     *             ...
1374     *         }
1375     *     }
1376     * } finally {
1377     *     c.close();
1378     * }
1379     * </pre>
1380     * </p>
1381     * </dd>
1382     * </dl>
1383     * <h2>Columns</h2>
1384     *
1385     * <table class="jd-sumtable">
1386     * <tr>
1387     * <th colspan='4'>RawContacts</th>
1388     * </tr>
1389     * <tr>
1390     * <td>long</td>
1391     * <td>{@link #_ID}</td>
1392     * <td>read-only</td>
1393     * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
1394     * it is much better for a sync adapter to update a raw contact rather than to delete and
1395     * re-insert it.</td>
1396     * </tr>
1397     * <tr>
1398     * <td>long</td>
1399     * <td>{@link #CONTACT_ID}</td>
1400     * <td>read-only</td>
1401     * <td>The ID of the row in the {@link ContactsContract.Contacts} table
1402     * that this raw contact belongs
1403     * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
1404     * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
1405     * </tr>
1406     * <tr>
1407     * <td>int</td>
1408     * <td>{@link #AGGREGATION_MODE}</td>
1409     * <td>read/write</td>
1410     * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
1411     * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
1412     * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
1413     * </tr>
1414     * <tr>
1415     * <td>int</td>
1416     * <td>{@link #DELETED}</td>
1417     * <td>read/write</td>
1418     * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
1419     * for deletion. When {@link android.content.ContentResolver#delete} is
1420     * called on a raw contact, it is marked for deletion and removed from its
1421     * aggregate contact. The sync adaptor deletes the raw contact on the server and
1422     * then calls ContactResolver.delete once more, this time passing the
1423     * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
1424     * the data removal.</td>
1425     * </tr>
1426     * <tr>
1427     * <td>int</td>
1428     * <td>{@link #TIMES_CONTACTED}</td>
1429     * <td>read/write</td>
1430     * <td>The number of times the contact has been contacted. To have an effect
1431     * on the corresponding value of the aggregate contact, this field
1432     * should be set at the time the raw contact is inserted.
1433     * After that, this value is typically updated via
1434     * {@link ContactsContract.Contacts#markAsContacted}.</td>
1435     * </tr>
1436     * <tr>
1437     * <td>long</td>
1438     * <td>{@link #LAST_TIME_CONTACTED}</td>
1439     * <td>read/write</td>
1440     * <td>The timestamp of the last time the contact was contacted. To have an effect
1441     * on the corresponding value of the aggregate contact, this field
1442     * should be set at the time the raw contact is inserted.
1443     * After that, this value is typically updated via
1444     * {@link ContactsContract.Contacts#markAsContacted}.
1445     * </td>
1446     * </tr>
1447     * <tr>
1448     * <td>int</td>
1449     * <td>{@link #STARRED}</td>
1450     * <td>read/write</td>
1451     * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
1452     * Changing this field immediately affects the corresponding aggregate contact:
1453     * if any raw contacts in that aggregate contact are starred, then the contact
1454     * itself is marked as starred.</td>
1455     * </tr>
1456     * <tr>
1457     * <td>String</td>
1458     * <td>{@link #CUSTOM_RINGTONE}</td>
1459     * <td>read/write</td>
1460     * <td>A custom ringtone associated with a raw contact. Typically this is the
1461     * URI returned by an activity launched with the
1462     * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
1463     * To have an effect on the corresponding value of the aggregate contact, this field
1464     * should be set at the time the raw contact is inserted. To set a custom
1465     * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
1466     * Contacts.CUSTOM_RINGTONE}
1467     * instead.</td>
1468     * </tr>
1469     * <tr>
1470     * <td>int</td>
1471     * <td>{@link #SEND_TO_VOICEMAIL}</td>
1472     * <td>read/write</td>
1473     * <td>An indicator of whether calls from this raw contact should be forwarded
1474     * directly to voice mail ('1') or not ('0'). To have an effect
1475     * on the corresponding value of the aggregate contact, this field
1476     * should be set at the time the raw contact is inserted.</td>
1477     * </tr>
1478     * <tr>
1479     * <td>String</td>
1480     * <td>{@link #ACCOUNT_NAME}</td>
1481     * <td>read/write-once</td>
1482     * <td>The name of the account instance to which this row belongs, which when paired with
1483     * {@link #ACCOUNT_TYPE} identifies a specific account.
1484     * For example, this will be the Gmail address if it is a Google account.
1485     * It should be set at the time
1486     * the raw contact is inserted and never changed afterwards.</td>
1487     * </tr>
1488     * <tr>
1489     * <td>String</td>
1490     * <td>{@link #ACCOUNT_TYPE}</td>
1491     * <td>read/write-once</td>
1492     * <td>
1493     * <p>
1494     * The type of account to which this row belongs, which when paired with
1495     * {@link #ACCOUNT_NAME} identifies a specific account.
1496     * It should be set at the time
1497     * the raw contact is inserted and never changed afterwards.
1498     * </p>
1499     * <p>
1500     * To ensure uniqueness, new account types should be chosen according to the
1501     * Java package naming convention.  Thus a Google account is of type "com.google".
1502     * </p>
1503     * </td>
1504     * </tr>
1505     * <tr>
1506     * <td>String</td>
1507     * <td>{@link #SOURCE_ID}</td>
1508     * <td>read/write</td>
1509     * <td>String that uniquely identifies this row to its source account.
1510     * Typically it is set at the time the raw contact is inserted and never
1511     * changed afterwards. The one notable exception is a new raw contact: it
1512     * will have an account name and type, but no source id. This
1513     * indicates to the sync adapter that a new contact needs to be created
1514     * server-side and its ID stored in the corresponding SOURCE_ID field on
1515     * the phone.
1516     * </td>
1517     * </tr>
1518     * <tr>
1519     * <td>int</td>
1520     * <td>{@link #VERSION}</td>
1521     * <td>read-only</td>
1522     * <td>Version number that is updated whenever this row or its related data
1523     * changes. This field can be used for optimistic locking of a raw contact.
1524     * </td>
1525     * </tr>
1526     * <tr>
1527     * <td>int</td>
1528     * <td>{@link #DIRTY}</td>
1529     * <td>read/write</td>
1530     * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
1531     * to be synchronized by its owning account.  The value is set to "1" automatically
1532     * whenever the raw contact changes, unless the URI has the
1533     * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
1534     * The sync adapter should always supply this query parameter to prevent
1535     * unnecessary synchronization: user changes some data on the server,
1536     * the sync adapter updates the contact on the phone (without the
1537     * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
1538     * which triggers a sync to bring the changes to the server.
1539     * </td>
1540     * </tr>
1541     * <tr>
1542     * <td>String</td>
1543     * <td>{@link #SYNC1}</td>
1544     * <td>read/write</td>
1545     * <td>Generic column provided for arbitrary use by sync adapters.
1546     * The content provider
1547     * stores this information on behalf of the sync adapter but does not
1548     * interpret it in any way.
1549     * </td>
1550     * </tr>
1551     * <tr>
1552     * <td>String</td>
1553     * <td>{@link #SYNC2}</td>
1554     * <td>read/write</td>
1555     * <td>Generic column for use by sync adapters.
1556     * </td>
1557     * </tr>
1558     * <tr>
1559     * <td>String</td>
1560     * <td>{@link #SYNC3}</td>
1561     * <td>read/write</td>
1562     * <td>Generic column for use by sync adapters.
1563     * </td>
1564     * </tr>
1565     * <tr>
1566     * <td>String</td>
1567     * <td>{@link #SYNC4}</td>
1568     * <td>read/write</td>
1569     * <td>Generic column for use by sync adapters.
1570     * </td>
1571     * </tr>
1572     * </table>
1573     */
1574    public static final class RawContacts implements BaseColumns, RawContactsColumns,
1575            ContactOptionsColumns, ContactNameColumns, SyncColumns  {
1576        /**
1577         * This utility class cannot be instantiated
1578         */
1579        private RawContacts() {
1580        }
1581
1582        /**
1583         * The content:// style URI for this table, which requests a directory of
1584         * raw contact rows matching the selection criteria.
1585         */
1586        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
1587
1588        /**
1589         * The MIME type of the results from {@link #CONTENT_URI} when a specific
1590         * ID value is not provided, and multiple raw contacts may be returned.
1591         */
1592        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
1593
1594        /**
1595         * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
1596         * yielding a subdirectory of a single person.
1597         */
1598        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
1599
1600        /**
1601         * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
1602         */
1603        public static final int AGGREGATION_MODE_DEFAULT = 0;
1604
1605        /**
1606         * Do not use.
1607         *
1608         * TODO: deprecate in favor of {@link #AGGREGATION_MODE_DEFAULT}
1609         */
1610        public static final int AGGREGATION_MODE_IMMEDIATE = 1;
1611
1612        /**
1613         * <p>
1614         * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
1615         * Changes to the raw contact will update the associated aggregate contact but will not
1616         * result in any change in how the contact is aggregated. Similar to
1617         * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
1618         * {@link Contacts} aggregate.
1619         * </p>
1620         * <p>
1621         * This can be used to postpone aggregation until after a series of updates, for better
1622         * performance and/or user experience.
1623         * </p>
1624         * <p>
1625         * Note that changing
1626         * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
1627         * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
1628         * subsequent
1629         * change to the raw contact's data will.
1630         * </p>
1631         */
1632        public static final int AGGREGATION_MODE_SUSPENDED = 2;
1633
1634        /**
1635         * <p>
1636         * Aggregation mode: never aggregate this raw contact.  The raw contact will not
1637         * have a corresponding {@link Contacts} aggregate and therefore will not be included in
1638         * {@link Contacts} query results.
1639         * </p>
1640         * <p>
1641         * For example, this mode can be used for a raw contact that is marked for deletion while
1642         * waiting for the deletion to occur on the server side.
1643         * </p>
1644         *
1645         * @see #AGGREGATION_MODE_SUSPENDED
1646         */
1647        public static final int AGGREGATION_MODE_DISABLED = 3;
1648
1649        /**
1650         * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
1651         * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
1652         * entry of the given {@link RawContacts} entry.
1653         */
1654        public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
1655            // TODO: use a lighter query by joining rawcontacts with contacts in provider
1656            final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
1657            final Cursor cursor = resolver.query(dataUri, new String[] {
1658                    RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
1659            }, null, null, null);
1660
1661            Uri lookupUri = null;
1662            try {
1663                if (cursor != null && cursor.moveToFirst()) {
1664                    final long contactId = cursor.getLong(0);
1665                    final String lookupKey = cursor.getString(1);
1666                    return Contacts.getLookupUri(contactId, lookupKey);
1667                }
1668            } finally {
1669                if (cursor != null) cursor.close();
1670            }
1671            return lookupUri;
1672        }
1673
1674        /**
1675         * A sub-directory of a single raw contact that contains all of its
1676         * {@link ContactsContract.Data} rows. To access this directory
1677         * append {@link Data#CONTENT_DIRECTORY} to the contact URI.
1678         *
1679         * TODO: deprecate in favor of {@link RawContacts.Entity}.
1680         */
1681        public static final class Data implements BaseColumns, DataColumns {
1682            /**
1683             * no public constructor since this is a utility class
1684             */
1685            private Data() {
1686            }
1687
1688            /**
1689             * The directory twig for this sub-table
1690             */
1691            public static final String CONTENT_DIRECTORY = "data";
1692        }
1693
1694        /**
1695         * <p>
1696         * A sub-directory of a single raw contact that contains all of its
1697         * {@link ContactsContract.Data} rows. To access this directory append
1698         * {@link #CONTENT_DIRECTORY} to the contact URI. See
1699         * {@link RawContactsEntity} for a stand-alone table containing the same
1700         * data.
1701         * </p>
1702         * <p>
1703         * Entity has two ID fields: {@link #_ID} for the raw contact
1704         * and {@link #DATA_ID} for the data rows.
1705         * Entity always contains at least one row, even if there are no
1706         * actual data rows. In this case the {@link #DATA_ID} field will be
1707         * null.
1708         * </p>
1709         * <p>
1710         * Entity reads all
1711         * data for a raw contact in one transaction, to guarantee
1712         * consistency.
1713         * </p>
1714         */
1715        public static final class Entity implements BaseColumns, DataColumns {
1716            /**
1717             * no public constructor since this is a utility class
1718             */
1719            private Entity() {
1720            }
1721
1722            /**
1723             * The directory twig for this sub-table
1724             */
1725            public static final String CONTENT_DIRECTORY = "entity";
1726
1727            /**
1728             * The ID of the data column. The value will be null if this raw contact has no
1729             * data rows.
1730             * <P>Type: INTEGER</P>
1731             */
1732            public static final String DATA_ID = "data_id";
1733        }
1734
1735        /**
1736         * TODO: javadoc
1737         * @param cursor
1738         * @return
1739         */
1740        public static EntityIterator newEntityIterator(Cursor cursor) {
1741            return new EntityIteratorImpl(cursor);
1742        }
1743
1744        private static class EntityIteratorImpl extends CursorEntityIterator {
1745            private static final String[] DATA_KEYS = new String[]{
1746                    Data.DATA1,
1747                    Data.DATA2,
1748                    Data.DATA3,
1749                    Data.DATA4,
1750                    Data.DATA5,
1751                    Data.DATA6,
1752                    Data.DATA7,
1753                    Data.DATA8,
1754                    Data.DATA9,
1755                    Data.DATA10,
1756                    Data.DATA11,
1757                    Data.DATA12,
1758                    Data.DATA13,
1759                    Data.DATA14,
1760                    Data.DATA15,
1761                    Data.SYNC1,
1762                    Data.SYNC2,
1763                    Data.SYNC3,
1764                    Data.SYNC4};
1765
1766            public EntityIteratorImpl(Cursor cursor) {
1767                super(cursor);
1768            }
1769
1770            @Override
1771            public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
1772                    throws RemoteException {
1773                final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
1774                final long rawContactId = cursor.getLong(columnRawContactId);
1775
1776                // we expect the cursor is already at the row we need to read from
1777                ContentValues cv = new ContentValues();
1778                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
1779                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
1780                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
1781                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
1782                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
1783                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
1784                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
1785                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
1786                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
1787                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
1788                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
1789                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
1790                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
1791                DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, IS_RESTRICTED);
1792                DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED);
1793                android.content.Entity contact = new android.content.Entity(cv);
1794
1795                // read data rows until the contact id changes
1796                do {
1797                    if (rawContactId != cursor.getLong(columnRawContactId)) {
1798                        break;
1799                    }
1800                    // add the data to to the contact
1801                    cv = new ContentValues();
1802                    cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
1803                    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
1804                            Data.RES_PACKAGE);
1805                    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
1806                    DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
1807                    DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
1808                            Data.IS_SUPER_PRIMARY);
1809                    DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
1810                    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
1811                            CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
1812                    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
1813                            Data.DATA_VERSION);
1814                    for (String key : DATA_KEYS) {
1815                        final int columnIndex = cursor.getColumnIndexOrThrow(key);
1816                        if (cursor.isNull(columnIndex)) {
1817                            // don't put anything
1818                        } else {
1819                            try {
1820                                cv.put(key, cursor.getString(columnIndex));
1821                            } catch (SQLiteException e) {
1822                                cv.put(key, cursor.getBlob(columnIndex));
1823                            }
1824                        }
1825                        // TODO: go back to this version of the code when bug
1826                        // http://b/issue?id=2306370 is fixed.
1827//                        if (cursor.isNull(columnIndex)) {
1828//                            // don't put anything
1829//                        } else if (cursor.isLong(columnIndex)) {
1830//                            values.put(key, cursor.getLong(columnIndex));
1831//                        } else if (cursor.isFloat(columnIndex)) {
1832//                            values.put(key, cursor.getFloat(columnIndex));
1833//                        } else if (cursor.isString(columnIndex)) {
1834//                            values.put(key, cursor.getString(columnIndex));
1835//                        } else if (cursor.isBlob(columnIndex)) {
1836//                            values.put(key, cursor.getBlob(columnIndex));
1837//                        }
1838                    }
1839                    contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
1840                } while (cursor.moveToNext());
1841
1842                return contact;
1843            }
1844
1845        }
1846    }
1847
1848    /**
1849     * Social status update columns.
1850     *
1851     * @see StatusUpdates
1852     * @see ContactsContract.Data
1853     */
1854    protected interface StatusColumns {
1855        /**
1856         * Contact's latest presence level.
1857         * <P>Type: INTEGER (one of the values below)</P>
1858         */
1859        public static final String PRESENCE = "mode";
1860
1861        /**
1862         * @deprecated use {@link #PRESENCE}
1863         */
1864        @Deprecated
1865        public static final String PRESENCE_STATUS = PRESENCE;
1866
1867        /**
1868         * An allowed value of {@link #PRESENCE}.
1869         */
1870        int OFFLINE = 0;
1871
1872        /**
1873         * An allowed value of {@link #PRESENCE}.
1874         */
1875        int INVISIBLE = 1;
1876
1877        /**
1878         * An allowed value of {@link #PRESENCE}.
1879         */
1880        int AWAY = 2;
1881
1882        /**
1883         * An allowed value of {@link #PRESENCE}.
1884         */
1885        int IDLE = 3;
1886
1887        /**
1888         * An allowed value of {@link #PRESENCE}.
1889         */
1890        int DO_NOT_DISTURB = 4;
1891
1892        /**
1893         * An allowed value of {@link #PRESENCE}.
1894         */
1895        int AVAILABLE = 5;
1896
1897        /**
1898         * Contact latest status update.
1899         * <p>Type: TEXT</p>
1900         */
1901        public static final String STATUS = "status";
1902
1903        /**
1904         * @deprecated use {@link #STATUS}
1905         */
1906        @Deprecated
1907        public static final String PRESENCE_CUSTOM_STATUS = STATUS;
1908
1909        /**
1910         * The absolute time in milliseconds when the latest status was inserted/updated.
1911         * <p>Type: NUMBER</p>
1912         */
1913        public static final String STATUS_TIMESTAMP = "status_ts";
1914
1915        /**
1916         * The package containing resources for this status: label and icon.
1917         * <p>Type: NUMBER</p>
1918         */
1919        public static final String STATUS_RES_PACKAGE = "status_res_package";
1920
1921        /**
1922         * The resource ID of the label describing the source of the status update, e.g. "Google
1923         * Talk".  This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
1924         * <p>Type: NUMBER</p>
1925         */
1926        public static final String STATUS_LABEL = "status_label";
1927
1928        /**
1929         * The resource ID of the icon for the source of the status update.
1930         * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
1931         * <p>Type: NUMBER</p>
1932         */
1933        public static final String STATUS_ICON = "status_icon";
1934    }
1935
1936    /**
1937     * Columns in the Data table.
1938     *
1939     * @see ContactsContract.Data
1940     */
1941    protected interface DataColumns {
1942        /**
1943         * The package name to use when creating {@link Resources} objects for
1944         * this data row. This value is only designed for use when building user
1945         * interfaces, and should not be used to infer the owner.
1946         *
1947         * @hide
1948         */
1949        public static final String RES_PACKAGE = "res_package";
1950
1951        /**
1952         * The MIME type of the item represented by this row.
1953         */
1954        public static final String MIMETYPE = "mimetype";
1955
1956        /**
1957         * A reference to the {@link RawContacts#_ID}
1958         * that this data belongs to.
1959         */
1960        public static final String RAW_CONTACT_ID = "raw_contact_id";
1961
1962        /**
1963         * Whether this is the primary entry of its kind for the raw contact it belongs to.
1964         * <P>Type: INTEGER (if set, non-0 means true)</P>
1965         */
1966        public static final String IS_PRIMARY = "is_primary";
1967
1968        /**
1969         * Whether this is the primary entry of its kind for the aggregate
1970         * contact it belongs to. Any data record that is "super primary" must
1971         * also be "primary".
1972         * <P>Type: INTEGER (if set, non-0 means true)</P>
1973         */
1974        public static final String IS_SUPER_PRIMARY = "is_super_primary";
1975
1976        /**
1977         * The version of this data record. This is a read-only value. The data column is
1978         * guaranteed to not change without the version going up. This value is monotonically
1979         * increasing.
1980         * <P>Type: INTEGER</P>
1981         */
1982        public static final String DATA_VERSION = "data_version";
1983
1984        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
1985        public static final String DATA1 = "data1";
1986        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
1987        public static final String DATA2 = "data2";
1988        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
1989        public static final String DATA3 = "data3";
1990        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
1991        public static final String DATA4 = "data4";
1992        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
1993        public static final String DATA5 = "data5";
1994        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
1995        public static final String DATA6 = "data6";
1996        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
1997        public static final String DATA7 = "data7";
1998        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
1999        public static final String DATA8 = "data8";
2000        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2001        public static final String DATA9 = "data9";
2002        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2003        public static final String DATA10 = "data10";
2004        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2005        public static final String DATA11 = "data11";
2006        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2007        public static final String DATA12 = "data12";
2008        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2009        public static final String DATA13 = "data13";
2010        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2011        public static final String DATA14 = "data14";
2012        /**
2013         * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
2014         * this field is used to store BLOBs (binary data).
2015         */
2016        public static final String DATA15 = "data15";
2017
2018        /** Generic column for use by sync adapters. */
2019        public static final String SYNC1 = "data_sync1";
2020        /** Generic column for use by sync adapters. */
2021        public static final String SYNC2 = "data_sync2";
2022        /** Generic column for use by sync adapters. */
2023        public static final String SYNC3 = "data_sync3";
2024        /** Generic column for use by sync adapters. */
2025        public static final String SYNC4 = "data_sync4";
2026    }
2027
2028    /**
2029     * Combines all columns returned by {@link ContactsContract.Data} table queries.
2030     *
2031     * @see ContactsContract.Data
2032     */
2033    protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
2034            RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
2035            ContactStatusColumns {
2036    }
2037
2038    /**
2039     * <p>
2040     * Constants for the data table, which contains data points tied to a raw
2041     * contact.  Each row of the data table is typically used to store a single
2042     * piece of contact
2043     * information (such as a phone number) and its
2044     * associated metadata (such as whether it is a work or home number).
2045     * </p>
2046     * <h3>Data kinds</h3>
2047     * <p>
2048     * Data is a generic table that can hold any kind of contact data.
2049     * The kind of data stored in a given row is specified by the row's
2050     * {@link #MIMETYPE} value, which determines the meaning of the
2051     * generic columns {@link #DATA1} through
2052     * {@link #DATA15}.
2053     * For example, if the data kind is
2054     * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
2055     * {@link #DATA1} stores the
2056     * phone number, but if the data kind is
2057     * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
2058     * stores the email address.
2059     * Sync adapters and applications can introduce their own data kinds.
2060     * </p>
2061     * <p>
2062     * ContactsContract defines a small number of pre-defined data kinds, e.g.
2063     * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
2064     * convenience, these classes define data kind specific aliases for DATA1 etc.
2065     * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
2066     * {@link ContactsContract.Data Data.DATA1}.
2067     * </p>
2068     * <p>
2069     * {@link #DATA1} is an indexed column and should be used for the data element that is
2070     * expected to be most frequently used in query selections. For example, in the
2071     * case of a row representing email addresses {@link #DATA1} should probably
2072     * be used for the email address itself, while {@link #DATA2} etc can be
2073     * used for auxiliary information like type of email address.
2074     * <p>
2075     * <p>
2076     * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
2077     * </p>
2078     * <p>
2079     * The sync adapter for a given account type must correctly handle every data type
2080     * used in the corresponding raw contacts.  Otherwise it could result in lost or
2081     * corrupted data.
2082     * </p>
2083     * <p>
2084     * Similarly, you should refrain from introducing new kinds of data for an other
2085     * party's account types. For example, if you add a data row for
2086     * "favorite song" to a raw contact owned by a Google account, it will not
2087     * get synced to the server, because the Google sync adapter does not know
2088     * how to handle this data kind. Thus new data kinds are typically
2089     * introduced along with new account types, i.e. new sync adapters.
2090     * </p>
2091     * <h3>Batch operations</h3>
2092     * <p>
2093     * Data rows can be inserted/updated/deleted using the traditional
2094     * {@link ContentResolver#insert}, {@link ContentResolver#update} and
2095     * {@link ContentResolver#delete} methods, however the newer mechanism based
2096     * on a batch of {@link ContentProviderOperation} will prove to be a better
2097     * choice in almost all cases. All operations in a batch are executed in a
2098     * single transaction, which ensures that the phone-side and server-side
2099     * state of a raw contact are always consistent. Also, the batch-based
2100     * approach is far more efficient: not only are the database operations
2101     * faster when executed in a single transaction, but also sending a batch of
2102     * commands to the content provider saves a lot of time on context switching
2103     * between your process and the process in which the content provider runs.
2104     * </p>
2105     * <p>
2106     * The flip side of using batched operations is that a large batch may lock
2107     * up the database for a long time preventing other applications from
2108     * accessing data and potentially causing ANRs ("Application Not Responding"
2109     * dialogs.)
2110     * </p>
2111     * <p>
2112     * To avoid such lockups of the database, make sure to insert "yield points"
2113     * in the batch. A yield point indicates to the content provider that before
2114     * executing the next operation it can commit the changes that have already
2115     * been made, yield to other requests, open another transaction and continue
2116     * processing operations. A yield point will not automatically commit the
2117     * transaction, but only if there is another request waiting on the
2118     * database. Normally a sync adapter should insert a yield point at the
2119     * beginning of each raw contact operation sequence in the batch. See
2120     * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
2121     * </p>
2122     * <h3>Operations</h3>
2123     * <dl>
2124     * <dt><b>Insert</b></dt>
2125     * <dd>
2126     * <p>
2127     * An individual data row can be inserted using the traditional
2128     * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
2129     * should always be inserted as a batch.
2130     * </p>
2131     * <p>
2132     * An example of a traditional insert:
2133     * <pre>
2134     * ContentValues values = new ContentValues();
2135     * values.put(Data.RAW_CONTACT_ID, rawContactId);
2136     * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
2137     * values.put(Phone.NUMBER, "1-800-GOOG-411");
2138     * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
2139     * values.put(Phone.LABEL, "free directory assistance");
2140     * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
2141     * </pre>
2142     * <p>
2143     * The same done using ContentProviderOperations:
2144     * <pre>
2145     * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
2146     * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
2147     *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
2148     *          .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
2149     *          .withValue(Phone.NUMBER, "1-800-GOOG-411")
2150     *          .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
2151     *          .withValue(Phone.LABEL, "free directory assistance")
2152     *          .build());
2153     * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2154     * </pre>
2155     * </p>
2156     * <dt><b>Update</b></dt>
2157     * <dd>
2158     * <p>
2159     * Just as with insert, update can be done incrementally or as a batch,
2160     * the batch mode being the preferred method:
2161     * <pre>
2162     * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
2163     * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
2164     *          .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
2165     *          .withValue(Email.DATA, "somebody@android.com")
2166     *          .build());
2167     * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2168     * </pre>
2169     * </p>
2170     * </dd>
2171     * <dt><b>Delete</b></dt>
2172     * <dd>
2173     * <p>
2174     * Just as with insert and update, deletion can be done either using the
2175     * {@link ContentResolver#delete} method or using a ContentProviderOperation:
2176     * <pre>
2177     * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
2178     * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
2179     *          .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
2180     *          .build());
2181     * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2182     * </pre>
2183     * </p>
2184     * </dd>
2185     * <dt><b>Query</b></dt>
2186     * <dd>
2187     * <p>
2188     * <dl>
2189     * <dt>Finding all Data of a given type for a given contact</dt>
2190     * <dd>
2191     * <pre>
2192     * Cursor c = getContentResolver().query(Data.CONTENT_URI,
2193     *          new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
2194     *          Data.CONTACT_ID + &quot;=?&quot; + " AND "
2195     *                  + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
2196     *          new String[] {String.valueOf(contactId)}, null);
2197     * </pre>
2198     * </p>
2199     * <p>
2200     * </dd>
2201     * <dt>Finding all Data of a given type for a given raw contact</dt>
2202     * <dd>
2203     * <pre>
2204     * Cursor c = getContentResolver().query(Data.CONTENT_URI,
2205     *          new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
2206     *          Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
2207     *                  + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
2208     *          new String[] {String.valueOf(rawContactId)}, null);
2209     * </pre>
2210     * </dd>
2211     * <dt>Finding all Data for a given raw contact</dt>
2212     * <dd>
2213     * Most sync adapters will want to read all data rows for a raw contact
2214     * along with the raw contact itself.  For that you should use the
2215     * {@link RawContactsEntity}. See also {@link RawContacts}.
2216     * </dd>
2217     * </dl>
2218     * </p>
2219     * </dd>
2220     * </dl>
2221     * <h2>Columns</h2>
2222     * <p>
2223     * Many columns are available via a {@link Data#CONTENT_URI} query.  For best performance you
2224     * should explicitly specify a projection to only those columns that you need.
2225     * </p>
2226     * <table class="jd-sumtable">
2227     * <tr>
2228     * <th colspan='4'>Data</th>
2229     * </tr>
2230     * <tr>
2231     * <td style="width: 7em;">long</td>
2232     * <td style="width: 20em;">{@link #_ID}</td>
2233     * <td style="width: 5em;">read-only</td>
2234     * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
2235     * it would be a bad idea to delete and reinsert a data row. A sync adapter should
2236     * always do an update instead.</td>
2237     * </tr>
2238     * <tr>
2239     * <td>String</td>
2240     * <td>{@link #MIMETYPE}</td>
2241     * <td>read/write-once</td>
2242     * <td>
2243     * <p>The MIME type of the item represented by this row. Examples of common
2244     * MIME types are:
2245     * <ul>
2246     * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
2247     * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
2248     * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
2249     * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
2250     * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
2251     * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
2252     * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
2253     * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
2254     * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
2255     * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
2256     * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
2257     * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
2258     * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
2259     * </ul>
2260     * </p>
2261     * </td>
2262     * </tr>
2263     * <tr>
2264     * <td>long</td>
2265     * <td>{@link #RAW_CONTACT_ID}</td>
2266     * <td>read/write-once</td>
2267     * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
2268     * </tr>
2269     * <tr>
2270     * <td>int</td>
2271     * <td>{@link #IS_PRIMARY}</td>
2272     * <td>read/write</td>
2273     * <td>Whether this is the primary entry of its kind for the raw contact it belongs to.
2274     * "1" if true, "0" if false.
2275     * </td>
2276     * </tr>
2277     * <tr>
2278     * <td>int</td>
2279     * <td>{@link #IS_SUPER_PRIMARY}</td>
2280     * <td>read/write</td>
2281     * <td>Whether this is the primary entry of its kind for the aggregate
2282     * contact it belongs to. Any data record that is "super primary" must
2283     * also be "primary".  For example, the super-primary entry may be
2284     * interpreted as the default contact value of its kind (for example,
2285     * the default phone number to use for the contact).</td>
2286     * </tr>
2287     * <tr>
2288     * <td>int</td>
2289     * <td>{@link #DATA_VERSION}</td>
2290     * <td>read-only</td>
2291     * <td>The version of this data record. Whenever the data row changes
2292     * the version goes up. This value is monotonically increasing.</td>
2293     * </tr>
2294     * <tr>
2295     * <td>Any type</td>
2296     * <td>
2297     * {@link #DATA1}<br>
2298     * {@link #DATA2}<br>
2299     * {@link #DATA3}<br>
2300     * {@link #DATA4}<br>
2301     * {@link #DATA5}<br>
2302     * {@link #DATA6}<br>
2303     * {@link #DATA7}<br>
2304     * {@link #DATA8}<br>
2305     * {@link #DATA9}<br>
2306     * {@link #DATA10}<br>
2307     * {@link #DATA11}<br>
2308     * {@link #DATA12}<br>
2309     * {@link #DATA13}<br>
2310     * {@link #DATA14}<br>
2311     * {@link #DATA15}
2312     * </td>
2313     * <td>read/write</td>
2314     * <td>
2315     * <p>
2316     * Generic data columns.  The meaning of each column is determined by the
2317     * {@link #MIMETYPE}.  By convention, {@link #DATA15} is used for storing
2318     * BLOBs (binary data).
2319     * </p>
2320     * <p>
2321     * Data columns whose meaning is not explicitly defined for a given MIMETYPE
2322     * should not be used.  There is no guarantee that any sync adapter will
2323     * preserve them.  Sync adapters themselves should not use such columns either,
2324     * but should instead use {@link #SYNC1}-{@link #SYNC4}.
2325     * </p>
2326     * </td>
2327     * </tr>
2328     * <tr>
2329     * <td>Any type</td>
2330     * <td>
2331     * {@link #SYNC1}<br>
2332     * {@link #SYNC2}<br>
2333     * {@link #SYNC3}<br>
2334     * {@link #SYNC4}
2335     * </td>
2336     * <td>read/write</td>
2337     * <td>Generic columns for use by sync adapters. For example, a Photo row
2338     * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
2339     * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
2340     * </tr>
2341     * </table>
2342     *
2343     * <p>
2344     * Some columns from the most recent associated status update are also available
2345     * through an implicit join.
2346     * </p>
2347     * <table class="jd-sumtable">
2348     * <tr>
2349     * <th colspan='4'>Join with {@link StatusUpdates}</th>
2350     * </tr>
2351     * <tr>
2352     * <td style="width: 7em;">int</td>
2353     * <td style="width: 20em;">{@link #PRESENCE}</td>
2354     * <td style="width: 5em;">read-only</td>
2355     * <td>IM presence status linked to this data row. Compare with
2356     * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
2357     * all IM rows. See {@link StatusUpdates} for individual status definitions.
2358     * The provider may choose not to store this value
2359     * in persistent storage. The expectation is that presence status will be
2360     * updated on a regular basic.
2361     * </td>
2362     * </tr>
2363     * <tr>
2364     * <td>String</td>
2365     * <td>{@link #STATUS}</td>
2366     * <td>read-only</td>
2367     * <td>Latest status update linked with this data row.</td>
2368     * </tr>
2369     * <tr>
2370     * <td>long</td>
2371     * <td>{@link #STATUS_TIMESTAMP}</td>
2372     * <td>read-only</td>
2373     * <td>The absolute time in milliseconds when the latest status was
2374     * inserted/updated for this data row.</td>
2375     * </tr>
2376     * <tr>
2377     * <td>String</td>
2378     * <td>{@link #STATUS_RES_PACKAGE}</td>
2379     * <td>read-only</td>
2380     * <td>The package containing resources for this status: label and icon.</td>
2381     * </tr>
2382     * <tr>
2383     * <td>long</td>
2384     * <td>{@link #STATUS_LABEL}</td>
2385     * <td>read-only</td>
2386     * <td>The resource ID of the label describing the source of status update linked
2387     * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
2388     * </tr>
2389     * <tr>
2390     * <td>long</td>
2391     * <td>{@link #STATUS_ICON}</td>
2392     * <td>read-only</td>
2393     * <td>The resource ID of the icon for the source of the status update linked
2394     * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
2395     * </tr>
2396     * </table>
2397     *
2398     * <p>
2399     * Some columns from the associated raw contact are also available through an
2400     * implicit join.  The other columns are excluded as uninteresting in this
2401     * context.
2402     * </p>
2403     *
2404     * <table class="jd-sumtable">
2405     * <tr>
2406     * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
2407     * </tr>
2408     * <tr>
2409     * <td style="width: 7em;">long</td>
2410     * <td style="width: 20em;">{@link #CONTACT_ID}</td>
2411     * <td style="width: 5em;">read-only</td>
2412     * <td>The id of the row in the {@link Contacts} table that this data belongs
2413     * to.</td>
2414     * </tr>
2415     * <tr>
2416     * <td>int</td>
2417     * <td>{@link #AGGREGATION_MODE}</td>
2418     * <td>read-only</td>
2419     * <td>See {@link RawContacts}.</td>
2420     * </tr>
2421     * <tr>
2422     * <td>int</td>
2423     * <td>{@link #DELETED}</td>
2424     * <td>read-only</td>
2425     * <td>See {@link RawContacts}.</td>
2426     * </tr>
2427     * </table>
2428     *
2429     * <p>
2430     * The ID column for the associated aggregated contact table
2431     * {@link ContactsContract.Contacts} is available
2432     * via the implicit join to the {@link RawContacts} table, see above.
2433     * The remaining columns from this table are also
2434     * available, through an implicit join.  This
2435     * facilitates lookup by
2436     * the value of a single data element, such as the email address.
2437     * </p>
2438     *
2439     * <table class="jd-sumtable">
2440     * <tr>
2441     * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
2442     * </tr>
2443     * <tr>
2444     * <td style="width: 7em;">String</td>
2445     * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
2446     * <td style="width: 5em;">read-only</td>
2447     * <td>See {@link ContactsContract.Contacts}</td>
2448     * </tr>
2449     * <tr>
2450     * <td>String</td>
2451     * <td>{@link #DISPLAY_NAME}</td>
2452     * <td>read-only</td>
2453     * <td>See {@link ContactsContract.Contacts}</td>
2454     * </tr>
2455     * <tr>
2456     * <td>long</td>
2457     * <td>{@link #PHOTO_ID}</td>
2458     * <td>read-only</td>
2459     * <td>See {@link ContactsContract.Contacts}.</td>
2460     * </tr>
2461     * <tr>
2462     * <td>int</td>
2463     * <td>{@link #IN_VISIBLE_GROUP}</td>
2464     * <td>read-only</td>
2465     * <td>See {@link ContactsContract.Contacts}.</td>
2466     * </tr>
2467     * <tr>
2468     * <td>int</td>
2469     * <td>{@link #HAS_PHONE_NUMBER}</td>
2470     * <td>read-only</td>
2471     * <td>See {@link ContactsContract.Contacts}.</td>
2472     * </tr>
2473     * <tr>
2474     * <td>int</td>
2475     * <td>{@link #TIMES_CONTACTED}</td>
2476     * <td>read-only</td>
2477     * <td>See {@link ContactsContract.Contacts}.</td>
2478     * </tr>
2479     * <tr>
2480     * <td>long</td>
2481     * <td>{@link #LAST_TIME_CONTACTED}</td>
2482     * <td>read-only</td>
2483     * <td>See {@link ContactsContract.Contacts}.</td>
2484     * </tr>
2485     * <tr>
2486     * <td>int</td>
2487     * <td>{@link #STARRED}</td>
2488     * <td>read-only</td>
2489     * <td>See {@link ContactsContract.Contacts}.</td>
2490     * </tr>
2491     * <tr>
2492     * <td>String</td>
2493     * <td>{@link #CUSTOM_RINGTONE}</td>
2494     * <td>read-only</td>
2495     * <td>See {@link ContactsContract.Contacts}.</td>
2496     * </tr>
2497     * <tr>
2498     * <td>int</td>
2499     * <td>{@link #SEND_TO_VOICEMAIL}</td>
2500     * <td>read-only</td>
2501     * <td>See {@link ContactsContract.Contacts}.</td>
2502     * </tr>
2503     * <tr>
2504     * <td>int</td>
2505     * <td>{@link #CONTACT_PRESENCE}</td>
2506     * <td>read-only</td>
2507     * <td>See {@link ContactsContract.Contacts}.</td>
2508     * </tr>
2509     * <tr>
2510     * <td>String</td>
2511     * <td>{@link #CONTACT_STATUS}</td>
2512     * <td>read-only</td>
2513     * <td>See {@link ContactsContract.Contacts}.</td>
2514     * </tr>
2515     * <tr>
2516     * <td>long</td>
2517     * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
2518     * <td>read-only</td>
2519     * <td>See {@link ContactsContract.Contacts}.</td>
2520     * </tr>
2521     * <tr>
2522     * <td>String</td>
2523     * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
2524     * <td>read-only</td>
2525     * <td>See {@link ContactsContract.Contacts}.</td>
2526     * </tr>
2527     * <tr>
2528     * <td>long</td>
2529     * <td>{@link #CONTACT_STATUS_LABEL}</td>
2530     * <td>read-only</td>
2531     * <td>See {@link ContactsContract.Contacts}.</td>
2532     * </tr>
2533     * <tr>
2534     * <td>long</td>
2535     * <td>{@link #CONTACT_STATUS_ICON}</td>
2536     * <td>read-only</td>
2537     * <td>See {@link ContactsContract.Contacts}.</td>
2538     * </tr>
2539     * </table>
2540     */
2541    public final static class Data implements DataColumnsWithJoins {
2542        /**
2543         * This utility class cannot be instantiated
2544         */
2545        private Data() {}
2546
2547        /**
2548         * The content:// style URI for this table, which requests a directory
2549         * of data rows matching the selection criteria.
2550         */
2551        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
2552
2553        /**
2554         * The MIME type of the results from {@link #CONTENT_URI}.
2555         */
2556        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
2557
2558        /**
2559         * <p>
2560         * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
2561         * Data.CONTENT_URI contains only exportable data.
2562         * </p>
2563         * <p>
2564         * This flag is useful (currently) only for vCard exporter in Contacts app, which
2565         * needs to exclude "un-exportable" data from available data to export, while
2566         * Contacts app itself has priviledge to access all data including "un-exportable"
2567         * ones and providers return all of them regardless of the callers' intention.
2568         * </p>
2569         * <p>
2570         * Type: INTEGER
2571         * </p>
2572         *
2573         * @hide Maybe available only in Eclair and not really ready for public use.
2574         * TODO: remove, or implement this feature completely. As of now (Eclair),
2575         * we only use this flag in queryEntities(), not query().
2576         */
2577        public static final String FOR_EXPORT_ONLY = "for_export_only";
2578
2579        /**
2580         * <p>
2581         * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
2582         * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
2583         * entry of the given {@link ContactsContract.Data} entry.
2584         * </p>
2585         * <p>
2586         * Returns the Uri for the contact in the first entry returned by
2587         * {@link ContentResolver#query(Uri, String[], String, String[], String)}
2588         * for the provided {@code dataUri}.  If the query returns null or empty
2589         * results, silently returns null.
2590         * </p>
2591         */
2592        public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
2593            final Cursor cursor = resolver.query(dataUri, new String[] {
2594                    RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
2595            }, null, null, null);
2596
2597            Uri lookupUri = null;
2598            try {
2599                if (cursor != null && cursor.moveToFirst()) {
2600                    final long contactId = cursor.getLong(0);
2601                    final String lookupKey = cursor.getString(1);
2602                    return Contacts.getLookupUri(contactId, lookupKey);
2603                }
2604            } finally {
2605                if (cursor != null) cursor.close();
2606            }
2607            return lookupUri;
2608        }
2609    }
2610
2611    /**
2612     * <p>
2613     * Constants for the raw contacts entities table, which can be thought of as
2614     * an outer join of the raw_contacts table with the data table.  It is a strictly
2615     * read-only table.
2616     * </p>
2617     * <p>
2618     * If a raw contact has data rows, the RawContactsEntity cursor will contain
2619     * a one row for each data row. If the raw contact has no data rows, the
2620     * cursor will still contain one row with the raw contact-level information
2621     * and nulls for data columns.
2622     *
2623     * <pre>
2624     * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
2625     * Cursor c = getContentResolver().query(entityUri,
2626     *          new String[]{
2627     *              RawContactsEntity.SOURCE_ID,
2628     *              RawContactsEntity.DATA_ID,
2629     *              RawContactsEntity.MIMETYPE,
2630     *              RawContactsEntity.DATA1
2631     *          }, null, null, null);
2632     * try {
2633     *     while (c.moveToNext()) {
2634     *         String sourceId = c.getString(0);
2635     *         if (!c.isNull(1)) {
2636     *             String mimeType = c.getString(2);
2637     *             String data = c.getString(3);
2638     *             ...
2639     *         }
2640     *     }
2641     * } finally {
2642     *     c.close();
2643     * }
2644     * </pre>
2645     *
2646     * <h3>Columns</h3>
2647     * RawContactsEntity has a combination of RawContact and Data columns.
2648     *
2649     * <table class="jd-sumtable">
2650     * <tr>
2651     * <th colspan='4'>RawContacts</th>
2652     * </tr>
2653     * <tr>
2654     * <td style="width: 7em;">long</td>
2655     * <td style="width: 20em;">{@link #_ID}</td>
2656     * <td style="width: 5em;">read-only</td>
2657     * <td>Raw contact row ID. See {@link RawContacts}.</td>
2658     * </tr>
2659     * <tr>
2660     * <td>long</td>
2661     * <td>{@link #CONTACT_ID}</td>
2662     * <td>read-only</td>
2663     * <td>See {@link RawContacts}.</td>
2664     * </tr>
2665     * <tr>
2666     * <td>int</td>
2667     * <td>{@link #AGGREGATION_MODE}</td>
2668     * <td>read-only</td>
2669     * <td>See {@link RawContacts}.</td>
2670     * </tr>
2671     * <tr>
2672     * <td>int</td>
2673     * <td>{@link #DELETED}</td>
2674     * <td>read-only</td>
2675     * <td>See {@link RawContacts}.</td>
2676     * </tr>
2677     * </table>
2678     *
2679     * <table class="jd-sumtable">
2680     * <tr>
2681     * <th colspan='4'>Data</th>
2682     * </tr>
2683     * <tr>
2684     * <td style="width: 7em;">long</td>
2685     * <td style="width: 20em;">{@link #DATA_ID}</td>
2686     * <td style="width: 5em;">read-only</td>
2687     * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
2688     * </tr>
2689     * <tr>
2690     * <td>String</td>
2691     * <td>{@link #MIMETYPE}</td>
2692     * <td>read-only</td>
2693     * <td>See {@link ContactsContract.Data}.</td>
2694     * </tr>
2695     * <tr>
2696     * <td>int</td>
2697     * <td>{@link #IS_PRIMARY}</td>
2698     * <td>read-only</td>
2699     * <td>See {@link ContactsContract.Data}.</td>
2700     * </tr>
2701     * <tr>
2702     * <td>int</td>
2703     * <td>{@link #IS_SUPER_PRIMARY}</td>
2704     * <td>read-only</td>
2705     * <td>See {@link ContactsContract.Data}.</td>
2706     * </tr>
2707     * <tr>
2708     * <td>int</td>
2709     * <td>{@link #DATA_VERSION}</td>
2710     * <td>read-only</td>
2711     * <td>See {@link ContactsContract.Data}.</td>
2712     * </tr>
2713     * <tr>
2714     * <td>Any type</td>
2715     * <td>
2716     * {@link #DATA1}<br>
2717     * {@link #DATA2}<br>
2718     * {@link #DATA3}<br>
2719     * {@link #DATA4}<br>
2720     * {@link #DATA5}<br>
2721     * {@link #DATA6}<br>
2722     * {@link #DATA7}<br>
2723     * {@link #DATA8}<br>
2724     * {@link #DATA9}<br>
2725     * {@link #DATA10}<br>
2726     * {@link #DATA11}<br>
2727     * {@link #DATA12}<br>
2728     * {@link #DATA13}<br>
2729     * {@link #DATA14}<br>
2730     * {@link #DATA15}
2731     * </td>
2732     * <td>read-only</td>
2733     * <td>See {@link ContactsContract.Data}.</td>
2734     * </tr>
2735     * <tr>
2736     * <td>Any type</td>
2737     * <td>
2738     * {@link #SYNC1}<br>
2739     * {@link #SYNC2}<br>
2740     * {@link #SYNC3}<br>
2741     * {@link #SYNC4}
2742     * </td>
2743     * <td>read-only</td>
2744     * <td>See {@link ContactsContract.Data}.</td>
2745     * </tr>
2746     * </table>
2747     */
2748    public final static class RawContactsEntity
2749            implements BaseColumns, DataColumns, RawContactsColumns {
2750        /**
2751         * This utility class cannot be instantiated
2752         */
2753        private RawContactsEntity() {}
2754
2755        /**
2756         * The content:// style URI for this table
2757         */
2758        public static final Uri CONTENT_URI =
2759                Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
2760
2761        /**
2762         * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
2763         */
2764        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
2765
2766        /**
2767         * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
2768         * Data.CONTENT_URI contains only exportable data.
2769         *
2770         * This flag is useful (currently) only for vCard exporter in Contacts app, which
2771         * needs to exclude "un-exportable" data from available data to export, while
2772         * Contacts app itself has priviledge to access all data including "un-expotable"
2773         * ones and providers return all of them regardless of the callers' intention.
2774         * <P>Type: INTEGER</p>
2775         *
2776         * @hide Maybe available only in Eclair and not really ready for public use.
2777         * TODO: remove, or implement this feature completely. As of now (Eclair),
2778         * we only use this flag in queryEntities(), not query().
2779         */
2780        public static final String FOR_EXPORT_ONLY = "for_export_only";
2781
2782        /**
2783         * The ID of the data column. The value will be null if this raw contact has no data rows.
2784         * <P>Type: INTEGER</P>
2785         */
2786        public static final String DATA_ID = "data_id";
2787    }
2788
2789    /**
2790     * @see PhoneLookup
2791     */
2792    protected interface PhoneLookupColumns {
2793        /**
2794         * The phone number as the user entered it.
2795         * <P>Type: TEXT</P>
2796         */
2797        public static final String NUMBER = "number";
2798
2799        /**
2800         * The type of phone number, for example Home or Work.
2801         * <P>Type: INTEGER</P>
2802         */
2803        public static final String TYPE = "type";
2804
2805        /**
2806         * The user defined label for the phone number.
2807         * <P>Type: TEXT</P>
2808         */
2809        public static final String LABEL = "label";
2810    }
2811
2812    /**
2813     * A table that represents the result of looking up a phone number, for
2814     * example for caller ID. To perform a lookup you must append the number you
2815     * want to find to {@link #CONTENT_FILTER_URI}.  This query is highly
2816     * optimized.
2817     * <pre>
2818     * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
2819     * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
2820     * </pre>
2821     *
2822     * <h3>Columns</h3>
2823     *
2824     * <table class="jd-sumtable">
2825     * <tr>
2826     * <th colspan='4'>PhoneLookup</th>
2827     * </tr>
2828     * <tr>
2829     * <td>long</td>
2830     * <td>{@link #_ID}</td>
2831     * <td>read-only</td>
2832     * <td>Data row ID.</td>
2833     * </tr>
2834     * <tr>
2835     * <td>String</td>
2836     * <td>{@link #NUMBER}</td>
2837     * <td>read-only</td>
2838     * <td>Phone number.</td>
2839     * </tr>
2840     * <tr>
2841     * <td>String</td>
2842     * <td>{@link #TYPE}</td>
2843     * <td>read-only</td>
2844     * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
2845     * </tr>
2846     * <tr>
2847     * <td>String</td>
2848     * <td>{@link #LABEL}</td>
2849     * <td>read-only</td>
2850     * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
2851     * </tr>
2852     * </table>
2853     * <p>
2854     * Columns from the Contacts table are also available through a join.
2855     * </p>
2856     * <table class="jd-sumtable">
2857     * <tr>
2858     * <th colspan='4'>Join with {@link Contacts}</th>
2859     * </tr>
2860     * <tr>
2861     * <td>String</td>
2862     * <td>{@link #LOOKUP_KEY}</td>
2863     * <td>read-only</td>
2864     * <td>See {@link ContactsContract.Contacts}</td>
2865     * </tr>
2866     * <tr>
2867     * <td>String</td>
2868     * <td>{@link #DISPLAY_NAME}</td>
2869     * <td>read-only</td>
2870     * <td>See {@link ContactsContract.Contacts}</td>
2871     * </tr>
2872     * <tr>
2873     * <td>long</td>
2874     * <td>{@link #PHOTO_ID}</td>
2875     * <td>read-only</td>
2876     * <td>See {@link ContactsContract.Contacts}.</td>
2877     * </tr>
2878     * <tr>
2879     * <td>int</td>
2880     * <td>{@link #IN_VISIBLE_GROUP}</td>
2881     * <td>read-only</td>
2882     * <td>See {@link ContactsContract.Contacts}.</td>
2883     * </tr>
2884     * <tr>
2885     * <td>int</td>
2886     * <td>{@link #HAS_PHONE_NUMBER}</td>
2887     * <td>read-only</td>
2888     * <td>See {@link ContactsContract.Contacts}.</td>
2889     * </tr>
2890     * <tr>
2891     * <td>int</td>
2892     * <td>{@link #TIMES_CONTACTED}</td>
2893     * <td>read-only</td>
2894     * <td>See {@link ContactsContract.Contacts}.</td>
2895     * </tr>
2896     * <tr>
2897     * <td>long</td>
2898     * <td>{@link #LAST_TIME_CONTACTED}</td>
2899     * <td>read-only</td>
2900     * <td>See {@link ContactsContract.Contacts}.</td>
2901     * </tr>
2902     * <tr>
2903     * <td>int</td>
2904     * <td>{@link #STARRED}</td>
2905     * <td>read-only</td>
2906     * <td>See {@link ContactsContract.Contacts}.</td>
2907     * </tr>
2908     * <tr>
2909     * <td>String</td>
2910     * <td>{@link #CUSTOM_RINGTONE}</td>
2911     * <td>read-only</td>
2912     * <td>See {@link ContactsContract.Contacts}.</td>
2913     * </tr>
2914     * <tr>
2915     * <td>int</td>
2916     * <td>{@link #SEND_TO_VOICEMAIL}</td>
2917     * <td>read-only</td>
2918     * <td>See {@link ContactsContract.Contacts}.</td>
2919     * </tr>
2920     * </table>
2921     */
2922    public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
2923            ContactsColumns, ContactOptionsColumns {
2924        /**
2925         * This utility class cannot be instantiated
2926         */
2927        private PhoneLookup() {}
2928
2929        /**
2930         * The content:// style URI for this table. Append the phone number you want to lookup
2931         * to this URI and query it to perform a lookup. For example:
2932         * <pre>
2933         * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, Uri.encode(phoneNumber));
2934         * </pre>
2935         */
2936        public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
2937                "phone_lookup");
2938    }
2939
2940    /**
2941     * Additional data mixed in with {@link StatusColumns} to link
2942     * back to specific {@link ContactsContract.Data#_ID} entries.
2943     *
2944     * @see StatusUpdates
2945     */
2946    protected interface PresenceColumns {
2947
2948        /**
2949         * Reference to the {@link Data#_ID} entry that owns this presence.
2950         * <P>Type: INTEGER</P>
2951         */
2952        public static final String DATA_ID = "presence_data_id";
2953
2954        /**
2955         * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
2956         * <p>Type: NUMBER</p>
2957         */
2958        public static final String PROTOCOL = "protocol";
2959
2960        /**
2961         * Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
2962         * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
2963         * omitted if {@link #PROTOCOL} value is not
2964         * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
2965         *
2966         * <p>Type: NUMBER</p>
2967         */
2968        public static final String CUSTOM_PROTOCOL = "custom_protocol";
2969
2970        /**
2971         * The IM handle the presence item is for. The handle is scoped to
2972         * {@link #PROTOCOL}.
2973         * <P>Type: TEXT</P>
2974         */
2975        public static final String IM_HANDLE = "im_handle";
2976
2977        /**
2978         * The IM account for the local user that the presence data came from.
2979         * <P>Type: TEXT</P>
2980         */
2981        public static final String IM_ACCOUNT = "im_account";
2982    }
2983
2984    /**
2985     * <p>
2986     * A status update is linked to a {@link ContactsContract.Data} row and captures
2987     * the user's latest status update via the corresponding source, e.g.
2988     * "Having lunch" via "Google Talk".
2989     * </p>
2990     * <p>
2991     * There are two ways a status update can be inserted: by explicitly linking
2992     * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
2993     * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
2994     * {@link #IM_HANDLE}.  There is no difference between insert and update, you can use
2995     * either.
2996     * </p>
2997     * <p>
2998     * You cannot use {@link ContentResolver#update} to change a status, but
2999     * {@link ContentResolver#insert} will replace the latests status if it already
3000     * exists.
3001     * </p>
3002     * <p>
3003     * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
3004     * for multiple contacts at once.
3005     * </p>
3006     *
3007     * <h3>Columns</h3>
3008     * <table class="jd-sumtable">
3009     * <tr>
3010     * <th colspan='4'>StatusUpdates</th>
3011     * </tr>
3012     * <tr>
3013     * <td>long</td>
3014     * <td>{@link #DATA_ID}</td>
3015     * <td>read/write</td>
3016     * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
3017     * field is <i>not</i> specified, the provider will attempt to find a data row
3018     * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
3019     * {@link #IM_HANDLE} columns.
3020     * </td>
3021     * </tr>
3022     * <tr>
3023     * <td>long</td>
3024     * <td>{@link #PROTOCOL}</td>
3025     * <td>read/write</td>
3026     * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
3027     * </tr>
3028     * <tr>
3029     * <td>String</td>
3030     * <td>{@link #CUSTOM_PROTOCOL}</td>
3031     * <td>read/write</td>
3032     * <td>Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
3033     * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
3034     * omitted if {@link #PROTOCOL} value is not
3035     * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
3036     * </tr>
3037     * <tr>
3038     * <td>String</td>
3039     * <td>{@link #IM_HANDLE}</td>
3040     * <td>read/write</td>
3041     * <td> The IM handle the presence item is for. The handle is scoped to
3042     * {@link #PROTOCOL}.</td>
3043     * </tr>
3044     * <tr>
3045     * <td>String</td>
3046     * <td>{@link #IM_ACCOUNT}</td>
3047     * <td>read/write</td>
3048     * <td>The IM account for the local user that the presence data came from.</td>
3049     * </tr>
3050     * <tr>
3051     * <td>int</td>
3052     * <td>{@link #PRESENCE}</td>
3053     * <td>read/write</td>
3054     * <td>Contact IM presence status. The allowed values are:
3055     * <p>
3056     * <ul>
3057     * <li>{@link #OFFLINE}</li>
3058     * <li>{@link #INVISIBLE}</li>
3059     * <li>{@link #AWAY}</li>
3060     * <li>{@link #IDLE}</li>
3061     * <li>{@link #DO_NOT_DISTURB}</li>
3062     * <li>{@link #AVAILABLE}</li>
3063     * </ul>
3064     * </p>
3065     * <p>
3066     * Since presence status is inherently volatile, the content provider
3067     * may choose not to store this field in long-term storage.
3068     * </p>
3069     * </td>
3070     * </tr>
3071     * <tr>
3072     * <td>String</td>
3073     * <td>{@link #STATUS}</td>
3074     * <td>read/write</td>
3075     * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
3076     * </tr>
3077     * <tr>
3078     * <td>long</td>
3079     * <td>{@link #STATUS_TIMESTAMP}</td>
3080     * <td>read/write</td>
3081     * <td>The absolute time in milliseconds when the status was
3082     * entered by the user. If this value is not provided, the provider will follow
3083     * this logic: if there was no prior status update, the value will be left as null.
3084     * If there was a prior status update, the provider will default this field
3085     * to the current time.</td>
3086     * </tr>
3087     * <tr>
3088     * <td>String</td>
3089     * <td>{@link #STATUS_RES_PACKAGE}</td>
3090     * <td>read/write</td>
3091     * <td> The package containing resources for this status: label and icon.</td>
3092     * </tr>
3093     * <tr>
3094     * <td>long</td>
3095     * <td>{@link #STATUS_LABEL}</td>
3096     * <td>read/write</td>
3097     * <td>The resource ID of the label describing the source of contact status,
3098     * e.g. "Google Talk". This resource is scoped by the
3099     * {@link #STATUS_RES_PACKAGE}.</td>
3100     * </tr>
3101     * <tr>
3102     * <td>long</td>
3103     * <td>{@link #STATUS_ICON}</td>
3104     * <td>read/write</td>
3105     * <td>The resource ID of the icon for the source of contact status. This
3106     * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
3107     * </tr>
3108     * </table>
3109     */
3110    public static class StatusUpdates implements StatusColumns, PresenceColumns {
3111
3112        /**
3113         * This utility class cannot be instantiated
3114         */
3115        private StatusUpdates() {}
3116
3117        /**
3118         * The content:// style URI for this table
3119         */
3120        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
3121
3122        /**
3123         * Gets the resource ID for the proper presence icon.
3124         *
3125         * @param status the status to get the icon for
3126         * @return the resource ID for the proper presence icon
3127         */
3128        public static final int getPresenceIconResourceId(int status) {
3129            switch (status) {
3130                case AVAILABLE:
3131                    return android.R.drawable.presence_online;
3132                case IDLE:
3133                case AWAY:
3134                    return android.R.drawable.presence_away;
3135                case DO_NOT_DISTURB:
3136                    return android.R.drawable.presence_busy;
3137                case INVISIBLE:
3138                    return android.R.drawable.presence_invisible;
3139                case OFFLINE:
3140                default:
3141                    return android.R.drawable.presence_offline;
3142            }
3143        }
3144
3145        /**
3146         * Returns the precedence of the status code the higher number being the higher precedence.
3147         *
3148         * @param status The status code.
3149         * @return An integer representing the precedence, 0 being the lowest.
3150         */
3151        public static final int getPresencePrecedence(int status) {
3152            // Keep this function here incase we want to enforce a different precedence than the
3153            // natural order of the status constants.
3154            return status;
3155        }
3156
3157        /**
3158         * The MIME type of {@link #CONTENT_URI} providing a directory of
3159         * status update details.
3160         */
3161        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
3162
3163        /**
3164         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
3165         * status update detail.
3166         */
3167        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
3168    }
3169
3170    /**
3171     * @deprecated This old name was never meant to be made public. Do not use.
3172     */
3173    @Deprecated
3174    public static final class Presence extends StatusUpdates {
3175
3176    }
3177
3178    /**
3179     * Container for definitions of common data types stored in the {@link ContactsContract.Data}
3180     * table.
3181     */
3182    public static final class CommonDataKinds {
3183        /**
3184         * This utility class cannot be instantiated
3185         */
3186        private CommonDataKinds() {}
3187
3188        /**
3189         * The {@link Data#RES_PACKAGE} value for common data that should be
3190         * shown using a default style.
3191         *
3192         * @hide RES_PACKAGE is hidden
3193         */
3194        public static final String PACKAGE_COMMON = "common";
3195
3196        /**
3197         * The base types that all "Typed" data kinds support.
3198         */
3199        public interface BaseTypes {
3200            /**
3201             * A custom type. The custom label should be supplied by user.
3202             */
3203            public static int TYPE_CUSTOM = 0;
3204        }
3205
3206        /**
3207         * Columns common across the specific types.
3208         */
3209        protected interface CommonColumns extends BaseTypes {
3210            /**
3211             * The data for the contact method.
3212             * <P>Type: TEXT</P>
3213             */
3214            public static final String DATA = DataColumns.DATA1;
3215
3216            /**
3217             * The type of data, for example Home or Work.
3218             * <P>Type: INTEGER</P>
3219             */
3220            public static final String TYPE = DataColumns.DATA2;
3221
3222            /**
3223             * The user defined label for the the contact method.
3224             * <P>Type: TEXT</P>
3225             */
3226            public static final String LABEL = DataColumns.DATA3;
3227        }
3228
3229        /**
3230         * A data kind representing the contact's proper name. You can use all
3231         * columns defined for {@link ContactsContract.Data} as well as the following aliases.
3232         *
3233         * <h2>Column aliases</h2>
3234         * <table class="jd-sumtable">
3235         * <tr>
3236         * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
3237         * </tr>
3238         * <tr>
3239         * <td>String</td>
3240         * <td>{@link #DISPLAY_NAME}</td>
3241         * <td>{@link #DATA1}</td>
3242         * <td></td>
3243         * </tr>
3244         * <tr>
3245         * <td>String</td>
3246         * <td>{@link #GIVEN_NAME}</td>
3247         * <td>{@link #DATA2}</td>
3248         * <td></td>
3249         * </tr>
3250         * <tr>
3251         * <td>String</td>
3252         * <td>{@link #FAMILY_NAME}</td>
3253         * <td>{@link #DATA3}</td>
3254         * <td></td>
3255         * </tr>
3256         * <tr>
3257         * <td>String</td>
3258         * <td>{@link #PREFIX}</td>
3259         * <td>{@link #DATA4}</td>
3260         * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
3261         * </tr>
3262         * <tr>
3263         * <td>String</td>
3264         * <td>{@link #MIDDLE_NAME}</td>
3265         * <td>{@link #DATA5}</td>
3266         * <td></td>
3267         * </tr>
3268         * <tr>
3269         * <td>String</td>
3270         * <td>{@link #SUFFIX}</td>
3271         * <td>{@link #DATA6}</td>
3272         * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
3273         * </tr>
3274         * <tr>
3275         * <td>String</td>
3276         * <td>{@link #PHONETIC_GIVEN_NAME}</td>
3277         * <td>{@link #DATA7}</td>
3278         * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
3279         * </tr>
3280         * <tr>
3281         * <td>String</td>
3282         * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
3283         * <td>{@link #DATA8}</td>
3284         * <td></td>
3285         * </tr>
3286         * <tr>
3287         * <td>String</td>
3288         * <td>{@link #PHONETIC_FAMILY_NAME}</td>
3289         * <td>{@link #DATA9}</td>
3290         * <td></td>
3291         * </tr>
3292         * </table>
3293         */
3294        public static final class StructuredName implements DataColumnsWithJoins {
3295            /**
3296             * This utility class cannot be instantiated
3297             */
3298            private StructuredName() {}
3299
3300            /** MIME type used when storing this in data table. */
3301            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
3302
3303            /**
3304             * The name that should be used to display the contact.
3305             * <i>Unstructured component of the name should be consistent with
3306             * its structured representation.</i>
3307             * <p>
3308             * Type: TEXT
3309             */
3310            public static final String DISPLAY_NAME = DATA1;
3311
3312            /**
3313             * The given name for the contact.
3314             * <P>Type: TEXT</P>
3315             */
3316            public static final String GIVEN_NAME = DATA2;
3317
3318            /**
3319             * The family name for the contact.
3320             * <P>Type: TEXT</P>
3321             */
3322            public static final String FAMILY_NAME = DATA3;
3323
3324            /**
3325             * The contact's honorific prefix, e.g. "Sir"
3326             * <P>Type: TEXT</P>
3327             */
3328            public static final String PREFIX = DATA4;
3329
3330            /**
3331             * The contact's middle name
3332             * <P>Type: TEXT</P>
3333             */
3334            public static final String MIDDLE_NAME = DATA5;
3335
3336            /**
3337             * The contact's honorific suffix, e.g. "Jr"
3338             */
3339            public static final String SUFFIX = DATA6;
3340
3341            /**
3342             * The phonetic version of the given name for the contact.
3343             * <P>Type: TEXT</P>
3344             */
3345            public static final String PHONETIC_GIVEN_NAME = DATA7;
3346
3347            /**
3348             * The phonetic version of the additional name for the contact.
3349             * <P>Type: TEXT</P>
3350             */
3351            public static final String PHONETIC_MIDDLE_NAME = DATA8;
3352
3353            /**
3354             * The phonetic version of the family name for the contact.
3355             * <P>Type: TEXT</P>
3356             */
3357            public static final String PHONETIC_FAMILY_NAME = DATA9;
3358
3359            /**
3360             * The style used for combining given/middle/family name into a full name.
3361             * See {@link ContactsContract.FullNameStyle}.
3362             *
3363             * @hide
3364             */
3365            public static final String FULL_NAME_STYLE = DATA10;
3366
3367            /**
3368             * The alphabet used for capturing the phonetic name.
3369             * See ContactsContract.PhoneticNameStyle.
3370             * @hide
3371             */
3372            public static final String PHONETIC_NAME_STYLE = DATA11;
3373        }
3374
3375        /**
3376         * <p>A data kind representing the contact's nickname. For example, for
3377         * Bob Parr ("Mr. Incredible"):
3378         * <pre>
3379         * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
3380         * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
3381         *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
3382         *          .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
3383         *          .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
3384         *          .build());
3385         *
3386         * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
3387         *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
3388         *          .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
3389         *          .withValue(Nickname.NAME, "Mr. Incredible")
3390         *          .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
3391         *          .withValue(Nickname.LABEL, "Superhero")
3392         *          .build());
3393         *
3394         * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
3395         * </pre>
3396         * </p>
3397         * <p>
3398         * You can use all columns defined for {@link ContactsContract.Data} as well as the
3399         * following aliases.
3400         * </p>
3401         *
3402         * <h2>Column aliases</h2>
3403         * <table class="jd-sumtable">
3404         * <tr>
3405         * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
3406         * </tr>
3407         * <tr>
3408         * <td>String</td>
3409         * <td>{@link #NAME}</td>
3410         * <td>{@link #DATA1}</td>
3411         * <td></td>
3412         * </tr>
3413         * <tr>
3414         * <td>int</td>
3415         * <td>{@link #TYPE}</td>
3416         * <td>{@link #DATA2}</td>
3417         * <td>
3418         * Allowed values are:
3419         * <p>
3420         * <ul>
3421         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
3422         * <li>{@link #TYPE_DEFAULT}</li>
3423         * <li>{@link #TYPE_OTHER_NAME}</li>
3424         * <li>{@link #TYPE_MAINDEN_NAME}</li>
3425         * <li>{@link #TYPE_SHORT_NAME}</li>
3426         * <li>{@link #TYPE_INITIALS}</li>
3427         * </ul>
3428         * </p>
3429         * </td>
3430         * </tr>
3431         * <tr>
3432         * <td>String</td>
3433         * <td>{@link #LABEL}</td>
3434         * <td>{@link #DATA3}</td>
3435         * <td></td>
3436         * </tr>
3437         * </table>
3438         */
3439        public static final class Nickname implements DataColumnsWithJoins, CommonColumns {
3440            /**
3441             * This utility class cannot be instantiated
3442             */
3443            private Nickname() {}
3444
3445            /** MIME type used when storing this in data table. */
3446            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
3447
3448            public static final int TYPE_DEFAULT = 1;
3449            public static final int TYPE_OTHER_NAME = 2;
3450            public static final int TYPE_MAINDEN_NAME = 3;
3451            public static final int TYPE_SHORT_NAME = 4;
3452            public static final int TYPE_INITIALS = 5;
3453
3454            /**
3455             * The name itself
3456             */
3457            public static final String NAME = DATA;
3458        }
3459
3460        /**
3461         * <p>
3462         * A data kind representing a telephone number.
3463         * </p>
3464         * <p>
3465         * You can use all columns defined for {@link ContactsContract.Data} as
3466         * well as the following aliases.
3467         * </p>
3468         * <h2>Column aliases</h2>
3469         * <table class="jd-sumtable">
3470         * <tr>
3471         * <th>Type</th>
3472         * <th>Alias</th><th colspan='2'>Data column</th>
3473         * </tr>
3474         * <tr>
3475         * <td>String</td>
3476         * <td>{@link #NUMBER}</td>
3477         * <td>{@link #DATA1}</td>
3478         * <td></td>
3479         * </tr>
3480         * <tr>
3481         * <td>int</td>
3482         * <td>{@link #TYPE}</td>
3483         * <td>{@link #DATA2}</td>
3484         * <td>Allowed values are:
3485         * <p>
3486         * <ul>
3487         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
3488         * <li>{@link #TYPE_HOME}</li>
3489         * <li>{@link #TYPE_MOBILE}</li>
3490         * <li>{@link #TYPE_WORK}</li>
3491         * <li>{@link #TYPE_FAX_WORK}</li>
3492         * <li>{@link #TYPE_FAX_HOME}</li>
3493         * <li>{@link #TYPE_PAGER}</li>
3494         * <li>{@link #TYPE_OTHER}</li>
3495         * <li>{@link #TYPE_CALLBACK}</li>
3496         * <li>{@link #TYPE_CAR}</li>
3497         * <li>{@link #TYPE_COMPANY_MAIN}</li>
3498         * <li>{@link #TYPE_ISDN}</li>
3499         * <li>{@link #TYPE_MAIN}</li>
3500         * <li>{@link #TYPE_OTHER_FAX}</li>
3501         * <li>{@link #TYPE_RADIO}</li>
3502         * <li>{@link #TYPE_TELEX}</li>
3503         * <li>{@link #TYPE_TTY_TDD}</li>
3504         * <li>{@link #TYPE_WORK_MOBILE}</li>
3505         * <li>{@link #TYPE_WORK_PAGER}</li>
3506         * <li>{@link #TYPE_ASSISTANT}</li>
3507         * <li>{@link #TYPE_MMS}</li>
3508         * </ul>
3509         * </p>
3510         * </td>
3511         * </tr>
3512         * <tr>
3513         * <td>String</td>
3514         * <td>{@link #LABEL}</td>
3515         * <td>{@link #DATA3}</td>
3516         * <td></td>
3517         * </tr>
3518         * </table>
3519         */
3520        public static final class Phone implements DataColumnsWithJoins, CommonColumns {
3521            /**
3522             * This utility class cannot be instantiated
3523             */
3524            private Phone() {}
3525
3526            /** MIME type used when storing this in data table. */
3527            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
3528
3529            /**
3530             * The MIME type of {@link #CONTENT_URI} providing a directory of
3531             * phones.
3532             */
3533            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
3534
3535            /**
3536             * The content:// style URI for all data records of the
3537             * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
3538             * associated raw contact and aggregate contact data.
3539             */
3540            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
3541                    "phones");
3542
3543            /**
3544             * The content:// style URL for phone lookup using a filter. The filter returns
3545             * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
3546             * to display names as well as phone numbers. The filter argument should be passed
3547             * as an additional path segment after this URI.
3548             */
3549            public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
3550                    "filter");
3551
3552            public static final int TYPE_HOME = 1;
3553            public static final int TYPE_MOBILE = 2;
3554            public static final int TYPE_WORK = 3;
3555            public static final int TYPE_FAX_WORK = 4;
3556            public static final int TYPE_FAX_HOME = 5;
3557            public static final int TYPE_PAGER = 6;
3558            public static final int TYPE_OTHER = 7;
3559            public static final int TYPE_CALLBACK = 8;
3560            public static final int TYPE_CAR = 9;
3561            public static final int TYPE_COMPANY_MAIN = 10;
3562            public static final int TYPE_ISDN = 11;
3563            public static final int TYPE_MAIN = 12;
3564            public static final int TYPE_OTHER_FAX = 13;
3565            public static final int TYPE_RADIO = 14;
3566            public static final int TYPE_TELEX = 15;
3567            public static final int TYPE_TTY_TDD = 16;
3568            public static final int TYPE_WORK_MOBILE = 17;
3569            public static final int TYPE_WORK_PAGER = 18;
3570            public static final int TYPE_ASSISTANT = 19;
3571            public static final int TYPE_MMS = 20;
3572
3573            /**
3574             * The phone number as the user entered it.
3575             * <P>Type: TEXT</P>
3576             */
3577            public static final String NUMBER = DATA;
3578
3579            /**
3580             * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
3581             * @hide
3582             */
3583            @Deprecated
3584            public static final CharSequence getDisplayLabel(Context context, int type,
3585                    CharSequence label, CharSequence[] labelArray) {
3586                return getTypeLabel(context.getResources(), type, label);
3587            }
3588
3589            /**
3590             * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
3591             * @hide
3592             */
3593            @Deprecated
3594            public static final CharSequence getDisplayLabel(Context context, int type,
3595                    CharSequence label) {
3596                return getTypeLabel(context.getResources(), type, label);
3597            }
3598
3599            /**
3600             * Return the string resource that best describes the given
3601             * {@link #TYPE}. Will always return a valid resource.
3602             */
3603            public static final int getTypeLabelResource(int type) {
3604                switch (type) {
3605                    case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
3606                    case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
3607                    case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
3608                    case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
3609                    case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
3610                    case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
3611                    case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
3612                    case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
3613                    case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
3614                    case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
3615                    case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
3616                    case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
3617                    case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
3618                    case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
3619                    case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
3620                    case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
3621                    case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
3622                    case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
3623                    case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
3624                    case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
3625                    default: return com.android.internal.R.string.phoneTypeCustom;
3626                }
3627            }
3628
3629            /**
3630             * Return a {@link CharSequence} that best describes the given type,
3631             * possibly substituting the given {@link #LABEL} value
3632             * for {@link #TYPE_CUSTOM}.
3633             */
3634            public static final CharSequence getTypeLabel(Resources res, int type,
3635                    CharSequence label) {
3636                if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
3637                    return label;
3638                } else {
3639                    final int labelRes = getTypeLabelResource(type);
3640                    return res.getText(labelRes);
3641                }
3642            }
3643        }
3644
3645        /**
3646         * <p>
3647         * A data kind representing an email address.
3648         * </p>
3649         * <p>
3650         * You can use all columns defined for {@link ContactsContract.Data} as
3651         * well as the following aliases.
3652         * </p>
3653         * <h2>Column aliases</h2>
3654         * <table class="jd-sumtable">
3655         * <tr>
3656         * <th>Type</th>
3657         * <th>Alias</th><th colspan='2'>Data column</th>
3658         * </tr>
3659         * <tr>
3660         * <td>String</td>
3661         * <td>{@link #DATA}</td>
3662         * <td>{@link #DATA1}</td>
3663         * <td>Email address itself.</td>
3664         * </tr>
3665         * <tr>
3666         * <td>int</td>
3667         * <td>{@link #TYPE}</td>
3668         * <td>{@link #DATA2}</td>
3669         * <td>Allowed values are:
3670         * <p>
3671         * <ul>
3672         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
3673         * <li>{@link #TYPE_HOME}</li>
3674         * <li>{@link #TYPE_WORK}</li>
3675         * <li>{@link #TYPE_OTHER}</li>
3676         * <li>{@link #TYPE_MOBILE}</li>
3677         * </ul>
3678         * </p>
3679         * </td>
3680         * </tr>
3681         * <tr>
3682         * <td>String</td>
3683         * <td>{@link #LABEL}</td>
3684         * <td>{@link #DATA3}</td>
3685         * <td></td>
3686         * </tr>
3687         * </table>
3688         */
3689        public static final class Email implements DataColumnsWithJoins, CommonColumns {
3690            /**
3691             * This utility class cannot be instantiated
3692             */
3693            private Email() {}
3694
3695            /** MIME type used when storing this in data table. */
3696            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
3697
3698            /**
3699             * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
3700             */
3701            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
3702
3703            /**
3704             * The content:// style URI for all data records of the
3705             * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
3706             * associated raw contact and aggregate contact data.
3707             */
3708            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
3709                    "emails");
3710
3711            /**
3712             * <p>
3713             * The content:// style URL for looking up data rows by email address. The
3714             * lookup argument, an email address, should be passed as an additional path segment
3715             * after this URI.
3716             * </p>
3717             * <p>Example:
3718             * <pre>
3719             * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
3720             * Cursor c = getContentResolver().query(uri,
3721             *          new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
3722             *          null, null, null);
3723             * </pre>
3724             * </p>
3725             */
3726            public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
3727                    "lookup");
3728
3729            /**
3730             * <p>
3731             * The content:// style URL for email lookup using a filter. The filter returns
3732             * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
3733             * to display names as well as email addresses. The filter argument should be passed
3734             * as an additional path segment after this URI.
3735             * </p>
3736             * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)"
3737             * as well as "Bob Parr (incredible@android.com)".
3738             * <pre>
3739             * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
3740             * Cursor c = getContentResolver().query(uri,
3741             *          new String[]{Email.DISPLAY_NAME, Email.DATA},
3742             *          null, null, null);
3743             * </pre>
3744             * </p>
3745             */
3746            public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
3747                    "filter");
3748
3749            /**
3750             * The email address.
3751             * <P>Type: TEXT</P>
3752             * @hide TODO: Unhide in a separate CL
3753             */
3754            public static final String ADDRESS = DATA1;
3755
3756            public static final int TYPE_HOME = 1;
3757            public static final int TYPE_WORK = 2;
3758            public static final int TYPE_OTHER = 3;
3759            public static final int TYPE_MOBILE = 4;
3760
3761            /**
3762             * The display name for the email address
3763             * <P>Type: TEXT</P>
3764             */
3765            public static final String DISPLAY_NAME = DATA4;
3766
3767            /**
3768             * Return the string resource that best describes the given
3769             * {@link #TYPE}. Will always return a valid resource.
3770             */
3771            public static final int getTypeLabelResource(int type) {
3772                switch (type) {
3773                    case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
3774                    case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
3775                    case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
3776                    case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
3777                    default: return com.android.internal.R.string.emailTypeCustom;
3778                }
3779            }
3780
3781            /**
3782             * Return a {@link CharSequence} that best describes the given type,
3783             * possibly substituting the given {@link #LABEL} value
3784             * for {@link #TYPE_CUSTOM}.
3785             */
3786            public static final CharSequence getTypeLabel(Resources res, int type,
3787                    CharSequence label) {
3788                if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
3789                    return label;
3790                } else {
3791                    final int labelRes = getTypeLabelResource(type);
3792                    return res.getText(labelRes);
3793                }
3794            }
3795        }
3796
3797        /**
3798         * <p>
3799         * A data kind representing a postal addresses.
3800         * </p>
3801         * <p>
3802         * You can use all columns defined for {@link ContactsContract.Data} as
3803         * well as the following aliases.
3804         * </p>
3805         * <h2>Column aliases</h2>
3806         * <table class="jd-sumtable">
3807         * <tr>
3808         * <th>Type</th>
3809         * <th>Alias</th><th colspan='2'>Data column</th>
3810         * </tr>
3811         * <tr>
3812         * <td>String</td>
3813         * <td>{@link #FORMATTED_ADDRESS}</td>
3814         * <td>{@link #DATA1}</td>
3815         * <td></td>
3816         * </tr>
3817         * <tr>
3818         * <td>int</td>
3819         * <td>{@link #TYPE}</td>
3820         * <td>{@link #DATA2}</td>
3821         * <td>Allowed values are:
3822         * <p>
3823         * <ul>
3824         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
3825         * <li>{@link #TYPE_HOME}</li>
3826         * <li>{@link #TYPE_WORK}</li>
3827         * <li>{@link #TYPE_OTHER}</li>
3828         * </ul>
3829         * </p>
3830         * </td>
3831         * </tr>
3832         * <tr>
3833         * <td>String</td>
3834         * <td>{@link #LABEL}</td>
3835         * <td>{@link #DATA3}</td>
3836         * <td></td>
3837         * </tr>
3838         * <tr>
3839         * <td>String</td>
3840         * <td>{@link #STREET}</td>
3841         * <td>{@link #DATA4}</td>
3842         * <td></td>
3843         * </tr>
3844         * <tr>
3845         * <td>String</td>
3846         * <td>{@link #POBOX}</td>
3847         * <td>{@link #DATA5}</td>
3848         * <td>Post Office Box number</td>
3849         * </tr>
3850         * <tr>
3851         * <td>String</td>
3852         * <td>{@link #NEIGHBORHOOD}</td>
3853         * <td>{@link #DATA6}</td>
3854         * <td></td>
3855         * </tr>
3856         * <tr>
3857         * <td>String</td>
3858         * <td>{@link #CITY}</td>
3859         * <td>{@link #DATA7}</td>
3860         * <td></td>
3861         * </tr>
3862         * <tr>
3863         * <td>String</td>
3864         * <td>{@link #REGION}</td>
3865         * <td>{@link #DATA8}</td>
3866         * <td></td>
3867         * </tr>
3868         * <tr>
3869         * <td>String</td>
3870         * <td>{@link #POSTCODE}</td>
3871         * <td>{@link #DATA9}</td>
3872         * <td></td>
3873         * </tr>
3874         * <tr>
3875         * <td>String</td>
3876         * <td>{@link #COUNTRY}</td>
3877         * <td>{@link #DATA10}</td>
3878         * <td></td>
3879         * </tr>
3880         * </table>
3881         */
3882        public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns {
3883            /**
3884             * This utility class cannot be instantiated
3885             */
3886            private StructuredPostal() {
3887            }
3888
3889            /** MIME type used when storing this in data table. */
3890            public static final String CONTENT_ITEM_TYPE =
3891                    "vnd.android.cursor.item/postal-address_v2";
3892
3893            /**
3894             * The MIME type of {@link #CONTENT_URI} providing a directory of
3895             * postal addresses.
3896             */
3897            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
3898
3899            /**
3900             * The content:// style URI for all data records of the
3901             * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
3902             */
3903            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
3904                    "postals");
3905
3906            public static final int TYPE_HOME = 1;
3907            public static final int TYPE_WORK = 2;
3908            public static final int TYPE_OTHER = 3;
3909
3910            /**
3911             * The full, unstructured postal address. <i>This field must be
3912             * consistent with any structured data.</i>
3913             * <p>
3914             * Type: TEXT
3915             */
3916            public static final String FORMATTED_ADDRESS = DATA;
3917
3918            /**
3919             * Can be street, avenue, road, etc. This element also includes the
3920             * house number and room/apartment/flat/floor number.
3921             * <p>
3922             * Type: TEXT
3923             */
3924            public static final String STREET = DATA4;
3925
3926            /**
3927             * Covers actual P.O. boxes, drawers, locked bags, etc. This is
3928             * usually but not always mutually exclusive with street.
3929             * <p>
3930             * Type: TEXT
3931             */
3932            public static final String POBOX = DATA5;
3933
3934            /**
3935             * This is used to disambiguate a street address when a city
3936             * contains more than one street with the same name, or to specify a
3937             * small place whose mail is routed through a larger postal town. In
3938             * China it could be a county or a minor city.
3939             * <p>
3940             * Type: TEXT
3941             */
3942            public static final String NEIGHBORHOOD = DATA6;
3943
3944            /**
3945             * Can be city, village, town, borough, etc. This is the postal town
3946             * and not necessarily the place of residence or place of business.
3947             * <p>
3948             * Type: TEXT
3949             */
3950            public static final String CITY = DATA7;
3951
3952            /**
3953             * A state, province, county (in Ireland), Land (in Germany),
3954             * departement (in France), etc.
3955             * <p>
3956             * Type: TEXT
3957             */
3958            public static final String REGION = DATA8;
3959
3960            /**
3961             * Postal code. Usually country-wide, but sometimes specific to the
3962             * city (e.g. "2" in "Dublin 2, Ireland" addresses).
3963             * <p>
3964             * Type: TEXT
3965             */
3966            public static final String POSTCODE = DATA9;
3967
3968            /**
3969             * The name or code of the country.
3970             * <p>
3971             * Type: TEXT
3972             */
3973            public static final String COUNTRY = DATA10;
3974
3975            /**
3976             * Return the string resource that best describes the given
3977             * {@link #TYPE}. Will always return a valid resource.
3978             */
3979            public static final int getTypeLabelResource(int type) {
3980                switch (type) {
3981                    case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
3982                    case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
3983                    case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
3984                    default: return com.android.internal.R.string.postalTypeCustom;
3985                }
3986            }
3987
3988            /**
3989             * Return a {@link CharSequence} that best describes the given type,
3990             * possibly substituting the given {@link #LABEL} value
3991             * for {@link #TYPE_CUSTOM}.
3992             */
3993            public static final CharSequence getTypeLabel(Resources res, int type,
3994                    CharSequence label) {
3995                if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
3996                    return label;
3997                } else {
3998                    final int labelRes = getTypeLabelResource(type);
3999                    return res.getText(labelRes);
4000                }
4001            }
4002        }
4003
4004        /**
4005         * <p>
4006         * A data kind representing an IM address
4007         * </p>
4008         * <p>
4009         * You can use all columns defined for {@link ContactsContract.Data} as
4010         * well as the following aliases.
4011         * </p>
4012         * <h2>Column aliases</h2>
4013         * <table class="jd-sumtable">
4014         * <tr>
4015         * <th>Type</th>
4016         * <th>Alias</th><th colspan='2'>Data column</th>
4017         * </tr>
4018         * <tr>
4019         * <td>String</td>
4020         * <td>{@link #DATA}</td>
4021         * <td>{@link #DATA1}</td>
4022         * <td></td>
4023         * </tr>
4024         * <tr>
4025         * <td>int</td>
4026         * <td>{@link #TYPE}</td>
4027         * <td>{@link #DATA2}</td>
4028         * <td>Allowed values are:
4029         * <p>
4030         * <ul>
4031         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4032         * <li>{@link #TYPE_HOME}</li>
4033         * <li>{@link #TYPE_WORK}</li>
4034         * <li>{@link #TYPE_OTHER}</li>
4035         * </ul>
4036         * </p>
4037         * </td>
4038         * </tr>
4039         * <tr>
4040         * <td>String</td>
4041         * <td>{@link #LABEL}</td>
4042         * <td>{@link #DATA3}</td>
4043         * <td></td>
4044         * </tr>
4045         * <tr>
4046         * <td>String</td>
4047         * <td>{@link #PROTOCOL}</td>
4048         * <td>{@link #DATA5}</td>
4049         * <td>
4050         * <p>
4051         * Allowed values:
4052         * <ul>
4053         * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
4054         * as {@link #CUSTOM_PROTOCOL}.</li>
4055         * <li>{@link #PROTOCOL_AIM}</li>
4056         * <li>{@link #PROTOCOL_MSN}</li>
4057         * <li>{@link #PROTOCOL_YAHOO}</li>
4058         * <li>{@link #PROTOCOL_SKYPE}</li>
4059         * <li>{@link #PROTOCOL_QQ}</li>
4060         * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
4061         * <li>{@link #PROTOCOL_ICQ}</li>
4062         * <li>{@link #PROTOCOL_JABBER}</li>
4063         * <li>{@link #PROTOCOL_NETMEETING}</li>
4064         * </ul>
4065         * </p>
4066         * </td>
4067         * </tr>
4068         * <tr>
4069         * <td>String</td>
4070         * <td>{@link #CUSTOM_PROTOCOL}</td>
4071         * <td>{@link #DATA6}</td>
4072         * <td></td>
4073         * </tr>
4074         * </table>
4075         */
4076        public static final class Im implements DataColumnsWithJoins, CommonColumns {
4077            /**
4078             * This utility class cannot be instantiated
4079             */
4080            private Im() {}
4081
4082            /** MIME type used when storing this in data table. */
4083            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
4084
4085            public static final int TYPE_HOME = 1;
4086            public static final int TYPE_WORK = 2;
4087            public static final int TYPE_OTHER = 3;
4088
4089            /**
4090             * This column should be populated with one of the defined
4091             * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
4092             * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
4093             * should contain the name of the custom protocol.
4094             */
4095            public static final String PROTOCOL = DATA5;
4096
4097            public static final String CUSTOM_PROTOCOL = DATA6;
4098
4099            /*
4100             * The predefined IM protocol types.
4101             */
4102            public static final int PROTOCOL_CUSTOM = -1;
4103            public static final int PROTOCOL_AIM = 0;
4104            public static final int PROTOCOL_MSN = 1;
4105            public static final int PROTOCOL_YAHOO = 2;
4106            public static final int PROTOCOL_SKYPE = 3;
4107            public static final int PROTOCOL_QQ = 4;
4108            public static final int PROTOCOL_GOOGLE_TALK = 5;
4109            public static final int PROTOCOL_ICQ = 6;
4110            public static final int PROTOCOL_JABBER = 7;
4111            public static final int PROTOCOL_NETMEETING = 8;
4112
4113            /**
4114             * Return the string resource that best describes the given
4115             * {@link #TYPE}. Will always return a valid resource.
4116             */
4117            public static final int getTypeLabelResource(int type) {
4118                switch (type) {
4119                    case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
4120                    case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
4121                    case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
4122                    default: return com.android.internal.R.string.imTypeCustom;
4123                }
4124            }
4125
4126            /**
4127             * Return a {@link CharSequence} that best describes the given type,
4128             * possibly substituting the given {@link #LABEL} value
4129             * for {@link #TYPE_CUSTOM}.
4130             */
4131            public static final CharSequence getTypeLabel(Resources res, int type,
4132                    CharSequence label) {
4133                if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
4134                    return label;
4135                } else {
4136                    final int labelRes = getTypeLabelResource(type);
4137                    return res.getText(labelRes);
4138                }
4139            }
4140
4141            /**
4142             * Return the string resource that best describes the given
4143             * {@link #PROTOCOL}. Will always return a valid resource.
4144             */
4145            public static final int getProtocolLabelResource(int type) {
4146                switch (type) {
4147                    case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
4148                    case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
4149                    case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
4150                    case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
4151                    case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
4152                    case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
4153                    case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
4154                    case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
4155                    case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
4156                    default: return com.android.internal.R.string.imProtocolCustom;
4157                }
4158            }
4159
4160            /**
4161             * Return a {@link CharSequence} that best describes the given
4162             * protocol, possibly substituting the given
4163             * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
4164             */
4165            public static final CharSequence getProtocolLabel(Resources res, int type,
4166                    CharSequence label) {
4167                if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
4168                    return label;
4169                } else {
4170                    final int labelRes = getProtocolLabelResource(type);
4171                    return res.getText(labelRes);
4172                }
4173            }
4174        }
4175
4176        /**
4177         * <p>
4178         * A data kind representing an organization.
4179         * </p>
4180         * <p>
4181         * You can use all columns defined for {@link ContactsContract.Data} as
4182         * well as the following aliases.
4183         * </p>
4184         * <h2>Column aliases</h2>
4185         * <table class="jd-sumtable">
4186         * <tr>
4187         * <th>Type</th>
4188         * <th>Alias</th><th colspan='2'>Data column</th>
4189         * </tr>
4190         * <tr>
4191         * <td>String</td>
4192         * <td>{@link #COMPANY}</td>
4193         * <td>{@link #DATA1}</td>
4194         * <td></td>
4195         * </tr>
4196         * <tr>
4197         * <td>int</td>
4198         * <td>{@link #TYPE}</td>
4199         * <td>{@link #DATA2}</td>
4200         * <td>Allowed values are:
4201         * <p>
4202         * <ul>
4203         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4204         * <li>{@link #TYPE_WORK}</li>
4205         * <li>{@link #TYPE_OTHER}</li>
4206         * </ul>
4207         * </p>
4208         * </td>
4209         * </tr>
4210         * <tr>
4211         * <td>String</td>
4212         * <td>{@link #LABEL}</td>
4213         * <td>{@link #DATA3}</td>
4214         * <td></td>
4215         * </tr>
4216         * <tr>
4217         * <td>String</td>
4218         * <td>{@link #TITLE}</td>
4219         * <td>{@link #DATA4}</td>
4220         * <td></td>
4221         * </tr>
4222         * <tr>
4223         * <td>String</td>
4224         * <td>{@link #DEPARTMENT}</td>
4225         * <td>{@link #DATA5}</td>
4226         * <td></td>
4227         * </tr>
4228         * <tr>
4229         * <td>String</td>
4230         * <td>{@link #JOB_DESCRIPTION}</td>
4231         * <td>{@link #DATA6}</td>
4232         * <td></td>
4233         * </tr>
4234         * <tr>
4235         * <td>String</td>
4236         * <td>{@link #SYMBOL}</td>
4237         * <td>{@link #DATA7}</td>
4238         * <td></td>
4239         * </tr>
4240         * <tr>
4241         * <td>String</td>
4242         * <td>{@link #PHONETIC_NAME}</td>
4243         * <td>{@link #DATA8}</td>
4244         * <td></td>
4245         * </tr>
4246         * <tr>
4247         * <td>String</td>
4248         * <td>{@link #OFFICE_LOCATION}</td>
4249         * <td>{@link #DATA9}</td>
4250         * <td></td>
4251         * </tr>
4252         * <tr>
4253         * <td>String</td>
4254         * <td>PHONETIC_NAME_STYLE</td>
4255         * <td>{@link #DATA10}</td>
4256         * <td></td>
4257         * </tr>
4258         * </table>
4259         */
4260        public static final class Organization implements DataColumnsWithJoins, CommonColumns {
4261            /**
4262             * This utility class cannot be instantiated
4263             */
4264            private Organization() {}
4265
4266            /** MIME type used when storing this in data table. */
4267            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
4268
4269            public static final int TYPE_WORK = 1;
4270            public static final int TYPE_OTHER = 2;
4271
4272            /**
4273             * The company as the user entered it.
4274             * <P>Type: TEXT</P>
4275             */
4276            public static final String COMPANY = DATA;
4277
4278            /**
4279             * The position title at this company as the user entered it.
4280             * <P>Type: TEXT</P>
4281             */
4282            public static final String TITLE = DATA4;
4283
4284            /**
4285             * The department at this company as the user entered it.
4286             * <P>Type: TEXT</P>
4287             */
4288            public static final String DEPARTMENT = DATA5;
4289
4290            /**
4291             * The job description at this company as the user entered it.
4292             * <P>Type: TEXT</P>
4293             */
4294            public static final String JOB_DESCRIPTION = DATA6;
4295
4296            /**
4297             * The symbol of this company as the user entered it.
4298             * <P>Type: TEXT</P>
4299             */
4300            public static final String SYMBOL = DATA7;
4301
4302            /**
4303             * The phonetic name of this company as the user entered it.
4304             * <P>Type: TEXT</P>
4305             */
4306            public static final String PHONETIC_NAME = DATA8;
4307
4308            /**
4309             * The office location of this organization.
4310             * <P>Type: TEXT</P>
4311             */
4312            public static final String OFFICE_LOCATION = DATA9;
4313
4314            /**
4315             * The alphabet used for capturing the phonetic name.
4316             * See {@link ContactsContract.PhoneticNameStyle}.
4317             * @hide
4318             */
4319            public static final String PHONETIC_NAME_STYLE = DATA10;
4320
4321            /**
4322             * Return the string resource that best describes the given
4323             * {@link #TYPE}. Will always return a valid resource.
4324             */
4325            public static final int getTypeLabelResource(int type) {
4326                switch (type) {
4327                    case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
4328                    case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
4329                    default: return com.android.internal.R.string.orgTypeCustom;
4330                }
4331            }
4332
4333            /**
4334             * Return a {@link CharSequence} that best describes the given type,
4335             * possibly substituting the given {@link #LABEL} value
4336             * for {@link #TYPE_CUSTOM}.
4337             */
4338            public static final CharSequence getTypeLabel(Resources res, int type,
4339                    CharSequence label) {
4340                if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
4341                    return label;
4342                } else {
4343                    final int labelRes = getTypeLabelResource(type);
4344                    return res.getText(labelRes);
4345                }
4346            }
4347        }
4348
4349        /**
4350         * <p>
4351         * A data kind representing a relation.
4352         * </p>
4353         * <p>
4354         * You can use all columns defined for {@link ContactsContract.Data} as
4355         * well as the following aliases.
4356         * </p>
4357         * <h2>Column aliases</h2>
4358         * <table class="jd-sumtable">
4359         * <tr>
4360         * <th>Type</th>
4361         * <th>Alias</th><th colspan='2'>Data column</th>
4362         * </tr>
4363         * <tr>
4364         * <td>String</td>
4365         * <td>{@link #NAME}</td>
4366         * <td>{@link #DATA1}</td>
4367         * <td></td>
4368         * </tr>
4369         * <tr>
4370         * <td>int</td>
4371         * <td>{@link #TYPE}</td>
4372         * <td>{@link #DATA2}</td>
4373         * <td>Allowed values are:
4374         * <p>
4375         * <ul>
4376         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4377         * <li>{@link #TYPE_ASSISTANT}</li>
4378         * <li>{@link #TYPE_BROTHER}</li>
4379         * <li>{@link #TYPE_CHILD}</li>
4380         * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
4381         * <li>{@link #TYPE_FATHER}</li>
4382         * <li>{@link #TYPE_FRIEND}</li>
4383         * <li>{@link #TYPE_MANAGER}</li>
4384         * <li>{@link #TYPE_MOTHER}</li>
4385         * <li>{@link #TYPE_PARENT}</li>
4386         * <li>{@link #TYPE_PARTNER}</li>
4387         * <li>{@link #TYPE_REFERRED_BY}</li>
4388         * <li>{@link #TYPE_RELATIVE}</li>
4389         * <li>{@link #TYPE_SISTER}</li>
4390         * <li>{@link #TYPE_SPOUSE}</li>
4391         * </ul>
4392         * </p>
4393         * </td>
4394         * </tr>
4395         * <tr>
4396         * <td>String</td>
4397         * <td>{@link #LABEL}</td>
4398         * <td>{@link #DATA3}</td>
4399         * <td></td>
4400         * </tr>
4401         * </table>
4402         */
4403        public static final class Relation implements DataColumnsWithJoins, CommonColumns {
4404            /**
4405             * This utility class cannot be instantiated
4406             */
4407            private Relation() {}
4408
4409            /** MIME type used when storing this in data table. */
4410            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
4411
4412            public static final int TYPE_ASSISTANT = 1;
4413            public static final int TYPE_BROTHER = 2;
4414            public static final int TYPE_CHILD = 3;
4415            public static final int TYPE_DOMESTIC_PARTNER = 4;
4416            public static final int TYPE_FATHER = 5;
4417            public static final int TYPE_FRIEND = 6;
4418            public static final int TYPE_MANAGER = 7;
4419            public static final int TYPE_MOTHER = 8;
4420            public static final int TYPE_PARENT = 9;
4421            public static final int TYPE_PARTNER = 10;
4422            public static final int TYPE_REFERRED_BY = 11;
4423            public static final int TYPE_RELATIVE = 12;
4424            public static final int TYPE_SISTER = 13;
4425            public static final int TYPE_SPOUSE = 14;
4426
4427            /**
4428             * The name of the relative as the user entered it.
4429             * <P>Type: TEXT</P>
4430             */
4431            public static final String NAME = DATA;
4432        }
4433
4434        /**
4435         * <p>
4436         * A data kind representing an event.
4437         * </p>
4438         * <p>
4439         * You can use all columns defined for {@link ContactsContract.Data} as
4440         * well as the following aliases.
4441         * </p>
4442         * <h2>Column aliases</h2>
4443         * <table class="jd-sumtable">
4444         * <tr>
4445         * <th>Type</th>
4446         * <th>Alias</th><th colspan='2'>Data column</th>
4447         * </tr>
4448         * <tr>
4449         * <td>String</td>
4450         * <td>{@link #START_DATE}</td>
4451         * <td>{@link #DATA1}</td>
4452         * <td></td>
4453         * </tr>
4454         * <tr>
4455         * <td>int</td>
4456         * <td>{@link #TYPE}</td>
4457         * <td>{@link #DATA2}</td>
4458         * <td>Allowed values are:
4459         * <p>
4460         * <ul>
4461         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4462         * <li>{@link #TYPE_ANNIVERSARY}</li>
4463         * <li>{@link #TYPE_OTHER}</li>
4464         * <li>{@link #TYPE_BIRTHDAY}</li>
4465         * </ul>
4466         * </p>
4467         * </td>
4468         * </tr>
4469         * <tr>
4470         * <td>String</td>
4471         * <td>{@link #LABEL}</td>
4472         * <td>{@link #DATA3}</td>
4473         * <td></td>
4474         * </tr>
4475         * </table>
4476         */
4477        public static final class Event implements DataColumnsWithJoins, CommonColumns {
4478            /**
4479             * This utility class cannot be instantiated
4480             */
4481            private Event() {}
4482
4483            /** MIME type used when storing this in data table. */
4484            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
4485
4486            public static final int TYPE_ANNIVERSARY = 1;
4487            public static final int TYPE_OTHER = 2;
4488            public static final int TYPE_BIRTHDAY = 3;
4489
4490            /**
4491             * The event start date as the user entered it.
4492             * <P>Type: TEXT</P>
4493             */
4494            public static final String START_DATE = DATA;
4495
4496            /**
4497             * Return the string resource that best describes the given
4498             * {@link #TYPE}. Will always return a valid resource.
4499             */
4500            public static int getTypeResource(Integer type) {
4501                if (type == null) {
4502                    return com.android.internal.R.string.eventTypeOther;
4503                }
4504                switch (type) {
4505                    case TYPE_ANNIVERSARY:
4506                        return com.android.internal.R.string.eventTypeAnniversary;
4507                    case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
4508                    case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
4509                    default: return com.android.internal.R.string.eventTypeOther;
4510                }
4511            }
4512        }
4513
4514        /**
4515         * <p>
4516         * A data kind representing an photo for the contact.
4517         * </p>
4518         * <p>
4519         * Some sync adapters will choose to download photos in a separate
4520         * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
4521         * through {@link ContactsContract.Data#SYNC4} to store temporary
4522         * data, e.g. the image URL or ID, state of download, server-side version
4523         * of the image.  It is allowed for the {@link #PHOTO} to be null.
4524         * </p>
4525         * <p>
4526         * You can use all columns defined for {@link ContactsContract.Data} as
4527         * well as the following aliases.
4528         * </p>
4529         * <h2>Column aliases</h2>
4530         * <table class="jd-sumtable">
4531         * <tr>
4532         * <th>Type</th>
4533         * <th>Alias</th><th colspan='2'>Data column</th>
4534         * </tr>
4535         * <tr>
4536         * <td>BLOB</td>
4537         * <td>{@link #PHOTO}</td>
4538         * <td>{@link #DATA15}</td>
4539         * <td>By convention, binary data is stored in DATA15.</td>
4540         * </tr>
4541         * </table>
4542         */
4543        public static final class Photo implements DataColumnsWithJoins {
4544            /**
4545             * This utility class cannot be instantiated
4546             */
4547            private Photo() {}
4548
4549            /** MIME type used when storing this in data table. */
4550            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
4551
4552            /**
4553             * Thumbnail photo of the raw contact. This is the raw bytes of an image
4554             * that could be inflated using {@link android.graphics.BitmapFactory}.
4555             * <p>
4556             * Type: BLOB
4557             */
4558            public static final String PHOTO = DATA15;
4559        }
4560
4561        /**
4562         * <p>
4563         * Notes about the contact.
4564         * </p>
4565         * <p>
4566         * You can use all columns defined for {@link ContactsContract.Data} as
4567         * well as the following aliases.
4568         * </p>
4569         * <h2>Column aliases</h2>
4570         * <table class="jd-sumtable">
4571         * <tr>
4572         * <th>Type</th>
4573         * <th>Alias</th><th colspan='2'>Data column</th>
4574         * </tr>
4575         * <tr>
4576         * <td>String</td>
4577         * <td>{@link #NOTE}</td>
4578         * <td>{@link #DATA1}</td>
4579         * <td></td>
4580         * </tr>
4581         * </table>
4582         */
4583        public static final class Note implements DataColumnsWithJoins {
4584            /**
4585             * This utility class cannot be instantiated
4586             */
4587            private Note() {}
4588
4589            /** MIME type used when storing this in data table. */
4590            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
4591
4592            /**
4593             * The note text.
4594             * <P>Type: TEXT</P>
4595             */
4596            public static final String NOTE = DATA1;
4597        }
4598
4599        /**
4600         * <p>
4601         * Group Membership.
4602         * </p>
4603         * <p>
4604         * You can use all columns defined for {@link ContactsContract.Data} as
4605         * well as the following aliases.
4606         * </p>
4607         * <h2>Column aliases</h2>
4608         * <table class="jd-sumtable">
4609         * <tr>
4610         * <th>Type</th>
4611         * <th>Alias</th><th colspan='2'>Data column</th>
4612         * </tr>
4613         * <tr>
4614         * <td>long</td>
4615         * <td>{@link #GROUP_ROW_ID}</td>
4616         * <td>{@link #DATA1}</td>
4617         * <td></td>
4618         * </tr>
4619         * <tr>
4620         * <td>String</td>
4621         * <td>{@link #GROUP_SOURCE_ID}</td>
4622         * <td>none</td>
4623         * <td>
4624         * <p>
4625         * The sourceid of the group that this group membership refers to.
4626         * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
4627         * inserting a row.
4628         * </p>
4629         * <p>
4630         * If this field is specified, the provider will first try to
4631         * look up a group with this {@link Groups Groups.SOURCE_ID}.  If such a group
4632         * is found, it will use the corresponding row id.  If the group is not
4633         * found, it will create one.
4634         * </td>
4635         * </tr>
4636         * </table>
4637         */
4638        public static final class GroupMembership implements DataColumnsWithJoins {
4639            /**
4640             * This utility class cannot be instantiated
4641             */
4642            private GroupMembership() {}
4643
4644            /** MIME type used when storing this in data table. */
4645            public static final String CONTENT_ITEM_TYPE =
4646                    "vnd.android.cursor.item/group_membership";
4647
4648            /**
4649             * The row id of the group that this group membership refers to. Exactly one of
4650             * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
4651             * <P>Type: INTEGER</P>
4652             */
4653            public static final String GROUP_ROW_ID = DATA1;
4654
4655            /**
4656             * The sourceid of the group that this group membership refers to.  Exactly one of
4657             * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
4658             * <P>Type: TEXT</P>
4659             */
4660            public static final String GROUP_SOURCE_ID = "group_sourceid";
4661        }
4662
4663        /**
4664         * <p>
4665         * A data kind representing a website related to the contact.
4666         * </p>
4667         * <p>
4668         * You can use all columns defined for {@link ContactsContract.Data} as
4669         * well as the following aliases.
4670         * </p>
4671         * <h2>Column aliases</h2>
4672         * <table class="jd-sumtable">
4673         * <tr>
4674         * <th>Type</th>
4675         * <th>Alias</th><th colspan='2'>Data column</th>
4676         * </tr>
4677         * <tr>
4678         * <td>String</td>
4679         * <td>{@link #URL}</td>
4680         * <td>{@link #DATA1}</td>
4681         * <td></td>
4682         * </tr>
4683         * <tr>
4684         * <td>int</td>
4685         * <td>{@link #TYPE}</td>
4686         * <td>{@link #DATA2}</td>
4687         * <td>Allowed values are:
4688         * <p>
4689         * <ul>
4690         * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4691         * <li>{@link #TYPE_HOMEPAGE}</li>
4692         * <li>{@link #TYPE_BLOG}</li>
4693         * <li>{@link #TYPE_PROFILE}</li>
4694         * <li>{@link #TYPE_HOME}</li>
4695         * <li>{@link #TYPE_WORK}</li>
4696         * <li>{@link #TYPE_FTP}</li>
4697         * <li>{@link #TYPE_OTHER}</li>
4698         * </ul>
4699         * </p>
4700         * </td>
4701         * </tr>
4702         * <tr>
4703         * <td>String</td>
4704         * <td>{@link #LABEL}</td>
4705         * <td>{@link #DATA3}</td>
4706         * <td></td>
4707         * </tr>
4708         * </table>
4709         */
4710        public static final class Website implements DataColumnsWithJoins, CommonColumns {
4711            /**
4712             * This utility class cannot be instantiated
4713             */
4714            private Website() {}
4715
4716            /** MIME type used when storing this in data table. */
4717            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
4718
4719            public static final int TYPE_HOMEPAGE = 1;
4720            public static final int TYPE_BLOG = 2;
4721            public static final int TYPE_PROFILE = 3;
4722            public static final int TYPE_HOME = 4;
4723            public static final int TYPE_WORK = 5;
4724            public static final int TYPE_FTP = 6;
4725            public static final int TYPE_OTHER = 7;
4726
4727            /**
4728             * The website URL string.
4729             * <P>Type: TEXT</P>
4730             */
4731            public static final String URL = DATA;
4732        }
4733    }
4734
4735    /**
4736     * @see Groups
4737     */
4738    protected interface GroupsColumns {
4739        /**
4740         * The display title of this group.
4741         * <p>
4742         * Type: TEXT
4743         */
4744        public static final String TITLE = "title";
4745
4746        /**
4747         * The package name to use when creating {@link Resources} objects for
4748         * this group. This value is only designed for use when building user
4749         * interfaces, and should not be used to infer the owner.
4750         *
4751         * @hide
4752         */
4753        public static final String RES_PACKAGE = "res_package";
4754
4755        /**
4756         * The display title of this group to load as a resource from
4757         * {@link #RES_PACKAGE}, which may be localized.
4758         * <P>Type: TEXT</P>
4759         *
4760         * @hide
4761         */
4762        public static final String TITLE_RES = "title_res";
4763
4764        /**
4765         * Notes about the group.
4766         * <p>
4767         * Type: TEXT
4768         */
4769        public static final String NOTES = "notes";
4770
4771        /**
4772         * The ID of this group if it is a System Group, i.e. a group that has a special meaning
4773         * to the sync adapter, null otherwise.
4774         * <P>Type: TEXT</P>
4775         */
4776        public static final String SYSTEM_ID = "system_id";
4777
4778        /**
4779         * The total number of {@link Contacts} that have
4780         * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
4781         * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
4782         * <p>
4783         * Type: INTEGER
4784         */
4785        public static final String SUMMARY_COUNT = "summ_count";
4786
4787        /**
4788         * The total number of {@link Contacts} that have both
4789         * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
4790         * Read-only value that is only present when querying
4791         * {@link Groups#CONTENT_SUMMARY_URI}.
4792         * <p>
4793         * Type: INTEGER
4794         */
4795        public static final String SUMMARY_WITH_PHONES = "summ_phones";
4796
4797        /**
4798         * Flag indicating if the contacts belonging to this group should be
4799         * visible in any user interface.
4800         * <p>
4801         * Type: INTEGER (boolean)
4802         */
4803        public static final String GROUP_VISIBLE = "group_visible";
4804
4805        /**
4806         * The "deleted" flag: "0" by default, "1" if the row has been marked
4807         * for deletion. When {@link android.content.ContentResolver#delete} is
4808         * called on a group, it is marked for deletion. The sync adaptor
4809         * deletes the group on the server and then calls ContactResolver.delete
4810         * once more, this time setting the the
4811         * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
4812         * finalize the data removal.
4813         * <P>Type: INTEGER</P>
4814         */
4815        public static final String DELETED = "deleted";
4816
4817        /**
4818         * Whether this group should be synced if the SYNC_EVERYTHING settings
4819         * is false for this group's account.
4820         * <p>
4821         * Type: INTEGER (boolean)
4822         */
4823        public static final String SHOULD_SYNC = "should_sync";
4824    }
4825
4826    /**
4827     * Constants for the groups table. Only per-account groups are supported.
4828     * <h2>Columns</h2>
4829     * <table class="jd-sumtable">
4830     * <tr>
4831     * <th colspan='4'>Groups</th>
4832     * </tr>
4833     * <tr>
4834     * <td>long</td>
4835     * <td>{@link #_ID}</td>
4836     * <td>read-only</td>
4837     * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
4838     * In other words, it would be a really bad idea to delete and reinsert a
4839     * group. A sync adapter should always do an update instead.</td>
4840     * </tr>
4841     * <tr>
4842     * <td>String</td>
4843     * <td>{@link #TITLE}</td>
4844     * <td>read/write</td>
4845     * <td>The display title of this group.</td>
4846     * </tr>
4847     * <tr>
4848     * <td>String</td>
4849     * <td>{@link #NOTES}</td>
4850     * <td>read/write</td>
4851     * <td>Notes about the group.</td>
4852     * </tr>
4853     * <tr>
4854     * <td>String</td>
4855     * <td>{@link #SYSTEM_ID}</td>
4856     * <td>read/write</td>
4857     * <td>The ID of this group if it is a System Group, i.e. a group that has a
4858     * special meaning to the sync adapter, null otherwise.</td>
4859     * </tr>
4860     * <tr>
4861     * <td>int</td>
4862     * <td>{@link #SUMMARY_COUNT}</td>
4863     * <td>read-only</td>
4864     * <td>The total number of {@link Contacts} that have
4865     * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
4866     * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
4867     * </tr>
4868     * <tr>
4869     * <td>int</td>
4870     * <td>{@link #SUMMARY_WITH_PHONES}</td>
4871     * <td>read-only</td>
4872     * <td>The total number of {@link Contacts} that have both
4873     * {@link CommonDataKinds.GroupMembership} in this group, and also have
4874     * phone numbers. Read-only value that is only present when querying
4875     * {@link Groups#CONTENT_SUMMARY_URI}.</td>
4876     * </tr>
4877     * <tr>
4878     * <td>int</td>
4879     * <td>{@link #GROUP_VISIBLE}</td>
4880     * <td>read-only</td>
4881     * <td>Flag indicating if the contacts belonging to this group should be
4882     * visible in any user interface. Allowed values: 0 and 1.</td>
4883     * </tr>
4884     * <tr>
4885     * <td>int</td>
4886     * <td>{@link #DELETED}</td>
4887     * <td>read/write</td>
4888     * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
4889     * for deletion. When {@link android.content.ContentResolver#delete} is
4890     * called on a group, it is marked for deletion. The sync adaptor deletes
4891     * the group on the server and then calls ContactResolver.delete once more,
4892     * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
4893     * query parameter to finalize the data removal.</td>
4894     * </tr>
4895     * <tr>
4896     * <td>int</td>
4897     * <td>{@link #SHOULD_SYNC}</td>
4898     * <td>read/write</td>
4899     * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
4900     * is false for this group's account.</td>
4901     * </tr>
4902     * </table>
4903     */
4904    public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
4905        /**
4906         * This utility class cannot be instantiated
4907         */
4908        private Groups() {
4909        }
4910
4911        /**
4912         * The content:// style URI for this table
4913         */
4914        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
4915
4916        /**
4917         * The content:// style URI for this table joined with details data from
4918         * {@link ContactsContract.Data}.
4919         */
4920        public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
4921                "groups_summary");
4922
4923        /**
4924         * The MIME type of a directory of groups.
4925         */
4926        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
4927
4928        /**
4929         * The MIME type of a single group.
4930         */
4931        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
4932
4933        public static EntityIterator newEntityIterator(Cursor cursor) {
4934            return new EntityIteratorImpl(cursor);
4935        }
4936
4937        private static class EntityIteratorImpl extends CursorEntityIterator {
4938            public EntityIteratorImpl(Cursor cursor) {
4939                super(cursor);
4940            }
4941
4942            @Override
4943            public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
4944                // we expect the cursor is already at the row we need to read from
4945                final ContentValues values = new ContentValues();
4946                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
4947                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
4948                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
4949                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
4950                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
4951                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
4952                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
4953                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
4954                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
4955                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
4956                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
4957                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
4958                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
4959                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
4960                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
4961                DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
4962                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
4963                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
4964                cursor.moveToNext();
4965                return new Entity(values);
4966            }
4967        }
4968    }
4969
4970    /**
4971     * <p>
4972     * Constants for the contact aggregation exceptions table, which contains
4973     * aggregation rules overriding those used by automatic aggregation. This
4974     * type only supports query and update. Neither insert nor delete are
4975     * supported.
4976     * </p>
4977     * <h2>Columns</h2>
4978     * <table class="jd-sumtable">
4979     * <tr>
4980     * <th colspan='4'>AggregationExceptions</th>
4981     * </tr>
4982     * <tr>
4983     * <td>int</td>
4984     * <td>{@link #TYPE}</td>
4985     * <td>read/write</td>
4986     * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
4987     * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
4988     * </tr>
4989     * <tr>
4990     * <td>long</td>
4991     * <td>{@link #RAW_CONTACT_ID1}</td>
4992     * <td>read/write</td>
4993     * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
4994     * the rule applies to.</td>
4995     * </tr>
4996     * <tr>
4997     * <td>long</td>
4998     * <td>{@link #RAW_CONTACT_ID2}</td>
4999     * <td>read/write</td>
5000     * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
5001     * that the rule applies to.</td>
5002     * </tr>
5003     * </table>
5004     */
5005    public static final class AggregationExceptions implements BaseColumns {
5006        /**
5007         * This utility class cannot be instantiated
5008         */
5009        private AggregationExceptions() {}
5010
5011        /**
5012         * The content:// style URI for this table
5013         */
5014        public static final Uri CONTENT_URI =
5015                Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
5016
5017        /**
5018         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
5019         */
5020        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
5021
5022        /**
5023         * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
5024         */
5025        public static final String CONTENT_ITEM_TYPE =
5026                "vnd.android.cursor.item/aggregation_exception";
5027
5028        /**
5029         * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
5030         * {@link #TYPE_AUTOMATIC}.
5031         *
5032         * <P>Type: INTEGER</P>
5033         */
5034        public static final String TYPE = "type";
5035
5036        /**
5037         * Allows the provider to automatically decide whether the specified raw contacts should
5038         * be included in the same aggregate contact or not.
5039         */
5040        public static final int TYPE_AUTOMATIC = 0;
5041
5042        /**
5043         * Makes sure that the specified raw contacts are included in the same
5044         * aggregate contact.
5045         */
5046        public static final int TYPE_KEEP_TOGETHER = 1;
5047
5048        /**
5049         * Makes sure that the specified raw contacts are NOT included in the same
5050         * aggregate contact.
5051         */
5052        public static final int TYPE_KEEP_SEPARATE = 2;
5053
5054        /**
5055         * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
5056         */
5057        public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
5058
5059        /**
5060         * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
5061         * applies to.
5062         */
5063        public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
5064    }
5065
5066    /**
5067     * @see Settings
5068     */
5069    protected interface SettingsColumns {
5070        /**
5071         * The name of the account instance to which this row belongs.
5072         * <P>Type: TEXT</P>
5073         */
5074        public static final String ACCOUNT_NAME = "account_name";
5075
5076        /**
5077         * The type of account to which this row belongs, which when paired with
5078         * {@link #ACCOUNT_NAME} identifies a specific account.
5079         * <P>Type: TEXT</P>
5080         */
5081        public static final String ACCOUNT_TYPE = "account_type";
5082
5083        /**
5084         * Depending on the mode defined by the sync-adapter, this flag controls
5085         * the top-level sync behavior for this data source.
5086         * <p>
5087         * Type: INTEGER (boolean)
5088         */
5089        public static final String SHOULD_SYNC = "should_sync";
5090
5091        /**
5092         * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
5093         * entries should be visible in any user interface.
5094         * <p>
5095         * Type: INTEGER (boolean)
5096         */
5097        public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
5098
5099        /**
5100         * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
5101         * {@link Groups#SHOULD_SYNC} under this account have been marked as
5102         * unsynced.
5103         */
5104        public static final String ANY_UNSYNCED = "any_unsynced";
5105
5106        /**
5107         * Read-only count of {@link Contacts} from a specific source that have
5108         * no {@link CommonDataKinds.GroupMembership} entries.
5109         * <p>
5110         * Type: INTEGER
5111         */
5112        public static final String UNGROUPED_COUNT = "summ_count";
5113
5114        /**
5115         * Read-only count of {@link Contacts} from a specific source that have
5116         * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
5117         * <p>
5118         * Type: INTEGER
5119         */
5120        public static final String UNGROUPED_WITH_PHONES = "summ_phones";
5121    }
5122
5123    /**
5124     * <p>
5125     * Contacts-specific settings for various {@link Account}'s.
5126     * </p>
5127     * <h2>Columns</h2>
5128     * <table class="jd-sumtable">
5129     * <tr>
5130     * <th colspan='4'>Settings</th>
5131     * </tr>
5132     * <tr>
5133     * <td>String</td>
5134     * <td>{@link #ACCOUNT_NAME}</td>
5135     * <td>read/write-once</td>
5136     * <td>The name of the account instance to which this row belongs.</td>
5137     * </tr>
5138     * <tr>
5139     * <td>String</td>
5140     * <td>{@link #ACCOUNT_TYPE}</td>
5141     * <td>read/write-once</td>
5142     * <td>The type of account to which this row belongs, which when paired with
5143     * {@link #ACCOUNT_NAME} identifies a specific account.</td>
5144     * </tr>
5145     * <tr>
5146     * <td>int</td>
5147     * <td>{@link #SHOULD_SYNC}</td>
5148     * <td>read/write</td>
5149     * <td>Depending on the mode defined by the sync-adapter, this flag controls
5150     * the top-level sync behavior for this data source.</td>
5151     * </tr>
5152     * <tr>
5153     * <td>int</td>
5154     * <td>{@link #UNGROUPED_VISIBLE}</td>
5155     * <td>read/write</td>
5156     * <td>Flag indicating if contacts without any
5157     * {@link CommonDataKinds.GroupMembership} entries should be visible in any
5158     * user interface.</td>
5159     * </tr>
5160     * <tr>
5161     * <td>int</td>
5162     * <td>{@link #ANY_UNSYNCED}</td>
5163     * <td>read-only</td>
5164     * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
5165     * {@link Groups#SHOULD_SYNC} under this account have been marked as
5166     * unsynced.</td>
5167     * </tr>
5168     * <tr>
5169     * <td>int</td>
5170     * <td>{@link #UNGROUPED_COUNT}</td>
5171     * <td>read-only</td>
5172     * <td>Read-only count of {@link Contacts} from a specific source that have
5173     * no {@link CommonDataKinds.GroupMembership} entries.</td>
5174     * </tr>
5175     * <tr>
5176     * <td>int</td>
5177     * <td>{@link #UNGROUPED_WITH_PHONES}</td>
5178     * <td>read-only</td>
5179     * <td>Read-only count of {@link Contacts} from a specific source that have
5180     * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
5181     * numbers.</td>
5182     * </tr>
5183     * </table>
5184     */
5185
5186    public static final class Settings implements SettingsColumns {
5187        /**
5188         * This utility class cannot be instantiated
5189         */
5190        private Settings() {
5191        }
5192
5193        /**
5194         * The content:// style URI for this table
5195         */
5196        public static final Uri CONTENT_URI =
5197                Uri.withAppendedPath(AUTHORITY_URI, "settings");
5198
5199        /**
5200         * The MIME-type of {@link #CONTENT_URI} providing a directory of
5201         * settings.
5202         */
5203        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
5204
5205        /**
5206         * The MIME-type of {@link #CONTENT_URI} providing a single setting.
5207         */
5208        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
5209    }
5210
5211    /**
5212     * Helper methods to display QuickContact dialogs that allow users to pivot on
5213     * a specific {@link Contacts} entry.
5214     */
5215    public static final class QuickContact {
5216        /**
5217         * Action used to trigger person pivot dialog.
5218         * @hide
5219         */
5220        public static final String ACTION_QUICK_CONTACT =
5221                "com.android.contacts.action.QUICK_CONTACT";
5222
5223        /**
5224         * Extra used to specify pivot dialog location in screen coordinates.
5225         * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
5226         * @hide
5227         */
5228        @Deprecated
5229        public static final String EXTRA_TARGET_RECT = "target_rect";
5230
5231        /**
5232         * Extra used to specify size of pivot dialog.
5233         * @hide
5234         */
5235        public static final String EXTRA_MODE = "mode";
5236
5237        /**
5238         * Extra used to indicate a list of specific MIME-types to exclude and
5239         * not display. Stored as a {@link String} array.
5240         * @hide
5241         */
5242        public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
5243
5244        /**
5245         * Small QuickContact mode, usually presented with minimal actions.
5246         */
5247        public static final int MODE_SMALL = 1;
5248
5249        /**
5250         * Medium QuickContact mode, includes actions and light summary describing
5251         * the {@link Contacts} entry being shown. This may include social
5252         * status and presence details.
5253         */
5254        public static final int MODE_MEDIUM = 2;
5255
5256        /**
5257         * Large QuickContact mode, includes actions and larger, card-like summary
5258         * of the {@link Contacts} entry being shown. This may include detailed
5259         * information, such as a photo.
5260         */
5261        public static final int MODE_LARGE = 3;
5262
5263        /**
5264         * Trigger a dialog that lists the various methods of interacting with
5265         * the requested {@link Contacts} entry. This may be based on available
5266         * {@link ContactsContract.Data} rows under that contact, and may also
5267         * include social status and presence details.
5268         *
5269         * @param context The parent {@link Context} that may be used as the
5270         *            parent for this dialog.
5271         * @param target Specific {@link View} from your layout that this dialog
5272         *            should be centered around. In particular, if the dialog
5273         *            has a "callout" arrow, it will be pointed and centered
5274         *            around this {@link View}.
5275         * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
5276         *            {@link Uri} that describes a specific contact to feature
5277         *            in this dialog.
5278         * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
5279         *            {@link #MODE_LARGE}, indicating the desired dialog size,
5280         *            when supported.
5281         * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
5282         *            to exclude when showing this dialog. For example, when
5283         *            already viewing the contact details card, this can be used
5284         *            to omit the details entry from the dialog.
5285         */
5286        public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
5287                String[] excludeMimes) {
5288            // Find location and bounds of target view, adjusting based on the
5289            // assumed local density.
5290            final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
5291            final int[] pos = new int[2];
5292            target.getLocationOnScreen(pos);
5293
5294            final Rect rect = new Rect();
5295            rect.left = (int) (pos[0] * appScale + 0.5f);
5296            rect.top = (int) (pos[1] * appScale + 0.5f);
5297            rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
5298            rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
5299
5300            // Trigger with obtained rectangle
5301            showQuickContact(context, rect, lookupUri, mode, excludeMimes);
5302        }
5303
5304        /**
5305         * Trigger a dialog that lists the various methods of interacting with
5306         * the requested {@link Contacts} entry. This may be based on available
5307         * {@link ContactsContract.Data} rows under that contact, and may also
5308         * include social status and presence details.
5309         *
5310         * @param context The parent {@link Context} that may be used as the
5311         *            parent for this dialog.
5312         * @param target Specific {@link Rect} that this dialog should be
5313         *            centered around, in screen coordinates. In particular, if
5314         *            the dialog has a "callout" arrow, it will be pointed and
5315         *            centered around this {@link Rect}. If you are running at a
5316         *            non-native density, you need to manually adjust using
5317         *            {@link DisplayMetrics#density} before calling.
5318         * @param lookupUri A
5319         *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
5320         *            {@link Uri} that describes a specific contact to feature
5321         *            in this dialog.
5322         * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
5323         *            {@link #MODE_LARGE}, indicating the desired dialog size,
5324         *            when supported.
5325         * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
5326         *            to exclude when showing this dialog. For example, when
5327         *            already viewing the contact details card, this can be used
5328         *            to omit the details entry from the dialog.
5329         */
5330        public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
5331                String[] excludeMimes) {
5332            // Launch pivot dialog through intent for now
5333            final Intent intent = new Intent(ACTION_QUICK_CONTACT);
5334            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
5335                    | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5336
5337            intent.setData(lookupUri);
5338            intent.setSourceBounds(target);
5339            intent.putExtra(EXTRA_MODE, mode);
5340            intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
5341            context.startActivity(intent);
5342        }
5343    }
5344
5345    /**
5346     * Contains helper classes used to create or manage {@link android.content.Intent Intents}
5347     * that involve contacts.
5348     */
5349    public static final class Intents {
5350        /**
5351         * This is the intent that is fired when a search suggestion is clicked on.
5352         */
5353        public static final String SEARCH_SUGGESTION_CLICKED =
5354                "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
5355
5356        /**
5357         * This is the intent that is fired when a search suggestion for dialing a number
5358         * is clicked on.
5359         */
5360        public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
5361                "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
5362
5363        /**
5364         * This is the intent that is fired when a search suggestion for creating a contact
5365         * is clicked on.
5366         */
5367        public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
5368                "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
5369
5370        /**
5371         * Starts an Activity that lets the user pick a contact to attach an image to.
5372         * After picking the contact it launches the image cropper in face detection mode.
5373         */
5374        public static final String ATTACH_IMAGE =
5375                "com.android.contacts.action.ATTACH_IMAGE";
5376
5377        /**
5378         * Takes as input a data URI with a mailto: or tel: scheme. If a single
5379         * contact exists with the given data it will be shown. If no contact
5380         * exists, a dialog will ask the user if they want to create a new
5381         * contact with the provided details filled in. If multiple contacts
5382         * share the data the user will be prompted to pick which contact they
5383         * want to view.
5384         * <p>
5385         * For <code>mailto:</code> URIs, the scheme specific portion must be a
5386         * raw email address, such as one built using
5387         * {@link Uri#fromParts(String, String, String)}.
5388         * <p>
5389         * For <code>tel:</code> URIs, the scheme specific portion is compared
5390         * to existing numbers using the standard caller ID lookup algorithm.
5391         * The number must be properly encoded, for example using
5392         * {@link Uri#fromParts(String, String, String)}.
5393         * <p>
5394         * Any extras from the {@link Insert} class will be passed along to the
5395         * create activity if there are no contacts to show.
5396         * <p>
5397         * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
5398         * prompting the user when the contact doesn't exist.
5399         */
5400        public static final String SHOW_OR_CREATE_CONTACT =
5401                "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
5402
5403        /**
5404         * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
5405         * contact if no matching contact found. Otherwise, default behavior is
5406         * to prompt user with dialog before creating.
5407         * <p>
5408         * Type: BOOLEAN
5409         */
5410        public static final String EXTRA_FORCE_CREATE =
5411                "com.android.contacts.action.FORCE_CREATE";
5412
5413        /**
5414         * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
5415         * description to be shown when prompting user about creating a new
5416         * contact.
5417         * <p>
5418         * Type: STRING
5419         */
5420        public static final String EXTRA_CREATE_DESCRIPTION =
5421            "com.android.contacts.action.CREATE_DESCRIPTION";
5422
5423        /**
5424         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
5425         * dialog location using screen coordinates. When not specified, the
5426         * dialog will be centered.
5427         *
5428         * @hide
5429         */
5430        @Deprecated
5431        public static final String EXTRA_TARGET_RECT = "target_rect";
5432
5433        /**
5434         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
5435         * desired dialog style, usually a variation on size. One of
5436         * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
5437         *
5438         * @hide
5439         */
5440        @Deprecated
5441        public static final String EXTRA_MODE = "mode";
5442
5443        /**
5444         * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
5445         *
5446         * @hide
5447         */
5448        @Deprecated
5449        public static final int MODE_SMALL = 1;
5450
5451        /**
5452         * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
5453         *
5454         * @hide
5455         */
5456        @Deprecated
5457        public static final int MODE_MEDIUM = 2;
5458
5459        /**
5460         * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
5461         *
5462         * @hide
5463         */
5464        @Deprecated
5465        public static final int MODE_LARGE = 3;
5466
5467        /**
5468         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
5469         * a list of specific MIME-types to exclude and not display. Stored as a
5470         * {@link String} array.
5471         *
5472         * @hide
5473         */
5474        @Deprecated
5475        public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
5476
5477        /**
5478         * Intents related to the Contacts app UI.
5479         *
5480         * @hide
5481         */
5482        public static final class UI {
5483            /**
5484             * The action for the default contacts list tab.
5485             */
5486            public static final String LIST_DEFAULT =
5487                    "com.android.contacts.action.LIST_DEFAULT";
5488
5489            /**
5490             * The action for the contacts list tab.
5491             */
5492            public static final String LIST_GROUP_ACTION =
5493                    "com.android.contacts.action.LIST_GROUP";
5494
5495            /**
5496             * When in LIST_GROUP_ACTION mode, this is the group to display.
5497             */
5498            public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
5499
5500            /**
5501             * The action for the all contacts list tab.
5502             */
5503            public static final String LIST_ALL_CONTACTS_ACTION =
5504                    "com.android.contacts.action.LIST_ALL_CONTACTS";
5505
5506            /**
5507             * The action for the contacts with phone numbers list tab.
5508             */
5509            public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
5510                    "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
5511
5512            /**
5513             * The action for the starred contacts list tab.
5514             */
5515            public static final String LIST_STARRED_ACTION =
5516                    "com.android.contacts.action.LIST_STARRED";
5517
5518            /**
5519             * The action for the frequent contacts list tab.
5520             */
5521            public static final String LIST_FREQUENT_ACTION =
5522                    "com.android.contacts.action.LIST_FREQUENT";
5523
5524            /**
5525             * The action for the "strequent" contacts list tab. It first lists the starred
5526             * contacts in alphabetical order and then the frequent contacts in descending
5527             * order of the number of times they have been contacted.
5528             */
5529            public static final String LIST_STREQUENT_ACTION =
5530                    "com.android.contacts.action.LIST_STREQUENT";
5531
5532            /**
5533             * A key for to be used as an intent extra to set the activity
5534             * title to a custom String value.
5535             */
5536            public static final String TITLE_EXTRA_KEY =
5537                    "com.android.contacts.extra.TITLE_EXTRA";
5538
5539            /**
5540             * Activity Action: Display a filtered list of contacts
5541             * <p>
5542             * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
5543             * filtering
5544             * <p>
5545             * Output: Nothing.
5546             */
5547            public static final String FILTER_CONTACTS_ACTION =
5548                    "com.android.contacts.action.FILTER_CONTACTS";
5549
5550            /**
5551             * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
5552             * intents to supply the text on which to filter.
5553             */
5554            public static final String FILTER_TEXT_EXTRA_KEY =
5555                    "com.android.contacts.extra.FILTER_TEXT";
5556        }
5557
5558        /**
5559         * Convenience class that contains string constants used
5560         * to create contact {@link android.content.Intent Intents}.
5561         */
5562        public static final class Insert {
5563            /** The action code to use when adding a contact */
5564            public static final String ACTION = Intent.ACTION_INSERT;
5565
5566            /**
5567             * If present, forces a bypass of quick insert mode.
5568             */
5569            public static final String FULL_MODE = "full_mode";
5570
5571            /**
5572             * The extra field for the contact name.
5573             * <P>Type: String</P>
5574             */
5575            public static final String NAME = "name";
5576
5577            // TODO add structured name values here.
5578
5579            /**
5580             * The extra field for the contact phonetic name.
5581             * <P>Type: String</P>
5582             */
5583            public static final String PHONETIC_NAME = "phonetic_name";
5584
5585            /**
5586             * The extra field for the contact company.
5587             * <P>Type: String</P>
5588             */
5589            public static final String COMPANY = "company";
5590
5591            /**
5592             * The extra field for the contact job title.
5593             * <P>Type: String</P>
5594             */
5595            public static final String JOB_TITLE = "job_title";
5596
5597            /**
5598             * The extra field for the contact notes.
5599             * <P>Type: String</P>
5600             */
5601            public static final String NOTES = "notes";
5602
5603            /**
5604             * The extra field for the contact phone number.
5605             * <P>Type: String</P>
5606             */
5607            public static final String PHONE = "phone";
5608
5609            /**
5610             * The extra field for the contact phone number type.
5611             * <P>Type: Either an integer value from
5612             * {@link CommonDataKinds.Phone},
5613             *  or a string specifying a custom label.</P>
5614             */
5615            public static final String PHONE_TYPE = "phone_type";
5616
5617            /**
5618             * The extra field for the phone isprimary flag.
5619             * <P>Type: boolean</P>
5620             */
5621            public static final String PHONE_ISPRIMARY = "phone_isprimary";
5622
5623            /**
5624             * The extra field for an optional second contact phone number.
5625             * <P>Type: String</P>
5626             */
5627            public static final String SECONDARY_PHONE = "secondary_phone";
5628
5629            /**
5630             * The extra field for an optional second contact phone number type.
5631             * <P>Type: Either an integer value from
5632             * {@link CommonDataKinds.Phone},
5633             *  or a string specifying a custom label.</P>
5634             */
5635            public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
5636
5637            /**
5638             * The extra field for an optional third contact phone number.
5639             * <P>Type: String</P>
5640             */
5641            public static final String TERTIARY_PHONE = "tertiary_phone";
5642
5643            /**
5644             * The extra field for an optional third contact phone number type.
5645             * <P>Type: Either an integer value from
5646             * {@link CommonDataKinds.Phone},
5647             *  or a string specifying a custom label.</P>
5648             */
5649            public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
5650
5651            /**
5652             * The extra field for the contact email address.
5653             * <P>Type: String</P>
5654             */
5655            public static final String EMAIL = "email";
5656
5657            /**
5658             * The extra field for the contact email type.
5659             * <P>Type: Either an integer value from
5660             * {@link CommonDataKinds.Email}
5661             *  or a string specifying a custom label.</P>
5662             */
5663            public static final String EMAIL_TYPE = "email_type";
5664
5665            /**
5666             * The extra field for the email isprimary flag.
5667             * <P>Type: boolean</P>
5668             */
5669            public static final String EMAIL_ISPRIMARY = "email_isprimary";
5670
5671            /**
5672             * The extra field for an optional second contact email address.
5673             * <P>Type: String</P>
5674             */
5675            public static final String SECONDARY_EMAIL = "secondary_email";
5676
5677            /**
5678             * The extra field for an optional second contact email type.
5679             * <P>Type: Either an integer value from
5680             * {@link CommonDataKinds.Email}
5681             *  or a string specifying a custom label.</P>
5682             */
5683            public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
5684
5685            /**
5686             * The extra field for an optional third contact email address.
5687             * <P>Type: String</P>
5688             */
5689            public static final String TERTIARY_EMAIL = "tertiary_email";
5690
5691            /**
5692             * The extra field for an optional third contact email type.
5693             * <P>Type: Either an integer value from
5694             * {@link CommonDataKinds.Email}
5695             *  or a string specifying a custom label.</P>
5696             */
5697            public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
5698
5699            /**
5700             * The extra field for the contact postal address.
5701             * <P>Type: String</P>
5702             */
5703            public static final String POSTAL = "postal";
5704
5705            /**
5706             * The extra field for the contact postal address type.
5707             * <P>Type: Either an integer value from
5708             * {@link CommonDataKinds.StructuredPostal}
5709             *  or a string specifying a custom label.</P>
5710             */
5711            public static final String POSTAL_TYPE = "postal_type";
5712
5713            /**
5714             * The extra field for the postal isprimary flag.
5715             * <P>Type: boolean</P>
5716             */
5717            public static final String POSTAL_ISPRIMARY = "postal_isprimary";
5718
5719            /**
5720             * The extra field for an IM handle.
5721             * <P>Type: String</P>
5722             */
5723            public static final String IM_HANDLE = "im_handle";
5724
5725            /**
5726             * The extra field for the IM protocol
5727             */
5728            public static final String IM_PROTOCOL = "im_protocol";
5729
5730            /**
5731             * The extra field for the IM isprimary flag.
5732             * <P>Type: boolean</P>
5733             */
5734            public static final String IM_ISPRIMARY = "im_isprimary";
5735        }
5736    }
5737}
5738