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