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