ContactsContract.java revision b3c49982840c05a5392d53efe97253c04fc59ef0
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.Context;
25import android.content.Intent;
26import android.content.res.Resources;
27import android.database.Cursor;
28import android.graphics.BitmapFactory;
29import android.net.Uri;
30import android.os.RemoteException;
31import android.text.TextUtils;
32
33import java.io.ByteArrayInputStream;
34import java.io.InputStream;
35
36/**
37 * The contract between the contacts provider and applications. Contains definitions
38 * for the supported URIs and columns.
39 *
40 * @hide
41 */
42public final class ContactsContract {
43    /** The authority for the contacts provider */
44    public static final String AUTHORITY = "com.android.contacts";
45    /** A content:// style uri to the authority for the contacts provider */
46    public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
47
48    public interface SyncStateColumns extends SyncStateContract.Columns {
49    }
50
51    public static final class SyncState {
52        /**
53         * This utility class cannot be instantiated
54         */
55        private SyncState() {}
56
57        public static final String CONTENT_DIRECTORY =
58                SyncStateContract.Constants.CONTENT_DIRECTORY;
59
60        /**
61         * The content:// style URI for this table
62         */
63        public static final Uri CONTENT_URI =
64                Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
65
66        /**
67         * @see android.provider.SyncStateContract.Helpers#get
68         */
69        public static byte[] get(ContentProviderClient provider, Account account)
70                throws RemoteException {
71            return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
72        }
73
74        /**
75         * @see android.provider.SyncStateContract.Helpers#set
76         */
77        public static void set(ContentProviderClient provider, Account account, byte[] data)
78                throws RemoteException {
79            SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
80        }
81
82        /**
83         * @see android.provider.SyncStateContract.Helpers#newSetOperation
84         */
85        public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
86            return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
87        }
88    }
89
90    /**
91     * Generic columns for use by sync adapters. The specific functions of
92     * these columns are private to the sync adapter. Other clients of the API
93     * should not attempt to either read or write this column.
94     */
95    private interface BaseSyncColumns {
96
97        /** Generic column for use by sync adapters. */
98        public static final String SYNC1 = "sync1";
99        /** Generic column for use by sync adapters. */
100        public static final String SYNC2 = "sync2";
101        /** Generic column for use by sync adapters. */
102        public static final String SYNC3 = "sync3";
103        /** Generic column for use by sync adapters. */
104        public static final String SYNC4 = "sync4";
105    }
106
107    /**
108     * Columns that appear when each row of a table belongs to a specific
109     * account, including sync information that an account may need.
110     */
111    private interface SyncColumns extends BaseSyncColumns {
112        /**
113         * The name of the account instance to which this row belongs.
114         * <P>Type: TEXT</P>
115         */
116        public static final String ACCOUNT_NAME = "account_name";
117
118        /**
119         * The type of account to which this row belongs, which when paired with
120         * {@link #ACCOUNT_NAME} identifies a specific account.
121         * <P>Type: TEXT</P>
122         */
123        public static final String ACCOUNT_TYPE = "account_type";
124
125        /**
126         * String that uniquely identifies this row to its source account.
127         * <P>Type: TEXT</P>
128         */
129        public static final String SOURCE_ID = "sourceid";
130
131        /**
132         * Version number that is updated whenever this row or its related data
133         * changes.
134         * <P>Type: INTEGER</P>
135         */
136        public static final String VERSION = "version";
137
138        /**
139         * Flag indicating that {@link #VERSION} has changed, and this row needs
140         * to be synchronized by its owning account.
141         * <P>Type: INTEGER (boolean)</P>
142         */
143        public static final String DIRTY = "dirty";
144    }
145
146    public interface ContactOptionsColumns {
147        /**
148         * The number of times a person has been contacted
149         * <P>Type: INTEGER</P>
150         */
151        public static final String TIMES_CONTACTED = "times_contacted";
152
153        /**
154         * The last time a person was contacted.
155         * <P>Type: INTEGER</P>
156         */
157        public static final String LAST_TIME_CONTACTED = "last_time_contacted";
158
159        /**
160         * Is the contact starred?
161         * <P>Type: INTEGER (boolean)</P>
162         */
163        public static final String STARRED = "starred";
164
165        /**
166         * A custom ringtone associated with a person. Not always present.
167         * <P>Type: TEXT (URI to the ringtone)</P>
168         */
169        public static final String CUSTOM_RINGTONE = "custom_ringtone";
170
171        /**
172         * Whether the person should always be sent to voicemail. Not always
173         * present.
174         * <P>Type: INTEGER (0 for false, 1 for true)</P>
175         */
176        public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
177    }
178
179    private interface ContactsColumns {
180        /**
181         * The display name for the contact.
182         * <P>Type: TEXT</P>
183         */
184        public static final String DISPLAY_NAME = "display_name";
185
186        /**
187         * Reference to the row in the data table holding the photo.
188         * <P>Type: INTEGER REFERENCES data(_id)</P>
189         */
190        public static final String PHOTO_ID = "photo_id";
191
192        /**
193         * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of
194         * any {@link CommonDataKinds.GroupMembership} for this contact.
195         */
196        public static final String IN_VISIBLE_GROUP = "in_visible_group";
197
198        /**
199         * Contact presence status.  See {@link android.provider.Im.CommonPresenceColumns}
200         * for individual status definitions.  This column is only returned if explicitly
201         * requested in the query projection.
202         * <p>Type: NUMBER</p>
203         */
204        public static final String PRESENCE_STATUS = Presence.PRESENCE_STATUS;
205
206        /**
207         * Contact presence custom status. This column is only returned if explicitly
208         * requested in the query projection.
209         * <p>Type: TEXT</p>
210         */
211        public static final String PRESENCE_CUSTOM_STATUS = Presence.PRESENCE_CUSTOM_STATUS;
212
213        /**
214         * An indicator of whether this contact has at least one phone number. "1" if there is
215         * at least one phone number, "0" otherwise.
216         * <P>Type: INTEGER</P>
217         */
218        public static final String HAS_PHONE_NUMBER = "has_phone_number";
219
220        /**
221         * An opaque value that contains hints on how to find the contact if
222         * its row id changed as a result of a sync or aggregation.
223         */
224        public static final String LOOKUP_KEY = "lookup";
225    }
226
227    /**
228     * Constants for the contacts table, which contains a record per group
229     * of raw contact representing the same person.
230     */
231    public static class Contacts implements BaseColumns, ContactsColumns,
232            ContactOptionsColumns {
233        /**
234         * This utility class cannot be instantiated
235         */
236        private Contacts()  {}
237
238        /**
239         * The content:// style URI for this table
240         */
241        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
242
243        /**
244         * A content:// style URI for this table that should be used to create
245         * shortcuts or otherwise create long-term links to contacts. This URI
246         * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
247         * It can optionally also have a "/" and last known contact ID appended after
248         * that. This "complete" format is an important optimization and is highly recommended.
249         * <p>
250         * As long as the contact's row ID remains the same, this URI is
251         * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
252         * as a result of a sync or aggregation, this URI will look up the
253         * contact using indirect information (sync IDs or constituent raw
254         * contacts).
255         * <p>
256         * Lookup key should be appended unencoded - it is stored in the encoded
257         * form, ready for use in a URI.
258         */
259        public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
260                "lookup");
261
262        /**
263         * Computes a complete lookup URI (see {@link #CONTENT_LOOKUP_URI}).
264         * Pass either a basic content URI with a contact ID to obtain an
265         * equivalent lookup URI. Pass a possibly stale lookup URI to get a fresh
266         * lookup URI for the same contact.
267         * <p>
268         * Returns null if the contact cannot be found.
269         */
270        public static Uri getLookupUri(ContentResolver resolver, Uri contentUri) {
271            Cursor c = resolver.query(contentUri,
272                    new String[]{Contacts.LOOKUP_KEY, Contacts._ID}, null, null, null);
273            if (c == null) {
274                return null;
275            }
276
277            try {
278                if (c.moveToFirst()) {
279                    String lookupKey = c.getString(0);
280                    long contactId = c.getLong(1);
281                    return ContentUris.withAppendedId(
282                            Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey),
283                            contactId);
284                }
285            } finally {
286                c.close();
287            }
288            return null;
289        }
290
291        /**
292         * The content:// style URI for this table joined with useful data from
293         * {@link Data}.
294         *
295         * @deprecated Please use plain CONTENT_URI for the same result
296         */
297        @Deprecated
298        public static final Uri CONTENT_SUMMARY_URI = CONTENT_URI;
299
300        /**
301         * The content:// style URI used for "type-to-filter" functionality on the
302         * {@link #CONTENT_URI} URI. The filter string will be used to match
303         * various parts of the contact name. The filter argument should be passed
304         * as an additional path segment after this URI.
305         */
306        public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
307                CONTENT_URI, "filter");
308
309        @Deprecated
310        public static final Uri CONTENT_SUMMARY_FILTER_URI = CONTENT_FILTER_URI;
311
312        /**
313         * The content:// style URI for this table joined with useful data from
314         * {@link Data}, filtered to include only starred contacts
315         * and the most frequently contacted contacts.
316         */
317        public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
318                CONTENT_URI, "strequent");
319
320        @Deprecated
321        public static final Uri CONTENT_SUMMARY_STREQUENT_URI = CONTENT_STREQUENT_URI;
322
323        /**
324         * The content:// style URI used for "type-to-filter" functionality on the
325         * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
326         * various parts of the contact name. The filter argument should be passed
327         * as an additional path segment after this URI.
328         */
329        public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
330                CONTENT_STREQUENT_URI, "filter");
331
332        @Deprecated
333        public static final Uri CONTENT_SUMMARY_STREQUENT_FILTER_URI = CONTENT_STREQUENT_FILTER_URI;
334
335        public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
336                CONTENT_URI, "group");
337
338        @Deprecated
339        public static final Uri CONTENT_SUMMARY_GROUP_URI = CONTENT_GROUP_URI;
340        /**
341         * The MIME type of {@link #CONTENT_URI} providing a directory of
342         * people.
343         */
344        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
345
346        /**
347         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
348         * person.
349         */
350        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
351
352        /**
353         * A sub-directory of a single contact that contains all of the constituent raw contact
354         * {@link Data} rows.
355         */
356        public static final class Data implements BaseColumns, DataColumns {
357            /**
358             * no public constructor since this is a utility class
359             */
360            private Data() {}
361
362            /**
363             * The directory twig for this sub-table
364             */
365            public static final String CONTENT_DIRECTORY = "data";
366        }
367
368        /**
369         * A sub-directory of a single contact aggregate that contains all aggregation suggestions
370         * (other contacts).  The aggregation suggestions are computed based on approximate
371         * data matches with this contact.
372         */
373        public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
374            /**
375             * No public constructor since this is a utility class
376             */
377            private AggregationSuggestions() {}
378
379            /**
380             * The directory twig for this sub-table
381             */
382            public static final String CONTENT_DIRECTORY = "suggestions";
383        }
384
385        /**
386         * A sub-directory of a single contact that contains the contact's primary photo.
387         */
388        public static final class Photo implements BaseColumns, DataColumns {
389            /**
390             * no public constructor since this is a utility class
391             */
392            private Photo() {}
393
394            /**
395             * The directory twig for this sub-table
396             */
397            public static final String CONTENT_DIRECTORY = "photo";
398        }
399
400        /**
401         * Opens an InputStream for the person's default photo and returns the
402         * photo as a Bitmap stream.
403         *
404         * @param contactUri the contact whose photo should be used
405         */
406        public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
407            Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
408            if (photoUri == null) {
409                return null;
410            }
411            Cursor cursor = cr.query(photoUri,
412                    new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
413            try {
414                if (cursor == null || !cursor.moveToNext()) {
415                    return null;
416                }
417                byte[] data = cursor.getBlob(0);
418                if (data == null) {
419                    return null;
420                }
421                return new ByteArrayInputStream(data);
422            } finally {
423                if (cursor != null) {
424                    cursor.close();
425                }
426            }
427        }
428    }
429
430    private interface RawContactsColumns {
431        /**
432         * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this
433         * data belongs to.
434         * <P>Type: INTEGER</P>
435         */
436        public static final String CONTACT_ID = "contact_id";
437
438        /**
439         * Flag indicating that this {@link RawContacts} entry and its children has
440         * been restricted to specific platform apps.
441         * <P>Type: INTEGER (boolean)</P>
442         *
443         * @hide until finalized in future platform release
444         */
445        public static final String IS_RESTRICTED = "is_restricted";
446
447        /**
448         * The aggregation mode for this contact.
449         * <P>Type: INTEGER</P>
450         */
451        public static final String AGGREGATION_MODE = "aggregation_mode";
452
453        /**
454         * The "deleted" flag: "0" by default, "1" if the row has been marked
455         * for deletion. When {@link android.content.ContentResolver#delete} is
456         * called on a raw contact, it is marked for deletion and removed from its
457         * aggregate contact. The sync adaptor deletes the raw contact on the server and
458         * then calls ContactResolver.delete once more, this time passing the
459         * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal.
460         * <P>Type: INTEGER</P>
461         */
462        public static final String DELETED = "deleted";
463    }
464
465    /**
466     * Constants for the raw_contacts table, which contains the base contact
467     * information per sync source. Sync adapters and contact management apps
468     * are the primary consumers of this API.
469     */
470    public static final class RawContacts implements BaseColumns, RawContactsColumns,
471            ContactOptionsColumns, SyncColumns  {
472        /**
473         * This utility class cannot be instantiated
474         */
475        private RawContacts() {
476        }
477
478        /**
479         * The content:// style URI for this table
480         */
481        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
482
483        /**
484         * The content:// style URL for filtering people by email address. The
485         * filter argument should be passed as an additional path segment after
486         * this URI.
487         *
488         * @hide
489         */
490        @Deprecated
491        public static final Uri CONTENT_FILTER_EMAIL_URI =
492                Uri.withAppendedPath(CONTENT_URI, "filter_email");
493
494        /**
495         * The MIME type of {@link #CONTENT_URI} providing a directory of
496         * people.
497         */
498        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
499
500        /**
501         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
502         * person.
503         */
504        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
505
506        /**
507         * Query parameter that can be passed with the {@link #CONTENT_URI} URI
508         * to the {@link android.content.ContentResolver#delete} method to
509         * indicate that the raw contact can be deleted physically, rather than
510         * merely marked as deleted.
511         */
512        public static final String DELETE_PERMANENTLY = "delete_permanently";
513
514        /**
515         * Aggregation mode: aggregate asynchronously.
516         */
517        public static final int AGGREGATION_MODE_DEFAULT = 0;
518
519        /**
520         * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
521         */
522        public static final int AGGREGATION_MODE_IMMEDITATE = 1;
523
524        /**
525         * If {@link #AGGREGATION_MODE} is {@link #AGGREGATION_MODE_SUSPENDED}, changes
526         * to the raw contact do not cause its aggregation to be revisited. Note that changing
527         * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
528         * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass. Any subsequent
529         * change to the raw contact's data will.
530         */
531        public static final int AGGREGATION_MODE_SUSPENDED = 2;
532
533        /**
534         * Aggregation mode: never aggregate this raw contact (note that the raw contact will not
535         * have a corresponding Aggregate and therefore will not be included in Aggregates
536         * query results.)
537         */
538        public static final int AGGREGATION_MODE_DISABLED = 3;
539
540        /**
541         * A sub-directory of a single raw contact that contains all of their {@link Data} rows.
542         * To access this directory append {@link Data#CONTENT_DIRECTORY} to the contact URI.
543         */
544        public static final class Data implements BaseColumns, DataColumns {
545            /**
546             * no public constructor since this is a utility class
547             */
548            private Data() {
549            }
550
551            /**
552             * The directory twig for this sub-table
553             */
554            public static final String CONTENT_DIRECTORY = "data";
555        }
556    }
557
558    private interface DataColumns {
559        /**
560         * The package name to use when creating {@link Resources} objects for
561         * this data row. This value is only designed for use when building user
562         * interfaces, and should not be used to infer the owner.
563         */
564        public static final String RES_PACKAGE = "res_package";
565
566        /**
567         * The MIME type of the item represented by this row.
568         */
569        public static final String MIMETYPE = "mimetype";
570
571        /**
572         * A reference to the {@link RawContacts#_ID}
573         * that this data belongs to.
574         */
575        public static final String RAW_CONTACT_ID = "raw_contact_id";
576
577        /**
578         * Whether this is the primary entry of its kind for the raw contact it belongs to
579         * <P>Type: INTEGER (if set, non-0 means true)</P>
580         */
581        public static final String IS_PRIMARY = "is_primary";
582
583        /**
584         * Whether this is the primary entry of its kind for the aggregate
585         * contact it belongs to. Any data record that is "super primary" must
586         * also be "primary".
587         * <P>Type: INTEGER (if set, non-0 means true)</P>
588         */
589        public static final String IS_SUPER_PRIMARY = "is_super_primary";
590
591        /**
592         * The version of this data record. This is a read-only value. The data column is
593         * guaranteed to not change without the version going up. This value is monotonically
594         * increasing.
595         * <P>Type: INTEGER</P>
596         */
597        public static final String DATA_VERSION = "data_version";
598
599        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
600        public static final String DATA1 = "data1";
601        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
602        public static final String DATA2 = "data2";
603        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
604        public static final String DATA3 = "data3";
605        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
606        public static final String DATA4 = "data4";
607        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
608        public static final String DATA5 = "data5";
609        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
610        public static final String DATA6 = "data6";
611        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
612        public static final String DATA7 = "data7";
613        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
614        public static final String DATA8 = "data8";
615        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
616        public static final String DATA9 = "data9";
617        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
618        public static final String DATA10 = "data10";
619        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
620        public static final String DATA11 = "data11";
621        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
622        public static final String DATA12 = "data12";
623        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
624        public static final String DATA13 = "data13";
625        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
626        public static final String DATA14 = "data14";
627        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
628        public static final String DATA15 = "data15";
629
630        /** Generic column for use by sync adapters. */
631        public static final String SYNC1 = "data_sync1";
632        /** Generic column for use by sync adapters. */
633        public static final String SYNC2 = "data_sync2";
634        /** Generic column for use by sync adapters. */
635        public static final String SYNC3 = "data_sync3";
636        /** Generic column for use by sync adapters. */
637        public static final String SYNC4 = "data_sync4";
638
639        /**
640         * An optional insert, update or delete URI parameter that determines if
641         * the corresponding raw contact should be marked as dirty. The default
642         * value is true.
643         */
644        public static final String MARK_AS_DIRTY = "mark_as_dirty";
645    }
646
647    /**
648     * Constants for the data table, which contains data points tied to a raw contact.
649     * For example, a phone number or email address. Each row in this table contains a type
650     * definition and some generic columns. Each data type can define the meaning for each of
651     * the generic columns.
652     */
653    public static final class Data implements BaseColumns, DataColumns {
654        /**
655         * This utility class cannot be instantiated
656         */
657        private Data() {}
658
659        /**
660         * The content:// style URI for this table
661         */
662        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
663
664        /**
665         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
666         */
667        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
668    }
669
670    private interface PhoneLookupColumns {
671        /**
672         * The phone number as the user entered it.
673         * <P>Type: TEXT</P>
674         */
675        public static final String NUMBER = "number";
676
677        /**
678         * The type of phone number, for example Home or Work.
679         * <P>Type: INTEGER</P>
680         */
681        public static final String TYPE = "type";
682
683        /**
684         * The user defined label for the phone number.
685         * <P>Type: TEXT</P>
686         */
687        public static final String LABEL = "label";
688    }
689
690    /**
691     * A table that represents the result of looking up a phone number, for
692     * example for caller ID. To perform a lookup you must append the number you
693     * want to find to {@link #CONTENT_FILTER_URI}.
694     */
695    public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
696            ContactsColumns, ContactOptionsColumns {
697        /**
698         * This utility class cannot be instantiated
699         */
700        private PhoneLookup() {}
701
702        /**
703         * The content:// style URI for this table. Append the phone number you want to lookup
704         * to this URI and query it to perform a lookup. For example:
705         *
706         * {@code
707         * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);
708         * }
709         */
710        public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
711                "phone_lookup");
712    }
713
714    /**
715     * Additional data mixed in with {@link Im.CommonPresenceColumns} to link
716     * back to specific {@link ContactsContract.Contacts#_ID} entries.
717     */
718    private interface PresenceColumns {
719
720        /**
721         * The unique ID for a row.
722         * <P>Type: INTEGER (long)</P>
723         */
724        public static final String _ID = "presence_id";
725
726        /**
727         * Reference to the {@link RawContacts#_ID} this presence references.
728         * <P>Type: INTEGER</P>
729         *
730         * TODO remove this from public API
731         * @hide
732         */
733        @Deprecated
734        public static final String RAW_CONTACT_ID = "presence_raw_contact_id";
735
736        /**
737         * Reference to the {@link Data#_ID} entry that owns this presence.
738         * <P>Type: INTEGER</P>
739         */
740        public static final String DATA_ID = "presence_data_id";
741
742        @Deprecated
743        public static final String IM_PROTOCOL = "im_protocol";
744
745        /**
746         * <p>Type: NUMBER</p>
747         */
748        public static final String PROTOCOL = "protocol";
749
750        /**
751         * Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
752         * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
753         * omitted if {@link #PROTOCOL} value is not
754         * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
755         *
756         * <p>Type: NUMBER</p>
757         */
758        public static final String CUSTOM_PROTOCOL = "custom_protocol";
759
760        /**
761         * The IM handle the presence item is for. The handle is scoped to
762         * {@link #PROTOCOL}.
763         * <P>Type: TEXT</P>
764         */
765        public static final String IM_HANDLE = "im_handle";
766
767        /**
768         * The IM account for the local user that the presence data came from.
769         * <P>Type: TEXT</P>
770         */
771        public static final String IM_ACCOUNT = "im_account";
772    }
773
774    public static final class Presence implements PresenceColumns, Im.CommonPresenceColumns {
775        /**
776         * This utility class cannot be instantiated
777         */
778        private Presence() {
779        }
780
781        /**
782         * The content:// style URI for this table
783         */
784        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence");
785
786        /**
787         * Gets the resource ID for the proper presence icon.
788         *
789         * @param status the status to get the icon for
790         * @return the resource ID for the proper presence icon
791         */
792        public static final int getPresenceIconResourceId(int status) {
793            switch (status) {
794                case AVAILABLE:
795                    return android.R.drawable.presence_online;
796                case IDLE:
797                case AWAY:
798                    return android.R.drawable.presence_away;
799                case DO_NOT_DISTURB:
800                    return android.R.drawable.presence_busy;
801                case INVISIBLE:
802                    return android.R.drawable.presence_invisible;
803                case OFFLINE:
804                default:
805                    return android.R.drawable.presence_offline;
806            }
807        }
808
809        /**
810         * Returns the precedence of the status code the higher number being the higher precedence.
811         *
812         * @param status The status code.
813         * @return An integer representing the precedence, 0 being the lowest.
814         */
815        public static final int getPresencePrecedence(int status) {
816            // Keep this function here incase we want to enforce a different precedence than the
817            // natural order of the status constants.
818            return status;
819        }
820
821        /**
822         * The MIME type of {@link #CONTENT_URI} providing a directory of
823         * presence details.
824         */
825        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence";
826
827        /**
828         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
829         * presence detail.
830         */
831        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence";
832    }
833
834    /**
835     * Container for definitions of common data types stored in the {@link Data} table.
836     */
837    public static final class CommonDataKinds {
838        /**
839         * The {@link Data#RES_PACKAGE} value for common data that should be
840         * shown using a default style.
841         */
842        public static final String PACKAGE_COMMON = "common";
843
844        /**
845         * Columns common across the specific types.
846         */
847        private interface BaseCommonColumns {
848            /**
849             * The package name to use when creating {@link Resources} objects for
850             * this data row. This value is only designed for use when building user
851             * interfaces, and should not be used to infer the owner.
852             */
853            public static final String RES_PACKAGE = "res_package";
854
855            /**
856             * The MIME type of the item represented by this row.
857             */
858            public static final String MIMETYPE = "mimetype";
859
860            /**
861             * The {@link RawContacts#_ID} that this data belongs to.
862             */
863            public static final String RAW_CONTACT_ID = "raw_contact_id";
864        }
865
866        /**
867         * The base types that all "Typed" data kinds support.
868         */
869        public interface BaseTypes {
870
871            /**
872             * A custom type. The custom label should be supplied by user.
873             */
874            public static int TYPE_CUSTOM = 0;
875        }
876
877        /**
878         * Columns common across the specific types.
879         */
880        private interface CommonColumns extends BaseTypes{
881            /**
882             * The type of data, for example Home or Work.
883             * <P>Type: INTEGER</P>
884             */
885            public static final String TYPE = "data1";
886
887            /**
888             * The data for the contact method.
889             * <P>Type: TEXT</P>
890             */
891            public static final String DATA = "data2";
892
893            /**
894             * The user defined label for the the contact method.
895             * <P>Type: TEXT</P>
896             */
897            public static final String LABEL = "data3";
898        }
899
900        /**
901         * Parts of the name.
902         */
903        public static final class StructuredName implements BaseCommonColumns {
904            private StructuredName() {}
905
906            /** MIME type used when storing this in data table. */
907            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
908
909            /**
910             * The given name for the contact.
911             * <P>Type: TEXT</P>
912             */
913            public static final String GIVEN_NAME = "data1";
914
915            /**
916             * The family name for the contact.
917             * <P>Type: TEXT</P>
918             */
919            public static final String FAMILY_NAME = "data2";
920
921            /**
922             * The contact's honorific prefix, e.g. "Sir"
923             * <P>Type: TEXT</P>
924             */
925            public static final String PREFIX = "data3";
926
927            /**
928             * The contact's middle name
929             * <P>Type: TEXT</P>
930             */
931            public static final String MIDDLE_NAME = "data4";
932
933            /**
934             * The contact's honorific suffix, e.g. "Jr"
935             */
936            public static final String SUFFIX = "data5";
937
938            /**
939             * The phonetic version of the given name for the contact.
940             * <P>Type: TEXT</P>
941             */
942            public static final String PHONETIC_GIVEN_NAME = "data6";
943
944            /**
945             * The phonetic version of the additional name for the contact.
946             * <P>Type: TEXT</P>
947             */
948            public static final String PHONETIC_MIDDLE_NAME = "data7";
949
950            /**
951             * The phonetic version of the family name for the contact.
952             * <P>Type: TEXT</P>
953             */
954            public static final String PHONETIC_FAMILY_NAME = "data8";
955
956            /**
957             * The name that should be used to display the contact.
958             * <i>Unstructured component of the name should be consistent with
959             * its structured representation.</i>
960             * <p>
961             * Type: TEXT
962             */
963            public static final String DISPLAY_NAME = "data9";
964        }
965
966        /**
967         * A nickname.
968         */
969        public static final class Nickname implements CommonColumns, BaseCommonColumns {
970            private Nickname() {}
971
972            /** MIME type used when storing this in data table. */
973            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
974
975            public static final int TYPE_DEFAULT = 1;
976            public static final int TYPE_OTHER_NAME = 2;
977            public static final int TYPE_MAINDEN_NAME = 3;
978            public static final int TYPE_SHORT_NAME = 4;
979            public static final int TYPE_INITIALS = 5;
980
981            /**
982             * The name itself
983             */
984            public static final String NAME = DATA;
985        }
986
987        /**
988         * Common data definition for telephone numbers.
989         */
990        public static final class Phone implements BaseCommonColumns, CommonColumns {
991            private Phone() {}
992
993            /** MIME type used when storing this in data table. */
994            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
995
996            /**
997             * The MIME type of {@link #CONTENT_URI} providing a directory of
998             * phones.
999             */
1000            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
1001
1002            /**
1003             * The content:// style URI for all data records of the
1004             * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the
1005             * associated raw contact and aggregate contact data.
1006             */
1007            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1008                    "phones");
1009
1010            /**
1011             * The content:// style URI for filtering data records of the
1012             * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the
1013             * associated raw contact and aggregate contact data. The filter argument should
1014             * be passed as an additional path segment after this URI.
1015             */
1016            public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
1017                    "filter");
1018
1019            public static final int TYPE_HOME = 1;
1020            public static final int TYPE_MOBILE = 2;
1021            public static final int TYPE_WORK = 3;
1022            public static final int TYPE_FAX_WORK = 4;
1023            public static final int TYPE_FAX_HOME = 5;
1024            public static final int TYPE_PAGER = 6;
1025            public static final int TYPE_OTHER = 7;
1026            public static final int TYPE_CALLBACK = 8;
1027            public static final int TYPE_CAR = 9;
1028            public static final int TYPE_COMPANY_MAIN = 10;
1029            public static final int TYPE_ISDN = 11;
1030            public static final int TYPE_MAIN = 12;
1031            public static final int TYPE_OTHER_FAX = 13;
1032            public static final int TYPE_RADIO = 14;
1033            public static final int TYPE_TELEX = 15;
1034            public static final int TYPE_TTY_TDD = 16;
1035            public static final int TYPE_WORK_MOBILE = 17;
1036            public static final int TYPE_WORK_PAGER = 18;
1037            public static final int TYPE_ASSISTANT = 19;
1038
1039            /**
1040             * The phone number as the user entered it.
1041             * <P>Type: TEXT</P>
1042             */
1043            public static final String NUMBER = DATA;
1044
1045            public static final CharSequence getDisplayLabel(Context context, int type,
1046                    CharSequence label, CharSequence[] labelArray) {
1047                CharSequence display = "";
1048
1049                if (type != Phone.TYPE_CUSTOM) {
1050                    CharSequence[] labels = labelArray != null? labelArray
1051                            : context.getResources().getTextArray(
1052                                    com.android.internal.R.array.phoneTypes);
1053                    try {
1054                        display = labels[type - 1];
1055                    } catch (ArrayIndexOutOfBoundsException e) {
1056                        display = labels[Phone.TYPE_CUSTOM];
1057                    }
1058                } else {
1059                    if (!TextUtils.isEmpty(label)) {
1060                        display = label;
1061                    }
1062                }
1063                return display;
1064            }
1065
1066            public static final CharSequence getDisplayLabel(Context context, int type,
1067                    CharSequence label) {
1068                return getDisplayLabel(context, type, label, null);
1069            }
1070        }
1071
1072        /**
1073         * Common data definition for email addresses.
1074         */
1075        public static final class Email implements BaseCommonColumns, CommonColumns {
1076            private Email() {}
1077
1078            /** MIME type used when storing this in data table. */
1079            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
1080
1081            /**
1082             * The content:// style URI for all data records of the
1083             * {@link Email#CONTENT_ITEM_TYPE} MIME type, combined with the
1084             * associated raw contact and aggregate contact data.
1085             */
1086            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1087                    "emails");
1088
1089            /**
1090             * The content:// style URL for filtering data rows by email address. The
1091             * filter argument should be passed as an additional path segment after
1092             * this URI.
1093             */
1094            public static final Uri CONTENT_FILTER_EMAIL_URI = Uri.withAppendedPath(CONTENT_URI,
1095                    "filter");
1096
1097            public static final int TYPE_HOME = 1;
1098            public static final int TYPE_WORK = 2;
1099            public static final int TYPE_OTHER = 3;
1100            public static final int TYPE_MOBILE = 4;
1101
1102            /**
1103             * The display name for the email address
1104             * <P>Type: TEXT</P>
1105             */
1106            public static final String DISPLAY_NAME = "data4";
1107        }
1108
1109        /**
1110         * Common data definition for postal addresses.
1111         */
1112        public static final class StructuredPostal implements BaseCommonColumns, CommonColumns {
1113            private StructuredPostal() {
1114            }
1115
1116            /** MIME type used when storing this in data table. */
1117            public static final String CONTENT_ITEM_TYPE =
1118                    "vnd.android.cursor.item/postal-address_v2";
1119
1120            /**
1121             * The MIME type of {@link #CONTENT_URI} providing a directory of
1122             * postal addresses.
1123             */
1124            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
1125
1126            /**
1127             * The content:// style URI for all data records of the
1128             * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
1129             */
1130            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1131                    "postals");
1132
1133            public static final int TYPE_HOME = 1;
1134            public static final int TYPE_WORK = 2;
1135            public static final int TYPE_OTHER = 3;
1136
1137            /**
1138             * The full, unstructured postal address. <i>This field must be
1139             * consistent with any structured data.</i>
1140             * <p>
1141             * Type: TEXT
1142             */
1143            public static final String FORMATTED_ADDRESS = DATA;
1144
1145            /**
1146             * The agent who actually receives the mail. Used in work addresses.
1147             * Also for 'in care of' or 'c/o'.
1148             * <p>
1149             * Type: TEXT
1150             * @deprecated since this isn't supported by gd:structuredPostalAddress
1151             */
1152            @Deprecated
1153            public static final String AGENT = "data4";
1154
1155            /**
1156             * Used in places where houses or buildings have names (and not
1157             * necessarily numbers), eg. "The Pillars".
1158             * <p>
1159             * Type: TEXT
1160             * @deprecated since this isn't supported by gd:structuredPostalAddress
1161             */
1162            @Deprecated
1163            public static final String HOUSENAME = "data5";
1164
1165            /**
1166             * Can be street, avenue, road, etc. This element also includes the
1167             * house number and room/apartment/flat/floor number.
1168             * <p>
1169             * Type: TEXT
1170             */
1171            public static final String STREET = "data6";
1172
1173            /**
1174             * Covers actual P.O. boxes, drawers, locked bags, etc. This is
1175             * usually but not always mutually exclusive with street.
1176             * <p>
1177             * Type: TEXT
1178             */
1179            public static final String POBOX = "data7";
1180
1181            /**
1182             * This is used to disambiguate a street address when a city
1183             * contains more than one street with the same name, or to specify a
1184             * small place whose mail is routed through a larger postal town. In
1185             * China it could be a county or a minor city.
1186             * <p>
1187             * Type: TEXT
1188             */
1189            public static final String NEIGHBORHOOD = "data8";
1190
1191            /**
1192             * Can be city, village, town, borough, etc. This is the postal town
1193             * and not necessarily the place of residence or place of business.
1194             * <p>
1195             * Type: TEXT
1196             */
1197            public static final String CITY = "data9";
1198
1199            /**
1200             * Handles administrative districts such as U.S. or U.K. counties
1201             * that are not used for mail addressing purposes. Subregion is not
1202             * intended for delivery addresses.
1203             * <p>
1204             * Type: TEXT
1205             * @deprecated since this isn't supported by gd:structuredPostalAddress
1206             */
1207            @Deprecated
1208            public static final String SUBREGION = "data10";
1209
1210            /**
1211             * A state, province, county (in Ireland), Land (in Germany),
1212             * departement (in France), etc.
1213             * <p>
1214             * Type: TEXT
1215             */
1216            public static final String REGION = "data11";
1217
1218            /**
1219             * Postal code. Usually country-wide, but sometimes specific to the
1220             * city (e.g. "2" in "Dublin 2, Ireland" addresses).
1221             * <p>
1222             * Type: TEXT
1223             */
1224            public static final String POSTCODE = "data12";
1225
1226            /**
1227             * The name or code of the country.
1228             * <p>
1229             * Type: TEXT
1230             */
1231            public static final String COUNTRY = "data13";
1232        }
1233
1234        /**
1235         * Common data definition for IM addresses.
1236         */
1237        public static final class Im implements BaseCommonColumns, CommonColumns {
1238            private Im() {}
1239
1240            /** MIME type used when storing this in data table. */
1241            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
1242
1243            public static final int TYPE_HOME = 1;
1244            public static final int TYPE_WORK = 2;
1245            public static final int TYPE_OTHER = 3;
1246
1247            /**
1248             * This column should be populated with one of the defined
1249             * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
1250             * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
1251             * should contain the name of the custom protocol.
1252             */
1253            public static final String PROTOCOL = "data5";
1254
1255            public static final String CUSTOM_PROTOCOL = "data6";
1256
1257            /*
1258             * The predefined IM protocol types.
1259             */
1260            public static final int PROTOCOL_CUSTOM = -1;
1261            public static final int PROTOCOL_AIM = 0;
1262            public static final int PROTOCOL_MSN = 1;
1263            public static final int PROTOCOL_YAHOO = 2;
1264            public static final int PROTOCOL_SKYPE = 3;
1265            public static final int PROTOCOL_QQ = 4;
1266            public static final int PROTOCOL_GOOGLE_TALK = 5;
1267            public static final int PROTOCOL_ICQ = 6;
1268            public static final int PROTOCOL_JABBER = 7;
1269            public static final int PROTOCOL_NETMEETING = 8;
1270        }
1271
1272        /**
1273         * Common data definition for organizations.
1274         */
1275        public static final class Organization implements BaseCommonColumns, CommonColumns {
1276            private Organization() {}
1277
1278            /** MIME type used when storing this in data table. */
1279            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
1280
1281            public static final int TYPE_WORK = 1;
1282            public static final int TYPE_OTHER = 2;
1283
1284            /**
1285             * The company as the user entered it.
1286             * <P>Type: TEXT</P>
1287             */
1288            public static final String COMPANY = DATA;
1289
1290            /**
1291             * The position title at this company as the user entered it.
1292             * <P>Type: TEXT</P>
1293             */
1294            public static final String TITLE = "data4";
1295
1296            /**
1297             * The department at this company as the user entered it.
1298             * <P>Type: TEXT</P>
1299             */
1300            public static final String DEPARTMENT = "data5";
1301
1302            /**
1303             * The job description at this company as the user entered it.
1304             * <P>Type: TEXT</P>
1305             */
1306            public static final String JOB_DESCRIPTION = "data6";
1307
1308            /**
1309             * The symbol of this company as the user entered it.
1310             * <P>Type: TEXT</P>
1311             */
1312            public static final String SYMBOL = "data7";
1313
1314            /**
1315             * The phonetic name of this company as the user entered it.
1316             * <P>Type: TEXT</P>
1317             */
1318            public static final String PHONETIC_NAME = "data8";
1319        }
1320
1321        /**
1322         * Common data definition for miscellaneous information.
1323         */
1324        public static final class Miscellaneous implements BaseCommonColumns {
1325            private Miscellaneous() {}
1326
1327            /** MIME type used when storing this in data table. */
1328            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/misc";
1329
1330            /**
1331             * The birthday as the user entered it.
1332             * <P>Type: TEXT</P>
1333             */
1334            public static final String BIRTHDAY = "data1";
1335
1336            /**
1337             * The nickname as the user entered it.
1338             * <P>Type: TEXT</P>
1339             */
1340            public static final String NICKNAME = "data2";
1341        }
1342
1343        /**
1344         * Common data definition for relations.
1345         */
1346        public static final class Relation implements BaseCommonColumns, CommonColumns {
1347            private Relation() {}
1348
1349            /** MIME type used when storing this in data table. */
1350            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
1351
1352            public static final int TYPE_ASSISTANT = 1;
1353            public static final int TYPE_BROTHER = 2;
1354            public static final int TYPE_CHILD = 3;
1355            public static final int TYPE_DOMESTIC_PARTNER = 4;
1356            public static final int TYPE_FATHER = 5;
1357            public static final int TYPE_FRIEND = 6;
1358            public static final int TYPE_MANAGER = 7;
1359            public static final int TYPE_MOTHER = 8;
1360            public static final int TYPE_PARENT = 9;
1361            public static final int TYPE_PARTNER = 10;
1362            public static final int TYPE_REFERRED_BY = 11;
1363            public static final int TYPE_RELATIVE = 12;
1364            public static final int TYPE_SISTER = 13;
1365            public static final int TYPE_SPOUSE = 14;
1366
1367            /**
1368             * The name of the relative as the user entered it.
1369             * <P>Type: TEXT</P>
1370             */
1371            public static final String NAME = DATA;
1372        }
1373
1374        /**
1375         * Common data definition for events.
1376         */
1377        public static final class Event implements BaseCommonColumns, CommonColumns {
1378            private Event() {}
1379
1380            /** MIME type used when storing this in data table. */
1381            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event";
1382
1383            public static final int TYPE_ANNIVERSARY = 1;
1384            public static final int TYPE_OTHER = 2;
1385
1386            /**
1387             * The event start date as the user entered it.
1388             * <P>Type: TEXT</P>
1389             */
1390            public static final String START_DATE = DATA;
1391        }
1392
1393        /**
1394         * Photo of the contact.
1395         */
1396        public static final class Photo implements BaseCommonColumns {
1397            private Photo() {}
1398
1399            /** MIME type used when storing this in data table. */
1400            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
1401
1402            /**
1403             * Thumbnail photo of the raw contact. This is the raw bytes of an image
1404             * that could be inflated using {@link BitmapFactory}.
1405             * <p>
1406             * Type: BLOB
1407             */
1408            public static final String PHOTO = "data1";
1409        }
1410
1411        /**
1412         * Notes about the contact.
1413         */
1414        public static final class Note implements BaseCommonColumns {
1415            private Note() {}
1416
1417            /** MIME type used when storing this in data table. */
1418            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
1419
1420            /**
1421             * The note text.
1422             * <P>Type: TEXT</P>
1423             */
1424            public static final String NOTE = "data1";
1425        }
1426
1427        /**
1428         * Group Membership.
1429         */
1430        public static final class GroupMembership implements BaseCommonColumns {
1431            private GroupMembership() {}
1432
1433            /** MIME type used when storing this in data table. */
1434            public static final String CONTENT_ITEM_TYPE =
1435                    "vnd.android.cursor.item/group_membership";
1436
1437            /**
1438             * The row id of the group that this group membership refers to. Exactly one of
1439             * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
1440             * <P>Type: INTEGER</P>
1441             */
1442            public static final String GROUP_ROW_ID = "data1";
1443
1444            /**
1445             * The sourceid of the group that this group membership refers to.  Exactly one of
1446             * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
1447             * <P>Type: TEXT</P>
1448             */
1449            public static final String GROUP_SOURCE_ID = "group_sourceid";
1450        }
1451
1452        /**
1453         * Website related to the contact.
1454         */
1455        public static final class Website implements BaseCommonColumns, CommonColumns {
1456            private Website() {}
1457
1458            /** MIME type used when storing this in data table. */
1459            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
1460
1461            public static final int TYPE_HOMEPAGE = 1;
1462            public static final int TYPE_BLOG = 2;
1463            public static final int TYPE_PROFILE = 3;
1464            public static final int TYPE_HOME = 4;
1465            public static final int TYPE_WORK = 5;
1466            public static final int TYPE_FTP = 6;
1467            public static final int TYPE_OTHER = 7;
1468
1469            /**
1470             * The website URL string.
1471             * <P>Type: TEXT</P>
1472             */
1473            public static final String URL = "data1";
1474        }
1475    }
1476
1477    // TODO: make this private before unhiding
1478    public interface GroupsColumns {
1479        /**
1480         * The display title of this group.
1481         * <p>
1482         * Type: TEXT
1483         */
1484        public static final String TITLE = "title";
1485
1486        /**
1487         * The package name to use when creating {@link Resources} objects for
1488         * this group. This value is only designed for use when building user
1489         * interfaces, and should not be used to infer the owner.
1490         */
1491        public static final String RES_PACKAGE = "res_package";
1492
1493        /**
1494         * The display title of this group to load as a resource from
1495         * {@link #RES_PACKAGE}, which may be localized.
1496         * <P>Type: TEXT</P>
1497         */
1498        public static final String TITLE_RES = "title_res";
1499
1500        /**
1501         * Notes about the group.
1502         * <p>
1503         * Type: TEXT
1504         */
1505        public static final String NOTES = "notes";
1506
1507        /**
1508         * The ID of this group if it is a System Group, i.e. a group that has a special meaning
1509         * to the sync adapter, null otherwise.
1510         * <P>Type: TEXT</P>
1511         */
1512        public static final String SYSTEM_ID = "system_id";
1513
1514        /**
1515         * The total number of {@link Contacts} that have
1516         * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
1517         * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
1518         * <p>
1519         * Type: INTEGER
1520         */
1521        public static final String SUMMARY_COUNT = "summ_count";
1522
1523        /**
1524         * The total number of {@link Contacts} that have both
1525         * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
1526         * Read-only value that is only present when querying
1527         * {@link Groups#CONTENT_SUMMARY_URI}.
1528         * <p>
1529         * Type: INTEGER
1530         */
1531        public static final String SUMMARY_WITH_PHONES = "summ_phones";
1532
1533        /**
1534         * Flag indicating if the contacts belonging to this group should be
1535         * visible in any user interface.
1536         * <p>
1537         * Type: INTEGER (boolean)
1538         */
1539        public static final String GROUP_VISIBLE = "group_visible";
1540
1541        /**
1542         * The "deleted" flag: "0" by default, "1" if the row has been marked
1543         * for deletion. When {@link android.content.ContentResolver#delete} is
1544         * called on a raw contact, it is marked for deletion and removed from its
1545         * aggregate contact. The sync adaptor deletes the raw contact on the server and
1546         * then calls ContactResolver.delete once more, this time passing the
1547         * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal.
1548         * <P>Type: INTEGER</P>
1549         */
1550        public static final String DELETED = "deleted";
1551
1552        /**
1553         * Whether this group should be synced if the SYNC_EVERYTHING settings
1554         * is false for this group's account.
1555         * <p>
1556         * Type: INTEGER (boolean)
1557         */
1558        public static final String SHOULD_SYNC = "should_sync";
1559    }
1560
1561    /**
1562     * Constants for the groups table.
1563     */
1564    public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
1565        /**
1566         * This utility class cannot be instantiated
1567         */
1568        private Groups() {
1569        }
1570
1571        /**
1572         * The content:// style URI for this table
1573         */
1574        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
1575
1576        /**
1577         * The content:// style URI for this table joined with details data from
1578         * {@link Data}.
1579         */
1580        public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
1581                "groups_summary");
1582
1583        /**
1584         * The MIME type of a directory of groups.
1585         */
1586        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
1587
1588        /**
1589         * The MIME type of a single group.
1590         */
1591        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
1592
1593        /**
1594         * Query parameter that can be passed with the {@link #CONTENT_URI} URI
1595         * to the {@link android.content.ContentResolver#delete} method to
1596         * indicate that the raw contact can be deleted physically, rather than
1597         * merely marked as deleted.
1598         */
1599        public static final String DELETE_PERMANENTLY = "delete_permanently";
1600
1601        /**
1602         * An optional update or insert URI parameter that determines if the
1603         * group should be marked as dirty. The default value is true.
1604         */
1605        public static final String MARK_AS_DIRTY = "mark_as_dirty";
1606    }
1607
1608    /**
1609     * Constants for the contact aggregation exceptions table, which contains
1610     * aggregation rules overriding those used by automatic aggregation.  This type only
1611     * supports query and update. Neither insert nor delete are supported.
1612     */
1613    public static final class AggregationExceptions implements BaseColumns {
1614        /**
1615         * This utility class cannot be instantiated
1616         */
1617        private AggregationExceptions() {}
1618
1619        /**
1620         * The content:// style URI for this table
1621         */
1622        public static final Uri CONTENT_URI =
1623                Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
1624
1625        /**
1626         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
1627         */
1628        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
1629
1630        /**
1631         * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
1632         */
1633        public static final String CONTENT_ITEM_TYPE =
1634                "vnd.android.cursor.item/aggregation_exception";
1635
1636        /**
1637         * The type of exception: {@link #TYPE_KEEP_IN}, {@link #TYPE_KEEP_OUT} or
1638         * {@link #TYPE_AUTOMATIC}.
1639         *
1640         * <P>Type: INTEGER</P>
1641         */
1642        public static final String TYPE = "type";
1643
1644        /**
1645         * Allows the provider to automatically decide whether the aggregate
1646         * contact should include a particular raw contact or not.
1647         */
1648        public static final int TYPE_AUTOMATIC = 0;
1649
1650        /**
1651         * Makes sure that the specified raw contact is included in the
1652         * specified aggregate contact.
1653         */
1654        public static final int TYPE_KEEP_IN = 1;
1655
1656        /**
1657         * Makes sure that the specified raw contact is NOT included in the
1658         * specified aggregate contact.
1659         */
1660        public static final int TYPE_KEEP_OUT = 2;
1661
1662        /**
1663         * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the
1664         * aggregate contact that the rule applies to.
1665         */
1666        public static final String CONTACT_ID = "contact_id";
1667
1668        /**
1669         * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
1670         */
1671        public static final String RAW_CONTACT_ID = "raw_contact_id";
1672    }
1673
1674    private interface SettingsColumns {
1675        /**
1676         * The name of the account instance to which this row belongs.
1677         * <P>Type: TEXT</P>
1678         */
1679        public static final String ACCOUNT_NAME = "account_name";
1680
1681        /**
1682         * The type of account to which this row belongs, which when paired with
1683         * {@link #ACCOUNT_NAME} identifies a specific account.
1684         * <P>Type: TEXT</P>
1685         */
1686        public static final String ACCOUNT_TYPE = "account_type";
1687
1688        /**
1689         * Depending on the mode defined by the sync-adapter, this flag controls
1690         * the top-level sync behavior for this data source.
1691         * <p>
1692         * Type: INTEGER (boolean)
1693         */
1694        public static final String SHOULD_SYNC = "should_sync";
1695
1696        /**
1697         * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
1698         * entries should be visible in any user interface.
1699         * <p>
1700         * Type: INTEGER (boolean)
1701         */
1702        public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
1703
1704        /**
1705         * Read-only count of {@link Contacts} from a specific source that have
1706         * no {@link CommonDataKinds.GroupMembership} entries.
1707         * <p>
1708         * Type: INTEGER
1709         */
1710        public static final String UNGROUPED_COUNT = "summ_count";
1711
1712        /**
1713         * Read-only count of {@link Contacts} from a specific source that have
1714         * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
1715         * <p>
1716         * Type: INTEGER
1717         */
1718        public static final String UNGROUPED_WITH_PHONES = "summ_phones";
1719    }
1720
1721    /**
1722     * Contacts-specific settings for various {@link Account}.
1723     */
1724    public static final class Settings implements SettingsColumns {
1725        /**
1726         * This utility class cannot be instantiated
1727         */
1728        private Settings() {
1729        }
1730
1731        /**
1732         * The content:// style URI for this table
1733         */
1734        public static final Uri CONTENT_URI =
1735                Uri.withAppendedPath(AUTHORITY_URI, "settings");
1736
1737        /**
1738         * The MIME-type of {@link #CONTENT_URI} providing a directory of
1739         * settings.
1740         */
1741        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
1742
1743        /**
1744         * The MIME-type of {@link #CONTENT_URI} providing a single setting.
1745         */
1746        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
1747    }
1748
1749    /**
1750     * Contains helper classes used to create or manage {@link android.content.Intent Intents}
1751     * that involve contacts.
1752     */
1753    public static final class Intents {
1754        /**
1755         * This is the intent that is fired when a search suggestion is clicked on.
1756         */
1757        public static final String SEARCH_SUGGESTION_CLICKED =
1758                "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
1759
1760        /**
1761         * This is the intent that is fired when a search suggestion for dialing a number
1762         * is clicked on.
1763         */
1764        public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
1765                "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
1766
1767        /**
1768         * This is the intent that is fired when a search suggestion for creating a contact
1769         * is clicked on.
1770         */
1771        public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
1772                "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
1773
1774        /**
1775         * Starts an Activity that lets the user pick a contact to attach an image to.
1776         * After picking the contact it launches the image cropper in face detection mode.
1777         */
1778        public static final String ATTACH_IMAGE =
1779                "com.android.contacts.action.ATTACH_IMAGE";
1780
1781        /**
1782         * Takes as input a data URI with a mailto: or tel: scheme. If a single
1783         * contact exists with the given data it will be shown. If no contact
1784         * exists, a dialog will ask the user if they want to create a new
1785         * contact with the provided details filled in. If multiple contacts
1786         * share the data the user will be prompted to pick which contact they
1787         * want to view.
1788         * <p>
1789         * For <code>mailto:</code> URIs, the scheme specific portion must be a
1790         * raw email address, such as one built using
1791         * {@link Uri#fromParts(String, String, String)}.
1792         * <p>
1793         * For <code>tel:</code> URIs, the scheme specific portion is compared
1794         * to existing numbers using the standard caller ID lookup algorithm.
1795         * The number must be properly encoded, for example using
1796         * {@link Uri#fromParts(String, String, String)}.
1797         * <p>
1798         * Any extras from the {@link Insert} class will be passed along to the
1799         * create activity if there are no contacts to show.
1800         * <p>
1801         * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
1802         * prompting the user when the contact doesn't exist.
1803         */
1804        public static final String SHOW_OR_CREATE_CONTACT =
1805                "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
1806
1807        /**
1808         * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
1809         * contact if no matching contact found. Otherwise, default behavior is
1810         * to prompt user with dialog before creating.
1811         * <p>
1812         * Type: BOOLEAN
1813         */
1814        public static final String EXTRA_FORCE_CREATE =
1815                "com.android.contacts.action.FORCE_CREATE";
1816
1817        /**
1818         * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
1819         * description to be shown when prompting user about creating a new
1820         * contact.
1821         * <p>
1822         * Type: STRING
1823         */
1824        public static final String EXTRA_CREATE_DESCRIPTION =
1825            "com.android.contacts.action.CREATE_DESCRIPTION";
1826
1827        /**
1828         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
1829         * dialog location using screen coordinates. When not specified, the
1830         * dialog will be centered.
1831         */
1832        public static final String EXTRA_TARGET_RECT = "target_rect";
1833
1834        /**
1835         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
1836         * desired dialog style, usually a variation on size. One of
1837         * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
1838         */
1839        public static final String EXTRA_MODE = "mode";
1840
1841        /**
1842         * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
1843         */
1844        public static final int MODE_SMALL = 1;
1845
1846        /**
1847         * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
1848         */
1849        public static final int MODE_MEDIUM = 2;
1850
1851        /**
1852         * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
1853         */
1854        public static final int MODE_LARGE = 3;
1855
1856        /**
1857         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
1858         * a list of specific MIME-types to exclude and not display. Stored as a
1859         * {@link String} array.
1860         */
1861        public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
1862
1863        /**
1864         * Intents related to the Contacts app UI.
1865         */
1866        public static final class UI {
1867            /**
1868             * The action for the default contacts list tab.
1869             */
1870            public static final String LIST_DEFAULT =
1871                    "com.android.contacts.action.LIST_DEFAULT";
1872
1873            /**
1874             * The action for the contacts list tab.
1875             */
1876            public static final String LIST_GROUP_ACTION =
1877                    "com.android.contacts.action.LIST_GROUP";
1878
1879            /**
1880             * When in LIST_GROUP_ACTION mode, this is the group to display.
1881             */
1882            public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
1883
1884            /**
1885             * The action for the all contacts list tab.
1886             */
1887            public static final String LIST_ALL_CONTACTS_ACTION =
1888                    "com.android.contacts.action.LIST_ALL_CONTACTS";
1889
1890            /**
1891             * The action for the contacts with phone numbers list tab.
1892             */
1893            public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
1894                    "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
1895
1896            /**
1897             * The action for the starred contacts list tab.
1898             */
1899            public static final String LIST_STARRED_ACTION =
1900                    "com.android.contacts.action.LIST_STARRED";
1901
1902            /**
1903             * The action for the frequent contacts list tab.
1904             */
1905            public static final String LIST_FREQUENT_ACTION =
1906                    "com.android.contacts.action.LIST_FREQUENT";
1907
1908            /**
1909             * The action for the "strequent" contacts list tab. It first lists the starred
1910             * contacts in alphabetical order and then the frequent contacts in descending
1911             * order of the number of times they have been contacted.
1912             */
1913            public static final String LIST_STREQUENT_ACTION =
1914                    "com.android.contacts.action.LIST_STREQUENT";
1915
1916            /**
1917             * A key for to be used as an intent extra to set the activity
1918             * title to a custom String value.
1919             */
1920            public static final String TITLE_EXTRA_KEY =
1921                "com.android.contacts.extra.TITLE_EXTRA";
1922
1923            /**
1924             * Activity Action: Display a filtered list of contacts
1925             * <p>
1926             * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
1927             * filtering
1928             * <p>
1929             * Output: Nothing.
1930             */
1931            public static final String FILTER_CONTACTS_ACTION =
1932                "com.android.contacts.action.FILTER_CONTACTS";
1933
1934            /**
1935             * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
1936             * intents to supply the text on which to filter.
1937             */
1938            public static final String FILTER_TEXT_EXTRA_KEY =
1939                "com.android.contacts.extra.FILTER_TEXT";
1940        }
1941
1942        /**
1943         * Convenience class that contains string constants used
1944         * to create contact {@link android.content.Intent Intents}.
1945         */
1946        public static final class Insert {
1947            /** The action code to use when adding a contact */
1948            public static final String ACTION = Intent.ACTION_INSERT;
1949
1950            /**
1951             * If present, forces a bypass of quick insert mode.
1952             */
1953            public static final String FULL_MODE = "full_mode";
1954
1955            /**
1956             * The extra field for the contact name.
1957             * <P>Type: String</P>
1958             */
1959            public static final String NAME = "name";
1960
1961            // TODO add structured name values here.
1962
1963            /**
1964             * The extra field for the contact phonetic name.
1965             * <P>Type: String</P>
1966             */
1967            public static final String PHONETIC_NAME = "phonetic_name";
1968
1969            /**
1970             * The extra field for the contact company.
1971             * <P>Type: String</P>
1972             */
1973            public static final String COMPANY = "company";
1974
1975            /**
1976             * The extra field for the contact job title.
1977             * <P>Type: String</P>
1978             */
1979            public static final String JOB_TITLE = "job_title";
1980
1981            /**
1982             * The extra field for the contact notes.
1983             * <P>Type: String</P>
1984             */
1985            public static final String NOTES = "notes";
1986
1987            /**
1988             * The extra field for the contact phone number.
1989             * <P>Type: String</P>
1990             */
1991            public static final String PHONE = "phone";
1992
1993            /**
1994             * The extra field for the contact phone number type.
1995             * <P>Type: Either an integer value from
1996             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
1997             *  or a string specifying a custom label.</P>
1998             */
1999            public static final String PHONE_TYPE = "phone_type";
2000
2001            /**
2002             * The extra field for the phone isprimary flag.
2003             * <P>Type: boolean</P>
2004             */
2005            public static final String PHONE_ISPRIMARY = "phone_isprimary";
2006
2007            /**
2008             * The extra field for an optional second contact phone number.
2009             * <P>Type: String</P>
2010             */
2011            public static final String SECONDARY_PHONE = "secondary_phone";
2012
2013            /**
2014             * The extra field for an optional second contact phone number type.
2015             * <P>Type: Either an integer value from
2016             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2017             *  or a string specifying a custom label.</P>
2018             */
2019            public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
2020
2021            /**
2022             * The extra field for an optional third contact phone number.
2023             * <P>Type: String</P>
2024             */
2025            public static final String TERTIARY_PHONE = "tertiary_phone";
2026
2027            /**
2028             * The extra field for an optional third contact phone number type.
2029             * <P>Type: Either an integer value from
2030             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2031             *  or a string specifying a custom label.</P>
2032             */
2033            public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
2034
2035            /**
2036             * The extra field for the contact email address.
2037             * <P>Type: String</P>
2038             */
2039            public static final String EMAIL = "email";
2040
2041            /**
2042             * The extra field for the contact email type.
2043             * <P>Type: Either an integer value from
2044             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2045             *  or a string specifying a custom label.</P>
2046             */
2047            public static final String EMAIL_TYPE = "email_type";
2048
2049            /**
2050             * The extra field for the email isprimary flag.
2051             * <P>Type: boolean</P>
2052             */
2053            public static final String EMAIL_ISPRIMARY = "email_isprimary";
2054
2055            /**
2056             * The extra field for an optional second contact email address.
2057             * <P>Type: String</P>
2058             */
2059            public static final String SECONDARY_EMAIL = "secondary_email";
2060
2061            /**
2062             * The extra field for an optional second contact email type.
2063             * <P>Type: Either an integer value from
2064             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2065             *  or a string specifying a custom label.</P>
2066             */
2067            public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
2068
2069            /**
2070             * The extra field for an optional third contact email address.
2071             * <P>Type: String</P>
2072             */
2073            public static final String TERTIARY_EMAIL = "tertiary_email";
2074
2075            /**
2076             * The extra field for an optional third contact email type.
2077             * <P>Type: Either an integer value from
2078             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2079             *  or a string specifying a custom label.</P>
2080             */
2081            public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
2082
2083            /**
2084             * The extra field for the contact postal address.
2085             * <P>Type: String</P>
2086             */
2087            public static final String POSTAL = "postal";
2088
2089            /**
2090             * The extra field for the contact postal address type.
2091             * <P>Type: Either an integer value from
2092             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2093             *  or a string specifying a custom label.</P>
2094             */
2095            public static final String POSTAL_TYPE = "postal_type";
2096
2097            /**
2098             * The extra field for the postal isprimary flag.
2099             * <P>Type: boolean</P>
2100             */
2101            public static final String POSTAL_ISPRIMARY = "postal_isprimary";
2102
2103            /**
2104             * The extra field for an IM handle.
2105             * <P>Type: String</P>
2106             */
2107            public static final String IM_HANDLE = "im_handle";
2108
2109            /**
2110             * The extra field for the IM protocol
2111             * <P>Type: the result of {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)}
2112             * or {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.</P>
2113             */
2114            public static final String IM_PROTOCOL = "im_protocol";
2115
2116            /**
2117             * The extra field for the IM isprimary flag.
2118             * <P>Type: boolean</P>
2119             */
2120            public static final String IM_ISPRIMARY = "im_isprimary";
2121        }
2122    }
2123
2124}
2125