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