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.app.Activity;
     21 import android.app.admin.DevicePolicyManager;
     22 import android.content.ActivityNotFoundException;
     23 import android.content.ContentProviderClient;
     24 import android.content.ContentProviderOperation;
     25 import android.content.ContentResolver;
     26 import android.content.ContentUris;
     27 import android.content.ContentValues;
     28 import android.content.Context;
     29 import android.content.ContextWrapper;
     30 import android.content.CursorEntityIterator;
     31 import android.content.Entity;
     32 import android.content.EntityIterator;
     33 import android.content.Intent;
     34 import android.content.res.AssetFileDescriptor;
     35 import android.content.res.Resources;
     36 import android.database.Cursor;
     37 import android.database.DatabaseUtils;
     38 import android.graphics.Rect;
     39 import android.net.Uri;
     40 import android.os.RemoteException;
     41 import android.text.TextUtils;
     42 import android.util.DisplayMetrics;
     43 import android.util.Pair;
     44 import android.view.View;
     45 import android.widget.Toast;
     46 
     47 import java.io.ByteArrayInputStream;
     48 import java.io.IOException;
     49 import java.io.InputStream;
     50 import java.util.ArrayList;
     51 
     52 /**
     53  * <p>
     54  * The contract between the contacts provider and applications. Contains
     55  * definitions for the supported URIs and columns. These APIs supersede
     56  * {@link Contacts}.
     57  * </p>
     58  * <h3>Overview</h3>
     59  * <p>
     60  * ContactsContract defines an extensible database of contact-related
     61  * information. Contact information is stored in a three-tier data model:
     62  * </p>
     63  * <ul>
     64  * <li>
     65  * A row in the {@link Data} table can store any kind of personal data, such
     66  * as a phone number or email addresses.  The set of data kinds that can be
     67  * stored in this table is open-ended. There is a predefined set of common
     68  * kinds, but any application can add its own data kinds.
     69  * </li>
     70  * <li>
     71  * A row in the {@link RawContacts} table represents a set of data describing a
     72  * person and associated with a single account (for example, one of the user's
     73  * Gmail accounts).
     74  * </li>
     75  * <li>
     76  * A row in the {@link Contacts} table represents an aggregate of one or more
     77  * RawContacts presumably describing the same person.  When data in or associated with
     78  * the RawContacts table is changed, the affected aggregate contacts are updated as
     79  * necessary.
     80  * </li>
     81  * </ul>
     82  * <p>
     83  * Other tables include:
     84  * </p>
     85  * <ul>
     86  * <li>
     87  * {@link Groups}, which contains information about raw contact groups
     88  * such as Gmail contact groups.  The
     89  * current API does not support the notion of groups spanning multiple accounts.
     90  * </li>
     91  * <li>
     92  * {@link StatusUpdates}, which contains social status updates including IM
     93  * availability.
     94  * </li>
     95  * <li>
     96  * {@link AggregationExceptions}, which is used for manual aggregation and
     97  * disaggregation of raw contacts
     98  * </li>
     99  * <li>
    100  * {@link Settings}, which contains visibility and sync settings for accounts
    101  * and groups.
    102  * </li>
    103  * <li>
    104  * {@link SyncState}, which contains free-form data maintained on behalf of sync
    105  * adapters
    106  * </li>
    107  * <li>
    108  * {@link PhoneLookup}, which is used for quick caller-ID lookup</li>
    109  * </ul>
    110  */
    111 @SuppressWarnings("unused")
    112 public final class ContactsContract {
    113     /** The authority for the contacts provider */
    114     public static final String AUTHORITY = "com.android.contacts";
    115     /** A content:// style uri to the authority for the contacts provider */
    116     public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
    117 
    118     /**
    119      * An optional URI parameter for insert, update, or delete queries
    120      * that allows the caller
    121      * to specify that it is a sync adapter. The default value is false. If true
    122      * {@link RawContacts#DIRTY} is not automatically set and the
    123      * "syncToNetwork" parameter is set to false when calling
    124      * {@link
    125      * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
    126      * This prevents an unnecessary extra synchronization, see the discussion of
    127      * the delete operation in {@link RawContacts}.
    128      */
    129     public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
    130 
    131     /**
    132      * Query parameter that should be used by the client to access a specific
    133      * {@link Directory}. The parameter value should be the _ID of the corresponding
    134      * directory, e.g.
    135      * {@code content://com.android.contacts/data/emails/filter/acme?directory=3}
    136      */
    137     public static final String DIRECTORY_PARAM_KEY = "directory";
    138 
    139     /**
    140      * A query parameter that limits the number of results returned. The
    141      * parameter value should be an integer.
    142      */
    143     public static final String LIMIT_PARAM_KEY = "limit";
    144 
    145     /**
    146      * A query parameter specifing a primary account. This parameter should be used with
    147      * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on
    148      * this information to optimize its query results.
    149      *
    150      * For example, in an email composition screen, its implementation can specify an account when
    151      * obtaining possible recipients, letting the provider know which account is selected during
    152      * the composition. The provider may use the "primary account" information to optimize
    153      * the search result.
    154      */
    155     public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account";
    156 
    157     /**
    158      * A query parameter specifing a primary account. This parameter should be used with
    159      * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}.
    160      */
    161     public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account";
    162 
    163     /**
    164      * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and
    165      * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to
    166      * return only phone-related results. For example, frequently contacted person list should
    167      * include persons contacted via phone (not email, sms, etc.)
    168      */
    169     public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only";
    170 
    171     /**
    172      * A key to a boolean in the "extras" bundle of the cursor.
    173      * The boolean indicates that the provider did not create a snippet and that the client asking
    174      * for the snippet should do it (true means the snippeting was deferred to the client).
    175      *
    176      * @see SearchSnippets
    177      */
    178     public static final String DEFERRED_SNIPPETING = "deferred_snippeting";
    179 
    180     /**
    181      * Key to retrieve the original deferred snippeting from the cursor on the client side.
    182      *
    183      * @see SearchSnippets
    184      * @see #DEFERRED_SNIPPETING
    185      */
    186     public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query";
    187 
    188     /**
    189      * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI},
    190      * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and
    191      * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}.
    192      * This enables a content provider to remove duplicate entries in results.
    193      */
    194     public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries";
    195 
    196     /**
    197      * <p>
    198      * API for obtaining a pre-authorized version of a URI that normally requires special
    199      * permission (beyond READ_CONTACTS) to read.  The caller obtaining the pre-authorized URI
    200      * must already have the necessary permissions to access the URI; otherwise a
    201      * {@link SecurityException} will be thrown. Unlike {@link Context#grantUriPermission},
    202      * this can be used to grant permissions that aren't explicitly required for the URI inside
    203      * AndroidManifest.xml. For example, permissions that are only required when reading URIs
    204      * that refer to the user's profile.
    205      * </p>
    206      * <p>
    207      * The authorized URI returned in the bundle contains an expiring token that allows the
    208      * caller to execute the query without having the special permissions that would normally
    209      * be required. The token expires in five minutes.
    210      * </p>
    211      * <p>
    212      * This API does not access disk, and should be safe to invoke from the UI thread.
    213      * </p>
    214      * <p>
    215      * Example usage:
    216      * <pre>
    217      * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI;
    218      * Bundle uriBundle = new Bundle();
    219      * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri);
    220      * Bundle authResponse = getContext().getContentResolver().call(
    221      *         ContactsContract.AUTHORITY_URI,
    222      *         ContactsContract.Authorization.AUTHORIZATION_METHOD,
    223      *         null, // String arg, not used.
    224      *         uriBundle);
    225      * if (authResponse != null) {
    226      *     Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable(
    227      *             ContactsContract.Authorization.KEY_AUTHORIZED_URI);
    228      *     // This pre-authorized URI can be queried by a caller without READ_PROFILE
    229      *     // permission.
    230      * }
    231      * </pre>
    232      * </p>
    233      *
    234      * @hide
    235      */
    236     public static final class Authorization {
    237         /**
    238          * The method to invoke to create a pre-authorized URI out of the input argument.
    239          */
    240         public static final String AUTHORIZATION_METHOD = "authorize";
    241 
    242         /**
    243          * The key to set in the outbound Bundle with the URI that should be authorized.
    244          */
    245         public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize";
    246 
    247         /**
    248          * The key to retrieve from the returned Bundle to obtain the pre-authorized URI.
    249          */
    250         public static final String KEY_AUTHORIZED_URI = "authorized_uri";
    251     }
    252 
    253     /**
    254      * A Directory represents a contacts corpus, e.g. Local contacts,
    255      * Google Apps Global Address List or Corporate Global Address List.
    256      * <p>
    257      * A Directory is implemented as a content provider with its unique authority and
    258      * the same API as the main Contacts Provider.  However, there is no expectation that
    259      * every directory provider will implement this Contract in its entirety.  If a
    260      * directory provider does not have an implementation for a specific request, it
    261      * should throw an UnsupportedOperationException.
    262      * </p>
    263      * <p>
    264      * The most important use case for Directories is search.  A Directory provider is
    265      * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI
    266      * Contacts.CONTENT_FILTER_URI}.  If a Directory provider wants to participate
    267      * in email and phone lookup functionalities, it should also implement
    268      * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI}
    269      * and
    270      * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}.
    271      * </p>
    272      * <p>
    273      * A directory provider should return NULL for every projection field it does not
    274      * recognize, rather than throwing an exception.  This way it will not be broken
    275      * if ContactsContract is extended with new fields in the future.
    276      * </p>
    277      * <p>
    278      * The client interacts with a directory via Contacts Provider by supplying an
    279      * optional {@code directory=} query parameter.
    280      * <p>
    281      * <p>
    282      * When the Contacts Provider receives the request, it transforms the URI and forwards
    283      * the request to the corresponding directory content provider.
    284      * The URI is transformed in the following fashion:
    285      * <ul>
    286      * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li>
    287      * <li>The {@code accountName=} and {@code accountType=} parameters are added or
    288      * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li>
    289      * </ul>
    290      * </p>
    291      * <p>
    292      * Clients should send directory requests to Contacts Provider and let it
    293      * forward them to the respective providers rather than constructing
    294      * directory provider URIs by themselves. This level of indirection allows
    295      * Contacts Provider to implement additional system-level features and
    296      * optimizations. Access to Contacts Provider is protected by the
    297      * READ_CONTACTS permission, but access to the directory provider is protected by
    298      * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous
    299      * platform versions the provider should perform the following check to make sure the call
    300      * is coming from the ContactsProvider:
    301      * <pre>
    302      * private boolean isCallerAllowed() {
    303      *   PackageManager pm = getContext().getPackageManager();
    304      *   for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) {
    305      *     if (packageName.equals("com.android.providers.contacts")) {
    306      *       return true;
    307      *     }
    308      *   }
    309      *   return false;
    310      * }
    311      * </pre>
    312      * </p>
    313      * <p>
    314      * The Directory table is read-only and is maintained by the Contacts Provider
    315      * automatically.
    316      * </p>
    317      * <p>It always has at least these two rows:
    318      * <ul>
    319      * <li>
    320      * The local directory. It has {@link Directory#_ID Directory._ID} =
    321      * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally
    322      * stored contacts. The same can be achieved by omitting the {@code directory=}
    323      * parameter altogether.
    324      * </li>
    325      * <li>
    326      * The local invisible contacts. The corresponding directory ID is
    327      * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}.
    328      * </li>
    329      * </ul>
    330      * </p>
    331      * <p>Custom Directories are discovered by the Contacts Provider following this procedure:
    332      * <ul>
    333      * <li>It finds all installed content providers with meta data identifying them
    334      * as directory providers in AndroidManifest.xml:
    335      * <code>
    336      * &lt;meta-data android:name="android.content.ContactDirectory"
    337      *               android:value="true" /&gt;
    338      * </code>
    339      * <p>
    340      * This tag should be placed inside the corresponding content provider declaration.
    341      * </p>
    342      * </li>
    343      * <li>
    344      * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI}
    345      * query to each of the directory authorities.  A directory provider must implement
    346      * this query and return a list of directories.  Each directory returned by
    347      * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and
    348      * {@link #ACCOUNT_TYPE} columns (nulls are allowed).  Since directory IDs are assigned
    349      * automatically, the _ID field will not be part of the query projection.
    350      * </li>
    351      * <li>Contacts Provider compiles directory lists received from all directory
    352      * providers into one, assigns each individual directory a globally unique ID and
    353      * stores all directory records in the Directory table.
    354      * </li>
    355      * </ul>
    356      * </p>
    357      * <p>Contacts Provider automatically interrogates newly installed or replaced packages.
    358      * Thus simply installing a package containing a directory provider is sufficient
    359      * to have that provider registered.  A package supplying a directory provider does
    360      * not have to contain launchable activities.
    361      * </p>
    362      * <p>
    363      * Every row in the Directory table is automatically associated with the corresponding package
    364      * (apk).  If the package is later uninstalled, all corresponding directory rows
    365      * are automatically removed from the Contacts Provider.
    366      * </p>
    367      * <p>
    368      * When the list of directories handled by a directory provider changes
    369      * (for instance when the user adds a new Directory account), the directory provider
    370      * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change.
    371      * In response, the Contacts Provider will requery the directory provider to obtain the
    372      * new list of directories.
    373      * </p>
    374      * <p>
    375      * A directory row can be optionally associated with an existing account
    376      * (see {@link android.accounts.AccountManager}). If the account is later removed,
    377      * the corresponding directory rows are automatically removed from the Contacts Provider.
    378      * </p>
    379      */
    380     public static final class Directory implements BaseColumns {
    381 
    382         /**
    383          * Not instantiable.
    384          */
    385         private Directory() {
    386         }
    387 
    388         /**
    389          * The content:// style URI for this table.  Requests to this URI can be
    390          * performed on the UI thread because they are always unblocking.
    391          */
    392         public static final Uri CONTENT_URI =
    393                 Uri.withAppendedPath(AUTHORITY_URI, "directories");
    394 
    395         /**
    396          * The MIME-type of {@link #CONTENT_URI} providing a directory of
    397          * contact directories.
    398          */
    399         public static final String CONTENT_TYPE =
    400                 "vnd.android.cursor.dir/contact_directories";
    401 
    402         /**
    403          * The MIME type of a {@link #CONTENT_URI} item.
    404          */
    405         public static final String CONTENT_ITEM_TYPE =
    406                 "vnd.android.cursor.item/contact_directory";
    407 
    408         /**
    409          * _ID of the default directory, which represents locally stored contacts.
    410          */
    411         public static final long DEFAULT = 0;
    412 
    413         /**
    414          * _ID of the directory that represents locally stored invisible contacts.
    415          */
    416         public static final long LOCAL_INVISIBLE = 1;
    417 
    418         /**
    419          * The name of the package that owns this directory. Contacts Provider
    420          * fill it in with the name of the package containing the directory provider.
    421          * If the package is later uninstalled, the directories it owns are
    422          * automatically removed from this table.
    423          *
    424          * <p>TYPE: TEXT</p>
    425          */
    426         public static final String PACKAGE_NAME = "packageName";
    427 
    428         /**
    429          * The type of directory captured as a resource ID in the context of the
    430          * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory"
    431          *
    432          * <p>TYPE: INTEGER</p>
    433          */
    434         public static final String TYPE_RESOURCE_ID = "typeResourceId";
    435 
    436         /**
    437          * An optional name that can be used in the UI to represent this directory,
    438          * e.g. "Acme Corp"
    439          * <p>TYPE: text</p>
    440          */
    441         public static final String DISPLAY_NAME = "displayName";
    442 
    443         /**
    444          * <p>
    445          * The authority of the Directory Provider. Contacts Provider will
    446          * use this authority to forward requests to the directory provider.
    447          * A directory provider can leave this column empty - Contacts Provider will fill it in.
    448          * </p>
    449          * <p>
    450          * Clients of this API should not send requests directly to this authority.
    451          * All directory requests must be routed through Contacts Provider.
    452          * </p>
    453          *
    454          * <p>TYPE: text</p>
    455          */
    456         public static final String DIRECTORY_AUTHORITY = "authority";
    457 
    458         /**
    459          * The account type which this directory is associated.
    460          *
    461          * <p>TYPE: text</p>
    462          */
    463         public static final String ACCOUNT_TYPE = "accountType";
    464 
    465         /**
    466          * The account with which this directory is associated. If the account is later
    467          * removed, the directories it owns are automatically removed from this table.
    468          *
    469          * <p>TYPE: text</p>
    470          */
    471         public static final String ACCOUNT_NAME = "accountName";
    472 
    473         /**
    474          * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT},
    475          * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the
    476          * directory has for data exported from it.  Clients must obey this setting.
    477          */
    478         public static final String EXPORT_SUPPORT = "exportSupport";
    479 
    480         /**
    481          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
    482          * does not allow any data to be copied out of it.
    483          */
    484         public static final int EXPORT_SUPPORT_NONE = 0;
    485 
    486         /**
    487          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
    488          * allow its data copied only to the account specified by
    489          * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}.
    490          */
    491         public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1;
    492 
    493         /**
    494          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
    495          * allow its data copied to any contacts account.
    496          */
    497         public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2;
    498 
    499         /**
    500          * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY},
    501          * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory
    502          * has for shortcuts created for its elements. Clients must obey this setting.
    503          */
    504         public static final String SHORTCUT_SUPPORT = "shortcutSupport";
    505 
    506         /**
    507          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
    508          * does not allow any shortcuts created for its contacts.
    509          */
    510         public static final int SHORTCUT_SUPPORT_NONE = 0;
    511 
    512         /**
    513          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
    514          * allow creation of shortcuts for data items like email, phone or postal address,
    515          * but not the entire contact.
    516          */
    517         public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1;
    518 
    519         /**
    520          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
    521          * allow creation of shortcuts for contact as well as their constituent elements.
    522          */
    523         public static final int SHORTCUT_SUPPORT_FULL = 2;
    524 
    525         /**
    526          * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY},
    527          * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent
    528          * to which the directory supports contact photos.
    529          */
    530         public static final String PHOTO_SUPPORT = "photoSupport";
    531 
    532         /**
    533          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
    534          * does not provide any photos.
    535          */
    536         public static final int PHOTO_SUPPORT_NONE = 0;
    537 
    538         /**
    539          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
    540          * can only produce small size thumbnails of contact photos.
    541          */
    542         public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1;
    543 
    544         /**
    545          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
    546          * has full-size contact photos, but cannot provide scaled thumbnails.
    547          */
    548         public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2;
    549 
    550         /**
    551          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
    552          * can produce thumbnails as well as full-size contact photos.
    553          */
    554         public static final int PHOTO_SUPPORT_FULL = 3;
    555 
    556         /**
    557          * Notifies the system of a change in the list of directories handled by
    558          * a particular directory provider. The Contacts provider will turn around
    559          * and send a query to the directory provider for the full list of directories,
    560          * which will replace the previous list.
    561          */
    562         public static void notifyDirectoryChange(ContentResolver resolver) {
    563             // This is done to trigger a query by Contacts Provider back to the directory provider.
    564             // No data needs to be sent back, because the provider can infer the calling
    565             // package from binder.
    566             ContentValues contentValues = new ContentValues();
    567             resolver.update(Directory.CONTENT_URI, contentValues, null, null);
    568         }
    569     }
    570 
    571     /**
    572      * @hide should be removed when users are updated to refer to SyncState
    573      * @deprecated use SyncState instead
    574      */
    575     @Deprecated
    576     public interface SyncStateColumns extends SyncStateContract.Columns {
    577     }
    578 
    579     /**
    580      * A table provided for sync adapters to use for storing private sync state data for contacts.
    581      *
    582      * @see SyncStateContract
    583      */
    584     public static final class SyncState implements SyncStateContract.Columns {
    585         /**
    586          * This utility class cannot be instantiated
    587          */
    588         private SyncState() {}
    589 
    590         public static final String CONTENT_DIRECTORY =
    591                 SyncStateContract.Constants.CONTENT_DIRECTORY;
    592 
    593         /**
    594          * The content:// style URI for this table
    595          */
    596         public static final Uri CONTENT_URI =
    597                 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
    598 
    599         /**
    600          * @see android.provider.SyncStateContract.Helpers#get
    601          */
    602         public static byte[] get(ContentProviderClient provider, Account account)
    603                 throws RemoteException {
    604             return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
    605         }
    606 
    607         /**
    608          * @see android.provider.SyncStateContract.Helpers#get
    609          */
    610         public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
    611                 throws RemoteException {
    612             return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
    613         }
    614 
    615         /**
    616          * @see android.provider.SyncStateContract.Helpers#set
    617          */
    618         public static void set(ContentProviderClient provider, Account account, byte[] data)
    619                 throws RemoteException {
    620             SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
    621         }
    622 
    623         /**
    624          * @see android.provider.SyncStateContract.Helpers#newSetOperation
    625          */
    626         public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
    627             return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
    628         }
    629     }
    630 
    631 
    632     /**
    633      * A table provided for sync adapters to use for storing private sync state data for the
    634      * user's personal profile.
    635      *
    636      * @see SyncStateContract
    637      */
    638     public static final class ProfileSyncState implements SyncStateContract.Columns {
    639         /**
    640          * This utility class cannot be instantiated
    641          */
    642         private ProfileSyncState() {}
    643 
    644         public static final String CONTENT_DIRECTORY =
    645                 SyncStateContract.Constants.CONTENT_DIRECTORY;
    646 
    647         /**
    648          * The content:// style URI for this table
    649          */
    650         public static final Uri CONTENT_URI =
    651                 Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY);
    652 
    653         /**
    654          * @see android.provider.SyncStateContract.Helpers#get
    655          */
    656         public static byte[] get(ContentProviderClient provider, Account account)
    657                 throws RemoteException {
    658             return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
    659         }
    660 
    661         /**
    662          * @see android.provider.SyncStateContract.Helpers#get
    663          */
    664         public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
    665                 throws RemoteException {
    666             return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
    667         }
    668 
    669         /**
    670          * @see android.provider.SyncStateContract.Helpers#set
    671          */
    672         public static void set(ContentProviderClient provider, Account account, byte[] data)
    673                 throws RemoteException {
    674             SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
    675         }
    676 
    677         /**
    678          * @see android.provider.SyncStateContract.Helpers#newSetOperation
    679          */
    680         public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
    681             return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
    682         }
    683     }
    684 
    685     /**
    686      * Generic columns for use by sync adapters. The specific functions of
    687      * these columns are private to the sync adapter. Other clients of the API
    688      * should not attempt to either read or write this column.
    689      *
    690      * @see RawContacts
    691      * @see Groups
    692      */
    693     protected interface BaseSyncColumns {
    694 
    695         /** Generic column for use by sync adapters. */
    696         public static final String SYNC1 = "sync1";
    697         /** Generic column for use by sync adapters. */
    698         public static final String SYNC2 = "sync2";
    699         /** Generic column for use by sync adapters. */
    700         public static final String SYNC3 = "sync3";
    701         /** Generic column for use by sync adapters. */
    702         public static final String SYNC4 = "sync4";
    703     }
    704 
    705     /**
    706      * Columns that appear when each row of a table belongs to a specific
    707      * account, including sync information that an account may need.
    708      *
    709      * @see RawContacts
    710      * @see Groups
    711      */
    712     protected interface SyncColumns extends BaseSyncColumns {
    713         /**
    714          * The name of the account instance to which this row belongs, which when paired with
    715          * {@link #ACCOUNT_TYPE} identifies a specific account.
    716          * <P>Type: TEXT</P>
    717          */
    718         public static final String ACCOUNT_NAME = "account_name";
    719 
    720         /**
    721          * The type of account to which this row belongs, which when paired with
    722          * {@link #ACCOUNT_NAME} identifies a specific account.
    723          * <P>Type: TEXT</P>
    724          */
    725         public static final String ACCOUNT_TYPE = "account_type";
    726 
    727         /**
    728          * String that uniquely identifies this row to its source account.
    729          * <P>Type: TEXT</P>
    730          */
    731         public static final String SOURCE_ID = "sourceid";
    732 
    733         /**
    734          * Version number that is updated whenever this row or its related data
    735          * changes.
    736          * <P>Type: INTEGER</P>
    737          */
    738         public static final String VERSION = "version";
    739 
    740         /**
    741          * Flag indicating that {@link #VERSION} has changed, and this row needs
    742          * to be synchronized by its owning account.
    743          * <P>Type: INTEGER (boolean)</P>
    744          */
    745         public static final String DIRTY = "dirty";
    746     }
    747 
    748     /**
    749      * Columns of {@link ContactsContract.Contacts} that track the user's
    750      * preferences for, or interactions with, the contact.
    751      *
    752      * @see Contacts
    753      * @see RawContacts
    754      * @see ContactsContract.Data
    755      * @see PhoneLookup
    756      * @see ContactsContract.Contacts.AggregationSuggestions
    757      */
    758     protected interface ContactOptionsColumns {
    759         /**
    760          * The number of times a contact has been contacted
    761          * <P>Type: INTEGER</P>
    762          */
    763         public static final String TIMES_CONTACTED = "times_contacted";
    764 
    765         /**
    766          * The last time a contact was contacted.
    767          * <P>Type: INTEGER</P>
    768          */
    769         public static final String LAST_TIME_CONTACTED = "last_time_contacted";
    770 
    771         /**
    772          * Is the contact starred?
    773          * <P>Type: INTEGER (boolean)</P>
    774          */
    775         public static final String STARRED = "starred";
    776 
    777         /**
    778          * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED},
    779          * the contact is not pinned. Also see {@link PinnedPositions}.
    780          * <P>Type: INTEGER </P>
    781          */
    782         public static final String PINNED = "pinned";
    783 
    784         /**
    785          * URI for a custom ringtone associated with the contact. If null or missing,
    786          * the default ringtone is used.
    787          * <P>Type: TEXT (URI to the ringtone)</P>
    788          */
    789         public static final String CUSTOM_RINGTONE = "custom_ringtone";
    790 
    791         /**
    792          * Whether the contact should always be sent to voicemail. If missing,
    793          * defaults to false.
    794          * <P>Type: INTEGER (0 for false, 1 for true)</P>
    795          */
    796         public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
    797     }
    798 
    799     /**
    800      * Columns of {@link ContactsContract.Contacts} that refer to intrinsic
    801      * properties of the contact, as opposed to the user-specified options
    802      * found in {@link ContactOptionsColumns}.
    803      *
    804      * @see Contacts
    805      * @see ContactsContract.Data
    806      * @see PhoneLookup
    807      * @see ContactsContract.Contacts.AggregationSuggestions
    808      */
    809     protected interface ContactsColumns {
    810         /**
    811          * The display name for the contact.
    812          * <P>Type: TEXT</P>
    813          */
    814         public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY;
    815 
    816         /**
    817          * Reference to the row in the RawContacts table holding the contact name.
    818          * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P>
    819          */
    820         public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
    821 
    822         /**
    823          * Reference to the row in the data table holding the photo.  A photo can
    824          * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI}
    825          * and {@link #PHOTO_URI}).
    826          * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI},
    827          * which is a more generic mechanism for referencing the contact photo, especially for
    828          * contacts returned by non-local directories (see {@link Directory}).
    829          *
    830          * <P>Type: INTEGER REFERENCES data(_id)</P>
    831          */
    832         public static final String PHOTO_ID = "photo_id";
    833 
    834         /**
    835          * Photo file ID of the full-size photo.  If present, this will be used to populate
    836          * {@link #PHOTO_URI}.  The ID can also be used with
    837          * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo.
    838          * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated.
    839          *
    840          * <P>Type: INTEGER</P>
    841          */
    842         public static final String PHOTO_FILE_ID = "photo_file_id";
    843 
    844         /**
    845          * A URI that can be used to retrieve the contact's full-size photo.
    846          * If PHOTO_FILE_ID is not null, this will be populated with a URI based off
    847          * {@link ContactsContract.DisplayPhoto#CONTENT_URI}.  Otherwise, this will
    848          * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}.
    849          * A photo can be referred to either by a URI (this field) or by ID
    850          * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null,
    851          * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily
    852          * vice versa).  Thus using PHOTO_URI is a more robust method of retrieving
    853          * contact photos.
    854          *
    855          * <P>Type: TEXT</P>
    856          */
    857         public static final String PHOTO_URI = "photo_uri";
    858 
    859         /**
    860          * A URI that can be used to retrieve a thumbnail of the contact's photo.
    861          * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI})
    862          * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and
    863          * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa).
    864          * If the content provider does not differentiate between full-size photos
    865          * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain
    866          * the same value, but either both shall be null or both not null.
    867          *
    868          * <P>Type: TEXT</P>
    869          */
    870         public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri";
    871 
    872         /**
    873          * Flag that reflects whether the contact exists inside the default directory.
    874          * Ie, whether the contact is designed to only be visible outside search.
    875          */
    876         public static final String IN_DEFAULT_DIRECTORY = "in_default_directory";
    877 
    878         /**
    879          * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any
    880          * {@link CommonDataKinds.GroupMembership} for this contact.
    881          */
    882         public static final String IN_VISIBLE_GROUP = "in_visible_group";
    883 
    884         /**
    885          * Flag that reflects whether this contact represents the user's
    886          * personal profile entry.
    887          */
    888         public static final String IS_USER_PROFILE = "is_user_profile";
    889 
    890         /**
    891          * An indicator of whether this contact has at least one phone number. "1" if there is
    892          * at least one phone number, "0" otherwise.
    893          * <P>Type: INTEGER</P>
    894          */
    895         public static final String HAS_PHONE_NUMBER = "has_phone_number";
    896 
    897         /**
    898          * An opaque value that contains hints on how to find the contact if
    899          * its row id changed as a result of a sync or aggregation.
    900          */
    901         public static final String LOOKUP_KEY = "lookup";
    902 
    903         /**
    904          * Timestamp (milliseconds since epoch) of when this contact was last updated.  This
    905          * includes updates to all data associated with this contact including raw contacts.  Any
    906          * modification (including deletes and inserts) of underlying contact data are also
    907          * reflected in this timestamp.
    908          */
    909         public static final String CONTACT_LAST_UPDATED_TIMESTAMP =
    910                 "contact_last_updated_timestamp";
    911     }
    912 
    913     /**
    914      * @see Contacts
    915      */
    916     protected interface ContactStatusColumns {
    917         /**
    918          * Contact presence status. See {@link StatusUpdates} for individual status
    919          * definitions.
    920          * <p>Type: NUMBER</p>
    921          */
    922         public static final String CONTACT_PRESENCE = "contact_presence";
    923 
    924         /**
    925          * Contact Chat Capabilities. See {@link StatusUpdates} for individual
    926          * definitions.
    927          * <p>Type: NUMBER</p>
    928          */
    929         public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability";
    930 
    931         /**
    932          * Contact's latest status update.
    933          * <p>Type: TEXT</p>
    934          */
    935         public static final String CONTACT_STATUS = "contact_status";
    936 
    937         /**
    938          * The absolute time in milliseconds when the latest status was
    939          * inserted/updated.
    940          * <p>Type: NUMBER</p>
    941          */
    942         public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
    943 
    944         /**
    945          * The package containing resources for this status: label and icon.
    946          * <p>Type: TEXT</p>
    947          */
    948         public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
    949 
    950         /**
    951          * The resource ID of the label describing the source of contact
    952          * status, e.g. "Google Talk". This resource is scoped by the
    953          * {@link #CONTACT_STATUS_RES_PACKAGE}.
    954          * <p>Type: NUMBER</p>
    955          */
    956         public static final String CONTACT_STATUS_LABEL = "contact_status_label";
    957 
    958         /**
    959          * The resource ID of the icon for the source of contact status. This
    960          * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
    961          * <p>Type: NUMBER</p>
    962          */
    963         public static final String CONTACT_STATUS_ICON = "contact_status_icon";
    964     }
    965 
    966     /**
    967      * Constants for various styles of combining given name, family name etc into
    968      * a full name.  For example, the western tradition follows the pattern
    969      * 'given name' 'middle name' 'family name' with the alternative pattern being
    970      * 'family name', 'given name' 'middle name'.  The CJK tradition is
    971      * 'family name' 'middle name' 'given name', with Japanese favoring a space between
    972      * the names and Chinese omitting the space.
    973      */
    974     public interface FullNameStyle {
    975         public static final int UNDEFINED = 0;
    976         public static final int WESTERN = 1;
    977 
    978         /**
    979          * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
    980          * which specific language it belongs to: Chinese, Japanese or Korean.
    981          */
    982         public static final int CJK = 2;
    983 
    984         public static final int CHINESE = 3;
    985         public static final int JAPANESE = 4;
    986         public static final int KOREAN = 5;
    987     }
    988 
    989     /**
    990      * Constants for various styles of capturing the pronunciation of a person's name.
    991      */
    992     public interface PhoneticNameStyle {
    993         public static final int UNDEFINED = 0;
    994 
    995         /**
    996          * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
    997          * shown in UIs, but used for searches and sorting.
    998          */
    999         public static final int PINYIN = 3;
   1000 
   1001         /**
   1002          * Hiragana and Katakana are two common styles of writing out the pronunciation
   1003          * of a Japanese names.
   1004          */
   1005         public static final int JAPANESE = 4;
   1006 
   1007         /**
   1008          * Hangul is the Korean phonetic alphabet.
   1009          */
   1010         public static final int KOREAN = 5;
   1011     }
   1012 
   1013     /**
   1014      * Types of data used to produce the display name for a contact. In the order
   1015      * of increasing priority: {@link #EMAIL}, {@link #PHONE},
   1016      * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_PHONETIC_NAME},
   1017      * {@link #STRUCTURED_NAME}.
   1018      */
   1019     public interface DisplayNameSources {
   1020         public static final int UNDEFINED = 0;
   1021         public static final int EMAIL = 10;
   1022         public static final int PHONE = 20;
   1023         public static final int ORGANIZATION = 30;
   1024         public static final int NICKNAME = 35;
   1025         /** Display name comes from a structured name that only has phonetic components. */
   1026         public static final int STRUCTURED_PHONETIC_NAME = 37;
   1027         public static final int STRUCTURED_NAME = 40;
   1028     }
   1029 
   1030     /**
   1031      * Contact name and contact name metadata columns in the RawContacts table.
   1032      *
   1033      * @see Contacts
   1034      * @see RawContacts
   1035      */
   1036     protected interface ContactNameColumns {
   1037 
   1038         /**
   1039          * The kind of data that is used as the display name for the contact, such as
   1040          * structured name or email address.  See {@link DisplayNameSources}.
   1041          */
   1042         public static final String DISPLAY_NAME_SOURCE = "display_name_source";
   1043 
   1044         /**
   1045          * <p>
   1046          * The standard text shown as the contact's display name, based on the best
   1047          * available information for the contact (for example, it might be the email address
   1048          * if the name is not available).
   1049          * The information actually used to compute the name is stored in
   1050          * {@link #DISPLAY_NAME_SOURCE}.
   1051          * </p>
   1052          * <p>
   1053          * A contacts provider is free to choose whatever representation makes most
   1054          * sense for its target market.
   1055          * For example in the default Android Open Source Project implementation,
   1056          * if the display name is
   1057          * based on the structured name and the structured name follows
   1058          * the Western full-name style, then this field contains the "given name first"
   1059          * version of the full name.
   1060          * <p>
   1061          *
   1062          * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE
   1063          */
   1064         public static final String DISPLAY_NAME_PRIMARY = "display_name";
   1065 
   1066         /**
   1067          * <p>
   1068          * An alternative representation of the display name, such as "family name first"
   1069          * instead of "given name first" for Western names.  If an alternative is not
   1070          * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}.
   1071          * </p>
   1072          * <p>
   1073          * A contacts provider is free to provide alternatives as necessary for
   1074          * its target market.
   1075          * For example the default Android Open Source Project contacts provider
   1076          * currently provides an
   1077          * alternative in a single case:  if the display name is
   1078          * based on the structured name and the structured name follows
   1079          * the Western full name style, then the field contains the "family name first"
   1080          * version of the full name.
   1081          * Other cases may be added later.
   1082          * </p>
   1083          */
   1084         public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
   1085 
   1086         /**
   1087          * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}.  See
   1088          * {@link PhoneticNameStyle}.
   1089          */
   1090         public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
   1091 
   1092         /**
   1093          * <p>
   1094          * Pronunciation of the full name in the phonetic alphabet specified by
   1095          * {@link #PHONETIC_NAME_STYLE}.
   1096          * </p>
   1097          * <p>
   1098          * The value may be set manually by the user. This capability is of
   1099          * interest only in countries with commonly used phonetic alphabets,
   1100          * such as Japan and Korea. See {@link PhoneticNameStyle}.
   1101          * </p>
   1102          */
   1103         public static final String PHONETIC_NAME = "phonetic_name";
   1104 
   1105         /**
   1106          * Sort key that takes into account locale-based traditions for sorting
   1107          * names in address books.  The default
   1108          * sort key is {@link #DISPLAY_NAME_PRIMARY}.  For Chinese names
   1109          * the sort key is the name's Pinyin spelling, and for Japanese names
   1110          * it is the Hiragana version of the phonetic name.
   1111          */
   1112         public static final String SORT_KEY_PRIMARY = "sort_key";
   1113 
   1114         /**
   1115          * Sort key based on the alternative representation of the full name,
   1116          * {@link #DISPLAY_NAME_ALTERNATIVE}.  Thus for Western names,
   1117          * it is the one using the "family name first" format.
   1118          */
   1119         public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
   1120     }
   1121 
   1122     interface ContactCounts {
   1123 
   1124         /**
   1125          * Add this query parameter to a URI to get back row counts grouped by the address book
   1126          * index as cursor extras. For most languages it is the first letter of the sort key. This
   1127          * parameter does not affect the main content of the cursor.
   1128          *
   1129          * <p>
   1130          * <pre>
   1131          * Example:
   1132          *
   1133          * import android.provider.ContactsContract.Contacts;
   1134          *
   1135          * Uri uri = Contacts.CONTENT_URI.buildUpon()
   1136          *          .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true")
   1137          *          .build();
   1138          * Cursor cursor = getContentResolver().query(uri,
   1139          *          new String[] {Contacts.DISPLAY_NAME},
   1140          *          null, null, null);
   1141          * Bundle bundle = cursor.getExtras();
   1142          * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) &&
   1143          *         bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) {
   1144          *     String sections[] =
   1145          *             bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
   1146          *     int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
   1147          * }
   1148          * </pre>
   1149          * </p>
   1150          */
   1151         public static final String EXTRA_ADDRESS_BOOK_INDEX =
   1152                 "android.provider.extra.ADDRESS_BOOK_INDEX";
   1153 
   1154         /**
   1155          * The array of address book index titles, which are returned in the
   1156          * same order as the data in the cursor.
   1157          * <p>TYPE: String[]</p>
   1158          */
   1159         public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES =
   1160                 "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
   1161 
   1162         /**
   1163          * The array of group counts for the corresponding group.  Contains the same number
   1164          * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
   1165          * <p>TYPE: int[]</p>
   1166          */
   1167         public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS =
   1168                 "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
   1169     }
   1170 
   1171     /**
   1172      * Constants for the contacts table, which contains a record per aggregate
   1173      * of raw contacts representing the same person.
   1174      * <h3>Operations</h3>
   1175      * <dl>
   1176      * <dt><b>Insert</b></dt>
   1177      * <dd>A Contact cannot be created explicitly. When a raw contact is
   1178      * inserted, the provider will first try to find a Contact representing the
   1179      * same person. If one is found, the raw contact's
   1180      * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
   1181      * Contact. If no match is found, the provider automatically inserts a new
   1182      * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
   1183      * of the newly inserted raw contact.</dd>
   1184      * <dt><b>Update</b></dt>
   1185      * <dd>Only certain columns of Contact are modifiable:
   1186      * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
   1187      * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
   1188      * these columns on the Contact also changes them on all constituent raw
   1189      * contacts.</dd>
   1190      * <dt><b>Delete</b></dt>
   1191      * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
   1192      * deletes all constituent raw contacts. The corresponding sync adapters
   1193      * will notice the deletions of their respective raw contacts and remove
   1194      * them from their back end storage.</dd>
   1195      * <dt><b>Query</b></dt>
   1196      * <dd>
   1197      * <ul>
   1198      * <li>If you need to read an individual contact, consider using
   1199      * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
   1200      * <li>If you need to look up a contact by the phone number, use
   1201      * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
   1202      * which is optimized for this purpose.</li>
   1203      * <li>If you need to look up a contact by partial name, e.g. to produce
   1204      * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
   1205      * <li>If you need to look up a contact by some data element like email
   1206      * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
   1207      * The result will contain contact ID, name etc.
   1208      * </ul>
   1209      * </dd>
   1210      * </dl>
   1211      * <h2>Columns</h2>
   1212      * <table class="jd-sumtable">
   1213      * <tr>
   1214      * <th colspan='4'>Contacts</th>
   1215      * </tr>
   1216      * <tr>
   1217      * <td>long</td>
   1218      * <td>{@link #_ID}</td>
   1219      * <td>read-only</td>
   1220      * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
   1221      * </tr>
   1222      * <tr>
   1223      * <td>String</td>
   1224      * <td>{@link #LOOKUP_KEY}</td>
   1225      * <td>read-only</td>
   1226      * <td>An opaque value that contains hints on how to find the contact if its
   1227      * row id changed as a result of a sync or aggregation.</td>
   1228      * </tr>
   1229      * <tr>
   1230      * <td>long</td>
   1231      * <td>NAME_RAW_CONTACT_ID</td>
   1232      * <td>read-only</td>
   1233      * <td>The ID of the raw contact that contributes the display name
   1234      * to the aggregate contact. During aggregation one of the constituent
   1235      * raw contacts is chosen using a heuristic: a longer name or a name
   1236      * with more diacritic marks or more upper case characters is chosen.</td>
   1237      * </tr>
   1238      * <tr>
   1239      * <td>String</td>
   1240      * <td>DISPLAY_NAME_PRIMARY</td>
   1241      * <td>read-only</td>
   1242      * <td>The display name for the contact. It is the display name
   1243      * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
   1244      * column.</td>
   1245      * </tr>
   1246      * <tr>
   1247      * <td>long</td>
   1248      * <td>{@link #PHOTO_ID}</td>
   1249      * <td>read-only</td>
   1250      * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
   1251      * That row has the mime type
   1252      * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
   1253      * is computed automatically based on the
   1254      * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
   1255      * that mime type.</td>
   1256      * </tr>
   1257      * <tr>
   1258      * <td>long</td>
   1259      * <td>{@link #PHOTO_URI}</td>
   1260      * <td>read-only</td>
   1261      * <td>A URI that can be used to retrieve the contact's full-size photo. This
   1262      * column is the preferred method of retrieving the contact photo.</td>
   1263      * </tr>
   1264      * <tr>
   1265      * <td>long</td>
   1266      * <td>{@link #PHOTO_THUMBNAIL_URI}</td>
   1267      * <td>read-only</td>
   1268      * <td>A URI that can be used to retrieve the thumbnail of contact's photo.  This
   1269      * column is the preferred method of retrieving the contact photo.</td>
   1270      * </tr>
   1271      * <tr>
   1272      * <td>int</td>
   1273      * <td>{@link #IN_VISIBLE_GROUP}</td>
   1274      * <td>read-only</td>
   1275      * <td>An indicator of whether this contact is supposed to be visible in the
   1276      * UI. "1" if the contact has at least one raw contact that belongs to a
   1277      * visible group; "0" otherwise.</td>
   1278      * </tr>
   1279      * <tr>
   1280      * <td>int</td>
   1281      * <td>{@link #HAS_PHONE_NUMBER}</td>
   1282      * <td>read-only</td>
   1283      * <td>An indicator of whether this contact has at least one phone number.
   1284      * "1" if there is at least one phone number, "0" otherwise.</td>
   1285      * </tr>
   1286      * <tr>
   1287      * <td>int</td>
   1288      * <td>{@link #TIMES_CONTACTED}</td>
   1289      * <td>read/write</td>
   1290      * <td>The number of times the contact has been contacted. See
   1291      * {@link #markAsContacted}. When raw contacts are aggregated, this field is
   1292      * computed automatically as the maximum number of times contacted among all
   1293      * constituent raw contacts. Setting this field automatically changes the
   1294      * corresponding field on all constituent raw contacts.</td>
   1295      * </tr>
   1296      * <tr>
   1297      * <td>long</td>
   1298      * <td>{@link #LAST_TIME_CONTACTED}</td>
   1299      * <td>read/write</td>
   1300      * <td>The timestamp of the last time the contact was contacted. See
   1301      * {@link #markAsContacted}. Setting this field also automatically
   1302      * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
   1303      * this field is computed automatically as the latest time contacted of all
   1304      * constituent raw contacts. Setting this field automatically changes the
   1305      * corresponding field on all constituent raw contacts.</td>
   1306      * </tr>
   1307      * <tr>
   1308      * <td>int</td>
   1309      * <td>{@link #STARRED}</td>
   1310      * <td>read/write</td>
   1311      * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
   1312      * When raw contacts are aggregated, this field is automatically computed:
   1313      * if any constituent raw contacts are starred, then this field is set to
   1314      * '1'. Setting this field automatically changes the corresponding field on
   1315      * all constituent raw contacts.</td>
   1316      * </tr>
   1317      * <tr>
   1318      * <td>String</td>
   1319      * <td>{@link #CUSTOM_RINGTONE}</td>
   1320      * <td>read/write</td>
   1321      * <td>A custom ringtone associated with a contact. Typically this is the
   1322      * URI returned by an activity launched with the
   1323      * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
   1324      * </tr>
   1325      * <tr>
   1326      * <td>int</td>
   1327      * <td>{@link #SEND_TO_VOICEMAIL}</td>
   1328      * <td>read/write</td>
   1329      * <td>An indicator of whether calls from this contact should be forwarded
   1330      * directly to voice mail ('1') or not ('0'). When raw contacts are
   1331      * aggregated, this field is automatically computed: if <i>all</i>
   1332      * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
   1333      * to '1'. Setting this field automatically changes the corresponding field
   1334      * on all constituent raw contacts.</td>
   1335      * </tr>
   1336      * <tr>
   1337      * <td>int</td>
   1338      * <td>{@link #CONTACT_PRESENCE}</td>
   1339      * <td>read-only</td>
   1340      * <td>Contact IM presence status. See {@link StatusUpdates} for individual
   1341      * status definitions. Automatically computed as the highest presence of all
   1342      * constituent raw contacts. The provider may choose not to store this value
   1343      * in persistent storage. The expectation is that presence status will be
   1344      * updated on a regular basis.</td>
   1345      * </tr>
   1346      * <tr>
   1347      * <td>String</td>
   1348      * <td>{@link #CONTACT_STATUS}</td>
   1349      * <td>read-only</td>
   1350      * <td>Contact's latest status update. Automatically computed as the latest
   1351      * of all constituent raw contacts' status updates.</td>
   1352      * </tr>
   1353      * <tr>
   1354      * <td>long</td>
   1355      * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
   1356      * <td>read-only</td>
   1357      * <td>The absolute time in milliseconds when the latest status was
   1358      * inserted/updated.</td>
   1359      * </tr>
   1360      * <tr>
   1361      * <td>String</td>
   1362      * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
   1363      * <td>read-only</td>
   1364      * <td> The package containing resources for this status: label and icon.</td>
   1365      * </tr>
   1366      * <tr>
   1367      * <td>long</td>
   1368      * <td>{@link #CONTACT_STATUS_LABEL}</td>
   1369      * <td>read-only</td>
   1370      * <td>The resource ID of the label describing the source of contact status,
   1371      * e.g. "Google Talk". This resource is scoped by the
   1372      * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
   1373      * </tr>
   1374      * <tr>
   1375      * <td>long</td>
   1376      * <td>{@link #CONTACT_STATUS_ICON}</td>
   1377      * <td>read-only</td>
   1378      * <td>The resource ID of the icon for the source of contact status. This
   1379      * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
   1380      * </tr>
   1381      * </table>
   1382      */
   1383     public static class Contacts implements BaseColumns, ContactsColumns,
   1384             ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts {
   1385         /**
   1386          * This utility class cannot be instantiated
   1387          */
   1388         private Contacts()  {}
   1389 
   1390         /**
   1391          * The content:// style URI for this table
   1392          */
   1393         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
   1394 
   1395         /**
   1396          * Special contacts URI to refer to contacts on the corp profile from the personal
   1397          * profile.
   1398          *
   1399          * It's supported only by a few specific places for referring to contact pictures that
   1400          * are in the corp provider for enterprise caller-ID.  Contact picture URIs returned from
   1401          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI.
   1402          *
   1403          * @hide
   1404          */
   1405         public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
   1406                 "contacts_corp");
   1407 
   1408         /**
   1409          * A content:// style URI for this table that should be used to create
   1410          * shortcuts or otherwise create long-term links to contacts. This URI
   1411          * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
   1412          * It can optionally also have a "/" and last known contact ID appended after
   1413          * that. This "complete" format is an important optimization and is highly recommended.
   1414          * <p>
   1415          * As long as the contact's row ID remains the same, this URI is
   1416          * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
   1417          * as a result of a sync or aggregation, this URI will look up the
   1418          * contact using indirect information (sync IDs or constituent raw
   1419          * contacts).
   1420          * <p>
   1421          * Lookup key should be appended unencoded - it is stored in the encoded
   1422          * form, ready for use in a URI.
   1423          */
   1424         public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
   1425                 "lookup");
   1426 
   1427         /**
   1428          * Base {@link Uri} for referencing a single {@link Contacts} entry,
   1429          * created by appending {@link #LOOKUP_KEY} using
   1430          * {@link Uri#withAppendedPath(Uri, String)}. Provides
   1431          * {@link OpenableColumns} columns when queried, or returns the
   1432          * referenced contact formatted as a vCard when opened through
   1433          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
   1434          */
   1435         public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
   1436                 "as_vcard");
   1437 
   1438        /**
   1439         * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI}
   1440         * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned
   1441         * vcard should not contain a photo.
   1442         *
   1443         * This is useful for obtaining a space efficient vcard.
   1444         */
   1445         public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "no_photo";
   1446 
   1447         /**
   1448          * Base {@link Uri} for referencing multiple {@link Contacts} entry,
   1449          * created by appending {@link #LOOKUP_KEY} using
   1450          * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
   1451          * joined with the colon (":") separator, and the resulting string encoded.
   1452          *
   1453          * Provides {@link OpenableColumns} columns when queried, or returns the
   1454          * referenced contact formatted as a vCard when opened through
   1455          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
   1456          *
   1457          * <p>
   1458          * Usage example:
   1459          * <dl>
   1460          * <dt>The following code snippet creates a multi-vcard URI that references all the
   1461          * contacts in a user's database.</dt>
   1462          * <dd>
   1463          *
   1464          * <pre>
   1465          * public Uri getAllContactsVcardUri() {
   1466          *     Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI,
   1467          *         new String[] {Contacts.LOOKUP_KEY}, null, null, null);
   1468          *     if (cursor == null) {
   1469          *         return null;
   1470          *     }
   1471          *     try {
   1472          *         StringBuilder uriListBuilder = new StringBuilder();
   1473          *         int index = 0;
   1474          *         while (cursor.moveToNext()) {
   1475          *             if (index != 0) uriListBuilder.append(':');
   1476          *             uriListBuilder.append(cursor.getString(0));
   1477          *             index++;
   1478          *         }
   1479          *         return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI,
   1480          *                 Uri.encode(uriListBuilder.toString()));
   1481          *     } finally {
   1482          *         cursor.close();
   1483          *     }
   1484          * }
   1485          * </pre>
   1486          *
   1487          * </p>
   1488          */
   1489         public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
   1490                 "as_multi_vcard");
   1491 
   1492         /**
   1493          * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
   1494          * requested {@link Contacts} entry.
   1495          *
   1496          * @param contactUri A {@link #CONTENT_URI} row, or an existing
   1497          *            {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
   1498          */
   1499         public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
   1500             final Cursor c = resolver.query(contactUri, new String[] {
   1501                     Contacts.LOOKUP_KEY, Contacts._ID
   1502             }, null, null, null);
   1503             if (c == null) {
   1504                 return null;
   1505             }
   1506 
   1507             try {
   1508                 if (c.moveToFirst()) {
   1509                     final String lookupKey = c.getString(0);
   1510                     final long contactId = c.getLong(1);
   1511                     return getLookupUri(contactId, lookupKey);
   1512                 }
   1513             } finally {
   1514                 c.close();
   1515             }
   1516             return null;
   1517         }
   1518 
   1519         /**
   1520          * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
   1521          * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
   1522          * <p>
   1523          * Returns null if unable to construct a valid lookup URI from the
   1524          * provided parameters.
   1525          */
   1526         public static Uri getLookupUri(long contactId, String lookupKey) {
   1527             if (TextUtils.isEmpty(lookupKey)) {
   1528                 return null;
   1529             }
   1530             return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
   1531                     lookupKey), contactId);
   1532         }
   1533 
   1534         /**
   1535          * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
   1536          * <p>
   1537          * Returns null if the contact cannot be found.
   1538          */
   1539         public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
   1540             if (lookupUri == null) {
   1541                 return null;
   1542             }
   1543 
   1544             Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
   1545             if (c == null) {
   1546                 return null;
   1547             }
   1548 
   1549             try {
   1550                 if (c.moveToFirst()) {
   1551                     long contactId = c.getLong(0);
   1552                     return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
   1553                 }
   1554             } finally {
   1555                 c.close();
   1556             }
   1557             return null;
   1558         }
   1559 
   1560         /**
   1561          * Mark a contact as having been contacted. Updates two fields:
   1562          * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The
   1563          * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED
   1564          * field is populated with the current system time.
   1565          *
   1566          * @param resolver the ContentResolver to use
   1567          * @param contactId the person who was contacted
   1568          *
   1569          * @deprecated The class DataUsageStatUpdater of the Android support library should
   1570          *     be used instead.
   1571          */
   1572         @Deprecated
   1573         public static void markAsContacted(ContentResolver resolver, long contactId) {
   1574             Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
   1575             ContentValues values = new ContentValues();
   1576             // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
   1577             values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
   1578             resolver.update(uri, values, null, null);
   1579         }
   1580 
   1581         /**
   1582          * The content:// style URI used for "type-to-filter" functionality on the
   1583          * {@link #CONTENT_URI} URI. The filter string will be used to match
   1584          * various parts of the contact name. The filter argument should be passed
   1585          * as an additional path segment after this URI.
   1586          */
   1587         public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
   1588                 CONTENT_URI, "filter");
   1589 
   1590         /**
   1591          * The content:// style URI for this table joined with useful data from
   1592          * {@link ContactsContract.Data}, filtered to include only starred contacts
   1593          * and the most frequently contacted contacts.
   1594          */
   1595         public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
   1596                 CONTENT_URI, "strequent");
   1597 
   1598         /**
   1599          * The content:// style URI for showing a list of frequently contacted people.
   1600          */
   1601         public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath(
   1602                 CONTENT_URI, "frequent");
   1603 
   1604         /**
   1605          * The content:// style URI used for "type-to-filter" functionality on the
   1606          * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
   1607          * various parts of the contact name. The filter argument should be passed
   1608          * as an additional path segment after this URI.
   1609          */
   1610         public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
   1611                 CONTENT_STREQUENT_URI, "filter");
   1612 
   1613         public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
   1614                 CONTENT_URI, "group");
   1615 
   1616         /**
   1617          * The MIME type of {@link #CONTENT_URI} providing a directory of
   1618          * people.
   1619          */
   1620         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
   1621 
   1622         /**
   1623          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
   1624          * person.
   1625          */
   1626         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
   1627 
   1628         /**
   1629          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
   1630          * person.
   1631          */
   1632         public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
   1633 
   1634         /**
   1635          * Mimimal ID for corp contacts returned from
   1636          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
   1637          *
   1638          * @hide
   1639          */
   1640         public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
   1641 
   1642         /**
   1643          * Prefix for corp contacts returned from
   1644          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
   1645          *
   1646          * @hide
   1647          */
   1648         public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-";
   1649 
   1650         /**
   1651          * Return TRUE if a contact ID is from the contacts provider on the enterprise profile.
   1652          *
   1653          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact.
   1654          */
   1655         public static boolean isEnterpriseContactId(long contactId) {
   1656             return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
   1657         }
   1658 
   1659         /**
   1660          * A sub-directory of a single contact that contains all of the constituent raw contact
   1661          * {@link ContactsContract.Data} rows.  This directory can be used either
   1662          * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
   1663          */
   1664         public static final class Data implements BaseColumns, DataColumns {
   1665             /**
   1666              * no public constructor since this is a utility class
   1667              */
   1668             private Data() {}
   1669 
   1670             /**
   1671              * The directory twig for this sub-table
   1672              */
   1673             public static final String CONTENT_DIRECTORY = "data";
   1674         }
   1675 
   1676         /**
   1677          * <p>
   1678          * A sub-directory of a contact that contains all of its
   1679          * {@link ContactsContract.RawContacts} as well as
   1680          * {@link ContactsContract.Data} rows. To access this directory append
   1681          * {@link #CONTENT_DIRECTORY} to the contact URI.
   1682          * </p>
   1683          * <p>
   1684          * Entity has three ID fields: {@link #CONTACT_ID} for the contact,
   1685          * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for
   1686          * the data rows. Entity always contains at least one row per
   1687          * constituent raw contact, even if there are no actual data rows. In
   1688          * this case the {@link #DATA_ID} field will be null.
   1689          * </p>
   1690          * <p>
   1691          * Entity reads all data for the entire contact in one transaction, to
   1692          * guarantee consistency.  There is significant data duplication
   1693          * in the Entity (each row repeats all Contact columns and all RawContact
   1694          * columns), so the benefits of transactional consistency should be weighed
   1695          * against the cost of transferring large amounts of denormalized data
   1696          * from the Provider.
   1697          * </p>
   1698          * <p>
   1699          * To reduce the amount of data duplication the contacts provider and directory
   1700          * providers implementing this protocol are allowed to provide common Contacts
   1701          * and RawContacts fields in the first row returned for each raw contact only and
   1702          * leave them as null in subsequent rows.
   1703          * </p>
   1704          */
   1705         public static final class Entity implements BaseColumns, ContactsColumns,
   1706                 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns,
   1707                 StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns {
   1708             /**
   1709              * no public constructor since this is a utility class
   1710              */
   1711             private Entity() {
   1712             }
   1713 
   1714             /**
   1715              * The directory twig for this sub-table
   1716              */
   1717             public static final String CONTENT_DIRECTORY = "entities";
   1718 
   1719             /**
   1720              * The ID of the raw contact row.
   1721              * <P>Type: INTEGER</P>
   1722              */
   1723             public static final String RAW_CONTACT_ID = "raw_contact_id";
   1724 
   1725             /**
   1726              * The ID of the data row. The value will be null if this raw contact has no
   1727              * data rows.
   1728              * <P>Type: INTEGER</P>
   1729              */
   1730             public static final String DATA_ID = "data_id";
   1731         }
   1732 
   1733         /**
   1734          * <p>
   1735          * A sub-directory of a single contact that contains all of the constituent raw contact
   1736          * {@link ContactsContract.StreamItems} rows.  This directory can be used either
   1737          * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
   1738          * </p>
   1739          * <p>
   1740          * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM
   1741          * permission.
   1742          * </p>
   1743          *
   1744          * @deprecated - Do not use. This will not be supported in the future. In the future,
   1745          * cursors returned from related queries will be empty.
   1746          *
   1747          * @hide
   1748          * @removed
   1749          */
   1750         @Deprecated
   1751         public static final class StreamItems implements StreamItemsColumns {
   1752             /**
   1753              * no public constructor since this is a utility class
   1754              *
   1755              * @deprecated - Do not use. This will not be supported in the future. In the future,
   1756              * cursors returned from related queries will be empty.
   1757              */
   1758             @Deprecated
   1759             private StreamItems() {}
   1760 
   1761             /**
   1762              * The directory twig for this sub-table
   1763              *
   1764              * @deprecated - Do not use. This will not be supported in the future. In the future,
   1765              * cursors returned from related queries will be empty.
   1766              */
   1767             @Deprecated
   1768             public static final String CONTENT_DIRECTORY = "stream_items";
   1769         }
   1770 
   1771         /**
   1772          * <p>
   1773          * A <i>read-only</i> sub-directory of a single contact aggregate that
   1774          * contains all aggregation suggestions (other contacts). The
   1775          * aggregation suggestions are computed based on approximate data
   1776          * matches with this contact.
   1777          * </p>
   1778          * <p>
   1779          * <i>Note: this query may be expensive! If you need to use it in bulk,
   1780          * make sure the user experience is acceptable when the query runs for a
   1781          * long time.</i>
   1782          * <p>
   1783          * Usage example:
   1784          *
   1785          * <pre>
   1786          * Uri uri = Contacts.CONTENT_URI.buildUpon()
   1787          *          .appendEncodedPath(String.valueOf(contactId))
   1788          *          .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
   1789          *          .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
   1790          *          .build()
   1791          * Cursor cursor = getContentResolver().query(suggestionsUri,
   1792          *          new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
   1793          *          null, null, null);
   1794          * </pre>
   1795          *
   1796          * </p>
   1797          * <p>
   1798          * This directory can be used either with a {@link #CONTENT_URI} or
   1799          * {@link #CONTENT_LOOKUP_URI}.
   1800          * </p>
   1801          */
   1802         public static final class AggregationSuggestions implements BaseColumns, ContactsColumns,
   1803                 ContactOptionsColumns, ContactStatusColumns {
   1804             /**
   1805              * No public constructor since this is a utility class
   1806              */
   1807             private AggregationSuggestions() {}
   1808 
   1809             /**
   1810              * The directory twig for this sub-table. The URI can be followed by an optional
   1811              * type-to-filter, similar to
   1812              * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
   1813              */
   1814             public static final String CONTENT_DIRECTORY = "suggestions";
   1815 
   1816             /**
   1817              * Used to specify what kind of data is supplied for the suggestion query.
   1818              *
   1819              * @hide
   1820              */
   1821             public static final String PARAMETER_MATCH_NAME = "name";
   1822 
   1823             /**
   1824              * A convenience builder for aggregation suggestion content URIs.
   1825              */
   1826             public static final class Builder {
   1827                 private long mContactId;
   1828                 private final ArrayList<String> mValues = new ArrayList<String>();
   1829                 private int mLimit;
   1830 
   1831                 /**
   1832                  * Optional existing contact ID.  If it is not provided, the search
   1833                  * will be based exclusively on the values supplied with {@link #addNameParameter}.
   1834                  *
   1835                  * @param contactId contact to find aggregation suggestions for
   1836                  * @return This Builder object to allow for chaining of calls to builder methods
   1837                  */
   1838                 public Builder setContactId(long contactId) {
   1839                     this.mContactId = contactId;
   1840                     return this;
   1841                 }
   1842 
   1843                 /**
   1844                  * Add a name to be used when searching for aggregation suggestions.
   1845                  *
   1846                  * @param name name to find aggregation suggestions for
   1847                  * @return This Builder object to allow for chaining of calls to builder methods
   1848                  */
   1849                 public Builder addNameParameter(String name) {
   1850                     mValues.add(name);
   1851                     return this;
   1852                 }
   1853 
   1854                 /**
   1855                  * Sets the Maximum number of suggested aggregations that should be returned.
   1856                  * @param limit The maximum number of suggested aggregations
   1857                  *
   1858                  * @return This Builder object to allow for chaining of calls to builder methods
   1859                  */
   1860                 public Builder setLimit(int limit) {
   1861                     mLimit = limit;
   1862                     return this;
   1863                 }
   1864 
   1865                 /**
   1866                  * Combine all of the options that have been set and return a new {@link Uri}
   1867                  * object for fetching aggregation suggestions.
   1868                  */
   1869                 public Uri build() {
   1870                     android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon();
   1871                     builder.appendEncodedPath(String.valueOf(mContactId));
   1872                     builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY);
   1873                     if (mLimit != 0) {
   1874                         builder.appendQueryParameter("limit", String.valueOf(mLimit));
   1875                     }
   1876 
   1877                     int count = mValues.size();
   1878                     for (int i = 0; i < count; i++) {
   1879                         builder.appendQueryParameter("query", PARAMETER_MATCH_NAME
   1880                                 + ":" + mValues.get(i));
   1881                     }
   1882 
   1883                     return builder.build();
   1884                 }
   1885             }
   1886 
   1887             /**
   1888              * @hide
   1889              */
   1890             public static final Builder builder() {
   1891                 return new Builder();
   1892             }
   1893         }
   1894 
   1895         /**
   1896          * A <i>read-only</i> sub-directory of a single contact that contains
   1897          * the contact's primary photo.  The photo may be stored in up to two ways -
   1898          * the default "photo" is a thumbnail-sized image stored directly in the data
   1899          * row, while the "display photo", if present, is a larger version stored as
   1900          * a file.
   1901          * <p>
   1902          * Usage example:
   1903          * <dl>
   1904          * <dt>Retrieving the thumbnail-sized photo</dt>
   1905          * <dd>
   1906          * <pre>
   1907          * public InputStream openPhoto(long contactId) {
   1908          *     Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
   1909          *     Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
   1910          *     Cursor cursor = getContentResolver().query(photoUri,
   1911          *          new String[] {Contacts.Photo.PHOTO}, null, null, null);
   1912          *     if (cursor == null) {
   1913          *         return null;
   1914          *     }
   1915          *     try {
   1916          *         if (cursor.moveToFirst()) {
   1917          *             byte[] data = cursor.getBlob(0);
   1918          *             if (data != null) {
   1919          *                 return new ByteArrayInputStream(data);
   1920          *             }
   1921          *         }
   1922          *     } finally {
   1923          *         cursor.close();
   1924          *     }
   1925          *     return null;
   1926          * }
   1927          * </pre>
   1928          * </dd>
   1929          * <dt>Retrieving the larger photo version</dt>
   1930          * <dd>
   1931          * <pre>
   1932          * public InputStream openDisplayPhoto(long contactId) {
   1933          *     Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
   1934          *     Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
   1935          *     try {
   1936          *         AssetFileDescriptor fd =
   1937          *             getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
   1938          *         return fd.createInputStream();
   1939          *     } catch (IOException e) {
   1940          *         return null;
   1941          *     }
   1942          * }
   1943          * </pre>
   1944          * </dd>
   1945          * </dl>
   1946          *
   1947          * </p>
   1948          * <p>You may also consider using the convenience method
   1949          * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)}
   1950          * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo.
   1951          * </p>
   1952          * <p>
   1953          * This directory can be used either with a {@link #CONTENT_URI} or
   1954          * {@link #CONTENT_LOOKUP_URI}.
   1955          * </p>
   1956          */
   1957         public static final class Photo implements BaseColumns, DataColumnsWithJoins {
   1958             /**
   1959              * no public constructor since this is a utility class
   1960              */
   1961             private Photo() {}
   1962 
   1963             /**
   1964              * The directory twig for this sub-table
   1965              */
   1966             public static final String CONTENT_DIRECTORY = "photo";
   1967 
   1968             /**
   1969              * The directory twig for retrieving the full-size display photo.
   1970              */
   1971             public static final String DISPLAY_PHOTO = "display_photo";
   1972 
   1973             /**
   1974              * Full-size photo file ID of the raw contact.
   1975              * See {@link ContactsContract.DisplayPhoto}.
   1976              * <p>
   1977              * Type: NUMBER
   1978              */
   1979             public static final String PHOTO_FILE_ID = DATA14;
   1980 
   1981             /**
   1982              * Thumbnail photo of the raw contact. This is the raw bytes of an image
   1983              * that could be inflated using {@link android.graphics.BitmapFactory}.
   1984              * <p>
   1985              * Type: BLOB
   1986              */
   1987             public static final String PHOTO = DATA15;
   1988         }
   1989 
   1990         /**
   1991          * Opens an InputStream for the contacts's photo and returns the
   1992          * photo as a byte stream.
   1993          * @param cr The content resolver to use for querying
   1994          * @param contactUri the contact whose photo should be used. This can be used with
   1995          * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
   1996          * @param preferHighres If this is true and the contact has a higher resolution photo
   1997          * available, it is returned. If false, this function always tries to get the thumbnail
   1998          * @return an InputStream of the photo, or null if no photo is present
   1999          */
   2000         public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri,
   2001                 boolean preferHighres) {
   2002             if (preferHighres) {
   2003                 final Uri displayPhotoUri = Uri.withAppendedPath(contactUri,
   2004                         Contacts.Photo.DISPLAY_PHOTO);
   2005                 InputStream inputStream;
   2006                 try {
   2007                     AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r");
   2008                     return fd.createInputStream();
   2009                 } catch (IOException e) {
   2010                     // fallback to the thumbnail code
   2011                 }
   2012            }
   2013 
   2014             Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
   2015             if (photoUri == null) {
   2016                 return null;
   2017             }
   2018             Cursor cursor = cr.query(photoUri,
   2019                     new String[] {
   2020                         ContactsContract.CommonDataKinds.Photo.PHOTO
   2021                     }, null, null, null);
   2022             try {
   2023                 if (cursor == null || !cursor.moveToNext()) {
   2024                     return null;
   2025                 }
   2026                 byte[] data = cursor.getBlob(0);
   2027                 if (data == null) {
   2028                     return null;
   2029                 }
   2030                 return new ByteArrayInputStream(data);
   2031             } finally {
   2032                 if (cursor != null) {
   2033                     cursor.close();
   2034                 }
   2035             }
   2036         }
   2037 
   2038         /**
   2039          * Opens an InputStream for the contacts's thumbnail photo and returns the
   2040          * photo as a byte stream.
   2041          * @param cr The content resolver to use for querying
   2042          * @param contactUri the contact whose photo should be used. This can be used with
   2043          * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
   2044          * @return an InputStream of the photo, or null if no photo is present
   2045          * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead
   2046          * of the thumbnail the high-res picture is preferred
   2047          */
   2048         public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
   2049             return openContactPhotoInputStream(cr, contactUri, false);
   2050         }
   2051     }
   2052 
   2053     /**
   2054      * <p>
   2055      * Constants for the user's profile data, which is represented as a single contact on
   2056      * the device that represents the user.  The profile contact is not aggregated
   2057      * together automatically in the same way that normal contacts are; instead, each
   2058      * account (including data set, if applicable) on the device may contribute a single
   2059      * raw contact representing the user's personal profile data from that source.
   2060      * </p>
   2061      * <p>
   2062      * Access to the profile entry through these URIs (or incidental access to parts of
   2063      * the profile if retrieved directly via ID) requires additional permissions beyond
   2064      * the read/write contact permissions required by the provider.  Querying for profile
   2065      * data requires android.permission.READ_PROFILE permission, and inserting or
   2066      * updating profile data requires android.permission.WRITE_PROFILE permission.
   2067      * </p>
   2068      * <h3>Operations</h3>
   2069      * <dl>
   2070      * <dt><b>Insert</b></dt>
   2071      * <dd>The user's profile entry cannot be created explicitly (attempting to do so
   2072      * will throw an exception). When a raw contact is inserted into the profile, the
   2073      * provider will check for the existence of a profile on the device.  If one is
   2074      * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of
   2075      * the profile Contact. If no match is found, the profile Contact is created and
   2076      * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly
   2077      * inserted raw contact.</dd>
   2078      * <dt><b>Update</b></dt>
   2079      * <dd>The profile Contact has the same update restrictions as Contacts in general,
   2080      * but requires the android.permission.WRITE_PROFILE permission.</dd>
   2081      * <dt><b>Delete</b></dt>
   2082      * <dd>The profile Contact cannot be explicitly deleted.  It will be removed
   2083      * automatically if all of its constituent raw contact entries are deleted.</dd>
   2084      * <dt><b>Query</b></dt>
   2085      * <dd>
   2086      * <ul>
   2087      * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as
   2088      * retrieving a contact by ID, except that it will only ever return the user's
   2089      * profile contact.
   2090      * </li>
   2091      * <li>
   2092      * The profile contact supports all of the same sub-paths as an individual contact
   2093      * does - the content of the profile contact can be retrieved as entities or
   2094      * data rows.  Similarly, specific raw contact entries can be retrieved by appending
   2095      * the desired raw contact ID within the profile.
   2096      * </li>
   2097      * </ul>
   2098      * </dd>
   2099      * </dl>
   2100      */
   2101     public static final class Profile implements BaseColumns, ContactsColumns,
   2102             ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
   2103         /**
   2104          * This utility class cannot be instantiated
   2105          */
   2106         private Profile() {
   2107         }
   2108 
   2109         /**
   2110          * The content:// style URI for this table, which requests the contact entry
   2111          * representing the user's personal profile data.
   2112          */
   2113         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile");
   2114 
   2115         /**
   2116          * {@link Uri} for referencing the user's profile {@link Contacts} entry,
   2117          * Provides {@link OpenableColumns} columns when queried, or returns the
   2118          * user's profile contact formatted as a vCard when opened through
   2119          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
   2120          */
   2121         public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
   2122                 "as_vcard");
   2123 
   2124         /**
   2125          * {@link Uri} for referencing the raw contacts that make up the user's profile
   2126          * {@link Contacts} entry.  An individual raw contact entry within the profile
   2127          * can be addressed by appending the raw contact ID.  The entities or data within
   2128          * that specific raw contact can be requested by appending the entity or data
   2129          * path as well.
   2130          */
   2131         public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI,
   2132                 "raw_contacts");
   2133 
   2134         /**
   2135          * The minimum ID for any entity that belongs to the profile.  This essentially
   2136          * defines an ID-space in which profile data is stored, and is used by the provider
   2137          * to determine whether a request via a non-profile-specific URI should be directed
   2138          * to the profile data rather than general contacts data, along with all the special
   2139          * permission checks that entails.
   2140          *
   2141          * Callers may use {@link #isProfileId} to check whether a specific ID falls into
   2142          * the set of data intended for the profile.
   2143          */
   2144         public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE;
   2145     }
   2146 
   2147     /**
   2148      * This method can be used to identify whether the given ID is associated with profile
   2149      * data.  It does not necessarily indicate that the ID is tied to valid data, merely
   2150      * that accessing data using this ID will result in profile access checks and will only
   2151      * return data from the profile.
   2152      *
   2153      * @param id The ID to check.
   2154      * @return Whether the ID is associated with profile data.
   2155      */
   2156     public static boolean isProfileId(long id) {
   2157         return id >= Profile.MIN_ID;
   2158     }
   2159 
   2160     protected interface DeletedContactsColumns {
   2161 
   2162         /**
   2163          * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted.
   2164          * <P>Type: INTEGER</P>
   2165          */
   2166         public static final String CONTACT_ID = "contact_id";
   2167 
   2168         /**
   2169          * Time (milliseconds since epoch) that the contact was deleted.
   2170          */
   2171         public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp";
   2172     }
   2173 
   2174     /**
   2175      * Constants for the deleted contact table.  This table holds a log of deleted contacts.
   2176      * <p>
   2177      * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted.
   2178      */
   2179     public static final class DeletedContacts implements DeletedContactsColumns {
   2180 
   2181         /**
   2182          * This utility class cannot be instantiated
   2183          */
   2184         private DeletedContacts() {
   2185         }
   2186 
   2187         /**
   2188          * The content:// style URI for this table, which requests a directory of raw contact rows
   2189          * matching the selection criteria.
   2190          */
   2191         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
   2192                 "deleted_contacts");
   2193 
   2194         /**
   2195          * Number of days that the delete log will be kept.  After this time, delete records may be
   2196          * deleted.
   2197          *
   2198          * @hide
   2199          */
   2200         private static final int DAYS_KEPT = 30;
   2201 
   2202         /**
   2203          * Milliseconds that the delete log will be kept.  After this time, delete records may be
   2204          * deleted.
   2205          */
   2206         public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT;
   2207     }
   2208 
   2209     protected interface RawContactsColumns {
   2210         /**
   2211          * A reference to the {@link ContactsContract.Contacts#_ID} that this
   2212          * data belongs to.
   2213          * <P>Type: INTEGER</P>
   2214          */
   2215         public static final String CONTACT_ID = "contact_id";
   2216 
   2217         /**
   2218          * Persistent unique id for each raw_contact within its account.
   2219          * This id is provided by its own data source, and can be used to backup metadata
   2220          * to the server.
   2221          * This should be unique within each set of account_name/account_type/data_set
   2222          *
   2223          * @hide
   2224          */
   2225         public static final String BACKUP_ID = "backup_id";
   2226 
   2227         /**
   2228          * The data set within the account that this row belongs to.  This allows
   2229          * multiple sync adapters for the same account type to distinguish between
   2230          * each others' data.
   2231          *
   2232          * This is empty by default, and is completely optional.  It only needs to
   2233          * be populated if multiple sync adapters are entering distinct data for
   2234          * the same account type and account name.
   2235          * <P>Type: TEXT</P>
   2236          */
   2237         public static final String DATA_SET = "data_set";
   2238 
   2239         /**
   2240          * A concatenation of the account type and data set (delimited by a forward
   2241          * slash) - if the data set is empty, this will be the same as the account
   2242          * type.  For applications that need to be aware of the data set, this can
   2243          * be used instead of account type to distinguish sets of data.  This is
   2244          * never intended to be used for specifying accounts.
   2245          * <p>
   2246          * This column does *not* escape forward slashes in the account type or the data set.
   2247          * If this is an issue, consider using
   2248          * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and
   2249          * {@link ContactsContract.RawContacts#DATA_SET} directly.
   2250          */
   2251         public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
   2252 
   2253         /**
   2254          * The aggregation mode for this contact.
   2255          * <P>Type: INTEGER</P>
   2256          */
   2257         public static final String AGGREGATION_MODE = "aggregation_mode";
   2258 
   2259         /**
   2260          * The "deleted" flag: "0" by default, "1" if the row has been marked
   2261          * for deletion. When {@link android.content.ContentResolver#delete} is
   2262          * called on a raw contact, it is marked for deletion and removed from its
   2263          * aggregate contact. The sync adaptor deletes the raw contact on the server and
   2264          * then calls ContactResolver.delete once more, this time passing the
   2265          * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
   2266          * the data removal.
   2267          * <P>Type: INTEGER</P>
   2268          */
   2269         public static final String DELETED = "deleted";
   2270 
   2271         /**
   2272          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
   2273          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
   2274          * <P>Type: INTEGER</P>
   2275          */
   2276         public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
   2277 
   2278         /**
   2279          * Flag that reflects whether this raw contact belongs to the user's
   2280          * personal profile entry.
   2281          */
   2282         public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile";
   2283     }
   2284 
   2285     /**
   2286      * Constants for the raw contacts table, which contains one row of contact
   2287      * information for each person in each synced account. Sync adapters and
   2288      * contact management apps
   2289      * are the primary consumers of this API.
   2290      *
   2291      * <h3>Aggregation</h3>
   2292      * <p>
   2293      * As soon as a raw contact is inserted or whenever its constituent data
   2294      * changes, the provider will check if the raw contact matches other
   2295      * existing raw contacts and if so will aggregate it with those. The
   2296      * aggregation is reflected in the {@link RawContacts} table by the change of the
   2297      * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
   2298      * </p>
   2299      * <p>
   2300      * Changes to the structured name, organization, phone number, email address,
   2301      * or nickname trigger a re-aggregation.
   2302      * </p>
   2303      * <p>
   2304      * See also {@link AggregationExceptions} for a mechanism to control
   2305      * aggregation programmatically.
   2306      * </p>
   2307      *
   2308      * <h3>Operations</h3>
   2309      * <dl>
   2310      * <dt><b>Insert</b></dt>
   2311      * <dd>
   2312      * <p>
   2313      * Raw contacts can be inserted incrementally or in a batch.
   2314      * The incremental method is more traditional but less efficient.
   2315      * It should be used
   2316      * only if no {@link Data} values are available at the time the raw contact is created:
   2317      * <pre>
   2318      * ContentValues values = new ContentValues();
   2319      * values.put(RawContacts.ACCOUNT_TYPE, accountType);
   2320      * values.put(RawContacts.ACCOUNT_NAME, accountName);
   2321      * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
   2322      * long rawContactId = ContentUris.parseId(rawContactUri);
   2323      * </pre>
   2324      * </p>
   2325      * <p>
   2326      * Once {@link Data} values become available, insert those.
   2327      * For example, here's how you would insert a name:
   2328      *
   2329      * <pre>
   2330      * values.clear();
   2331      * values.put(Data.RAW_CONTACT_ID, rawContactId);
   2332      * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
   2333      * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
   2334      * getContentResolver().insert(Data.CONTENT_URI, values);
   2335      * </pre>
   2336      * </p>
   2337      * <p>
   2338      * The batch method is by far preferred.  It inserts the raw contact and its
   2339      * constituent data rows in a single database transaction
   2340      * and causes at most one aggregation pass.
   2341      * <pre>
   2342      * ArrayList&lt;ContentProviderOperation&gt; ops =
   2343      *          new ArrayList&lt;ContentProviderOperation&gt;();
   2344      * ...
   2345      * int rawContactInsertIndex = ops.size();
   2346      * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
   2347      *          .withValue(RawContacts.ACCOUNT_TYPE, accountType)
   2348      *          .withValue(RawContacts.ACCOUNT_NAME, accountName)
   2349      *          .build());
   2350      *
   2351      * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
   2352      *          .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
   2353      *          .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
   2354      *          .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
   2355      *          .build());
   2356      *
   2357      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   2358      * </pre>
   2359      * </p>
   2360      * <p>
   2361      * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
   2362      * to refer to the as-yet-unknown index value of the raw contact inserted in the
   2363      * first operation.
   2364      * </p>
   2365      *
   2366      * <dt><b>Update</b></dt>
   2367      * <dd><p>
   2368      * Raw contacts can be updated incrementally or in a batch.
   2369      * Batch mode should be used whenever possible.
   2370      * The procedures and considerations are analogous to those documented above for inserts.
   2371      * </p></dd>
   2372      * <dt><b>Delete</b></dt>
   2373      * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
   2374      * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
   2375      * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
   2376      * itself is also deleted automatically.
   2377      * </p>
   2378      * <p>
   2379      * The invocation of {@code resolver.delete(...)}, does not immediately delete
   2380      * a raw contacts row.
   2381      * Instead, it sets the {@link #DELETED} flag on the raw contact and
   2382      * removes the raw contact from its aggregate contact.
   2383      * The sync adapter then deletes the raw contact from the server and
   2384      * finalizes phone-side deletion by calling {@code resolver.delete(...)}
   2385      * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
   2386      * <p>Some sync adapters are read-only, meaning that they only sync server-side
   2387      * changes to the phone, but not the reverse.  If one of those raw contacts
   2388      * is marked for deletion, it will remain on the phone.  However it will be
   2389      * effectively invisible, because it will not be part of any aggregate contact.
   2390      * </dd>
   2391      *
   2392      * <dt><b>Query</b></dt>
   2393      * <dd>
   2394      * <p>
   2395      * It is easy to find all raw contacts in a Contact:
   2396      * <pre>
   2397      * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
   2398      *          new String[]{RawContacts._ID},
   2399      *          RawContacts.CONTACT_ID + "=?",
   2400      *          new String[]{String.valueOf(contactId)}, null);
   2401      * </pre>
   2402      * </p>
   2403      * <p>
   2404      * To find raw contacts within a specific account,
   2405      * you can either put the account name and type in the selection or pass them as query
   2406      * parameters.  The latter approach is preferable, especially when you can reuse the
   2407      * URI:
   2408      * <pre>
   2409      * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
   2410      *          .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
   2411      *          .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
   2412      *          .build();
   2413      * Cursor c1 = getContentResolver().query(rawContactUri,
   2414      *          RawContacts.STARRED + "&lt;&gt;0", null, null, null);
   2415      * ...
   2416      * Cursor c2 = getContentResolver().query(rawContactUri,
   2417      *          RawContacts.DELETED + "&lt;&gt;0", null, null, null);
   2418      * </pre>
   2419      * </p>
   2420      * <p>The best way to read a raw contact along with all the data associated with it is
   2421      * by using the {@link Entity} directory. If the raw contact has data rows,
   2422      * the Entity cursor will contain a row for each data row.  If the raw contact has no
   2423      * data rows, the cursor will still contain one row with the raw contact-level information.
   2424      * <pre>
   2425      * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
   2426      * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
   2427      * Cursor c = getContentResolver().query(entityUri,
   2428      *          new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
   2429      *          null, null, null);
   2430      * try {
   2431      *     while (c.moveToNext()) {
   2432      *         String sourceId = c.getString(0);
   2433      *         if (!c.isNull(1)) {
   2434      *             String mimeType = c.getString(2);
   2435      *             String data = c.getString(3);
   2436      *             ...
   2437      *         }
   2438      *     }
   2439      * } finally {
   2440      *     c.close();
   2441      * }
   2442      * </pre>
   2443      * </p>
   2444      * </dd>
   2445      * </dl>
   2446      * <h2>Columns</h2>
   2447      *
   2448      * <table class="jd-sumtable">
   2449      * <tr>
   2450      * <th colspan='4'>RawContacts</th>
   2451      * </tr>
   2452      * <tr>
   2453      * <td>long</td>
   2454      * <td>{@link #_ID}</td>
   2455      * <td>read-only</td>
   2456      * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
   2457      * it is much better for a sync adapter to update a raw contact rather than to delete and
   2458      * re-insert it.</td>
   2459      * </tr>
   2460      * <tr>
   2461      * <td>long</td>
   2462      * <td>{@link #CONTACT_ID}</td>
   2463      * <td>read-only</td>
   2464      * <td>The ID of the row in the {@link ContactsContract.Contacts} table
   2465      * that this raw contact belongs
   2466      * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
   2467      * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
   2468      * </tr>
   2469      * <tr>
   2470      * <td>int</td>
   2471      * <td>{@link #AGGREGATION_MODE}</td>
   2472      * <td>read/write</td>
   2473      * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
   2474      * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
   2475      * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
   2476      * </tr>
   2477      * <tr>
   2478      * <td>int</td>
   2479      * <td>{@link #DELETED}</td>
   2480      * <td>read/write</td>
   2481      * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
   2482      * for deletion. When {@link android.content.ContentResolver#delete} is
   2483      * called on a raw contact, it is marked for deletion and removed from its
   2484      * aggregate contact. The sync adaptor deletes the raw contact on the server and
   2485      * then calls ContactResolver.delete once more, this time passing the
   2486      * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
   2487      * the data removal.</td>
   2488      * </tr>
   2489      * <tr>
   2490      * <td>int</td>
   2491      * <td>{@link #TIMES_CONTACTED}</td>
   2492      * <td>read/write</td>
   2493      * <td>The number of times the contact has been contacted. To have an effect
   2494      * on the corresponding value of the aggregate contact, this field
   2495      * should be set at the time the raw contact is inserted.
   2496      * After that, this value is typically updated via
   2497      * {@link ContactsContract.Contacts#markAsContacted}.</td>
   2498      * </tr>
   2499      * <tr>
   2500      * <td>long</td>
   2501      * <td>{@link #LAST_TIME_CONTACTED}</td>
   2502      * <td>read/write</td>
   2503      * <td>The timestamp of the last time the contact was contacted. To have an effect
   2504      * on the corresponding value of the aggregate contact, this field
   2505      * should be set at the time the raw contact is inserted.
   2506      * After that, this value is typically updated via
   2507      * {@link ContactsContract.Contacts#markAsContacted}.
   2508      * </td>
   2509      * </tr>
   2510      * <tr>
   2511      * <td>int</td>
   2512      * <td>{@link #STARRED}</td>
   2513      * <td>read/write</td>
   2514      * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
   2515      * Changing this field immediately affects the corresponding aggregate contact:
   2516      * if any raw contacts in that aggregate contact are starred, then the contact
   2517      * itself is marked as starred.</td>
   2518      * </tr>
   2519      * <tr>
   2520      * <td>String</td>
   2521      * <td>{@link #CUSTOM_RINGTONE}</td>
   2522      * <td>read/write</td>
   2523      * <td>A custom ringtone associated with a raw contact. Typically this is the
   2524      * URI returned by an activity launched with the
   2525      * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
   2526      * To have an effect on the corresponding value of the aggregate contact, this field
   2527      * should be set at the time the raw contact is inserted. To set a custom
   2528      * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
   2529      * Contacts.CUSTOM_RINGTONE}
   2530      * instead.</td>
   2531      * </tr>
   2532      * <tr>
   2533      * <td>int</td>
   2534      * <td>{@link #SEND_TO_VOICEMAIL}</td>
   2535      * <td>read/write</td>
   2536      * <td>An indicator of whether calls from this raw contact should be forwarded
   2537      * directly to voice mail ('1') or not ('0'). To have an effect
   2538      * on the corresponding value of the aggregate contact, this field
   2539      * should be set at the time the raw contact is inserted.</td>
   2540      * </tr>
   2541      * <tr>
   2542      * <td>String</td>
   2543      * <td>{@link #ACCOUNT_NAME}</td>
   2544      * <td>read/write-once</td>
   2545      * <td>The name of the account instance to which this row belongs, which when paired with
   2546      * {@link #ACCOUNT_TYPE} identifies a specific account.
   2547      * For example, this will be the Gmail address if it is a Google account.
   2548      * It should be set at the time the raw contact is inserted and never
   2549      * changed afterwards.</td>
   2550      * </tr>
   2551      * <tr>
   2552      * <td>String</td>
   2553      * <td>{@link #ACCOUNT_TYPE}</td>
   2554      * <td>read/write-once</td>
   2555      * <td>
   2556      * <p>
   2557      * The type of account to which this row belongs, which when paired with
   2558      * {@link #ACCOUNT_NAME} identifies a specific account.
   2559      * It should be set at the time the raw contact is inserted and never
   2560      * changed afterwards.
   2561      * </p>
   2562      * <p>
   2563      * To ensure uniqueness, new account types should be chosen according to the
   2564      * Java package naming convention.  Thus a Google account is of type "com.google".
   2565      * </p>
   2566      * </td>
   2567      * </tr>
   2568      * <tr>
   2569      * <td>String</td>
   2570      * <td>{@link #DATA_SET}</td>
   2571      * <td>read/write-once</td>
   2572      * <td>
   2573      * <p>
   2574      * The data set within the account that this row belongs to.  This allows
   2575      * multiple sync adapters for the same account type to distinguish between
   2576      * each others' data.  The combination of {@link #ACCOUNT_TYPE},
   2577      * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
   2578      * that is associated with a single sync adapter.
   2579      * </p>
   2580      * <p>
   2581      * This is empty by default, and is completely optional.  It only needs to
   2582      * be populated if multiple sync adapters are entering distinct data for
   2583      * the same account type and account name.
   2584      * </p>
   2585      * <p>
   2586      * It should be set at the time the raw contact is inserted and never
   2587      * changed afterwards.
   2588      * </p>
   2589      * </td>
   2590      * </tr>
   2591      * <tr>
   2592      * <td>String</td>
   2593      * <td>{@link #SOURCE_ID}</td>
   2594      * <td>read/write</td>
   2595      * <td>String that uniquely identifies this row to its source account.
   2596      * Typically it is set at the time the raw contact is inserted and never
   2597      * changed afterwards. The one notable exception is a new raw contact: it
   2598      * will have an account name and type (and possibly a data set), but no
   2599      * source id. This indicates to the sync adapter that a new contact needs
   2600      * to be created server-side and its ID stored in the corresponding
   2601      * SOURCE_ID field on the phone.
   2602      * </td>
   2603      * </tr>
   2604      * <tr>
   2605      * <td>int</td>
   2606      * <td>{@link #VERSION}</td>
   2607      * <td>read-only</td>
   2608      * <td>Version number that is updated whenever this row or its related data
   2609      * changes. This field can be used for optimistic locking of a raw contact.
   2610      * </td>
   2611      * </tr>
   2612      * <tr>
   2613      * <td>int</td>
   2614      * <td>{@link #DIRTY}</td>
   2615      * <td>read/write</td>
   2616      * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
   2617      * to be synchronized by its owning account.  The value is set to "1" automatically
   2618      * whenever the raw contact changes, unless the URI has the
   2619      * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
   2620      * The sync adapter should always supply this query parameter to prevent
   2621      * unnecessary synchronization: user changes some data on the server,
   2622      * the sync adapter updates the contact on the phone (without the
   2623      * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
   2624      * which triggers a sync to bring the changes to the server.
   2625      * </td>
   2626      * </tr>
   2627      * <tr>
   2628      * <td>String</td>
   2629      * <td>{@link #SYNC1}</td>
   2630      * <td>read/write</td>
   2631      * <td>Generic column provided for arbitrary use by sync adapters.
   2632      * The content provider
   2633      * stores this information on behalf of the sync adapter but does not
   2634      * interpret it in any way.
   2635      * </td>
   2636      * </tr>
   2637      * <tr>
   2638      * <td>String</td>
   2639      * <td>{@link #SYNC2}</td>
   2640      * <td>read/write</td>
   2641      * <td>Generic column for use by sync adapters.
   2642      * </td>
   2643      * </tr>
   2644      * <tr>
   2645      * <td>String</td>
   2646      * <td>{@link #SYNC3}</td>
   2647      * <td>read/write</td>
   2648      * <td>Generic column for use by sync adapters.
   2649      * </td>
   2650      * </tr>
   2651      * <tr>
   2652      * <td>String</td>
   2653      * <td>{@link #SYNC4}</td>
   2654      * <td>read/write</td>
   2655      * <td>Generic column for use by sync adapters.
   2656      * </td>
   2657      * </tr>
   2658      * </table>
   2659      */
   2660     public static final class RawContacts implements BaseColumns, RawContactsColumns,
   2661             ContactOptionsColumns, ContactNameColumns, SyncColumns  {
   2662         /**
   2663          * This utility class cannot be instantiated
   2664          */
   2665         private RawContacts() {
   2666         }
   2667 
   2668         /**
   2669          * The content:// style URI for this table, which requests a directory of
   2670          * raw contact rows matching the selection criteria.
   2671          */
   2672         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
   2673 
   2674         /**
   2675          * The MIME type of the results from {@link #CONTENT_URI} when a specific
   2676          * ID value is not provided, and multiple raw contacts may be returned.
   2677          */
   2678         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
   2679 
   2680         /**
   2681          * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
   2682          * yielding a subdirectory of a single person.
   2683          */
   2684         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
   2685 
   2686         /**
   2687          * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
   2688          */
   2689         public static final int AGGREGATION_MODE_DEFAULT = 0;
   2690 
   2691         /**
   2692          * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
   2693          * @deprecated Aggregation is synchronous, this historic value is a no-op
   2694          */
   2695         @Deprecated
   2696         public static final int AGGREGATION_MODE_IMMEDIATE = 1;
   2697 
   2698         /**
   2699          * <p>
   2700          * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
   2701          * Changes to the raw contact will update the associated aggregate contact but will not
   2702          * result in any change in how the contact is aggregated. Similar to
   2703          * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
   2704          * {@link Contacts} aggregate.
   2705          * </p>
   2706          * <p>
   2707          * This can be used to postpone aggregation until after a series of updates, for better
   2708          * performance and/or user experience.
   2709          * </p>
   2710          * <p>
   2711          * Note that changing
   2712          * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
   2713          * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
   2714          * subsequent
   2715          * change to the raw contact's data will.
   2716          * </p>
   2717          */
   2718         public static final int AGGREGATION_MODE_SUSPENDED = 2;
   2719 
   2720         /**
   2721          * <p>
   2722          * Aggregation mode: never aggregate this raw contact.  The raw contact will not
   2723          * have a corresponding {@link Contacts} aggregate and therefore will not be included in
   2724          * {@link Contacts} query results.
   2725          * </p>
   2726          * <p>
   2727          * For example, this mode can be used for a raw contact that is marked for deletion while
   2728          * waiting for the deletion to occur on the server side.
   2729          * </p>
   2730          *
   2731          * @see #AGGREGATION_MODE_SUSPENDED
   2732          */
   2733         public static final int AGGREGATION_MODE_DISABLED = 3;
   2734 
   2735         /**
   2736          * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
   2737          * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
   2738          * entry of the given {@link RawContacts} entry.
   2739          */
   2740         public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
   2741             // TODO: use a lighter query by joining rawcontacts with contacts in provider
   2742             final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
   2743             final Cursor cursor = resolver.query(dataUri, new String[] {
   2744                     RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
   2745             }, null, null, null);
   2746 
   2747             Uri lookupUri = null;
   2748             try {
   2749                 if (cursor != null && cursor.moveToFirst()) {
   2750                     final long contactId = cursor.getLong(0);
   2751                     final String lookupKey = cursor.getString(1);
   2752                     return Contacts.getLookupUri(contactId, lookupKey);
   2753                 }
   2754             } finally {
   2755                 if (cursor != null) cursor.close();
   2756             }
   2757             return lookupUri;
   2758         }
   2759 
   2760         /**
   2761          * A sub-directory of a single raw contact that contains all of its
   2762          * {@link ContactsContract.Data} rows. To access this directory
   2763          * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI.
   2764          */
   2765         public static final class Data implements BaseColumns, DataColumns {
   2766             /**
   2767              * no public constructor since this is a utility class
   2768              */
   2769             private Data() {
   2770             }
   2771 
   2772             /**
   2773              * The directory twig for this sub-table
   2774              */
   2775             public static final String CONTENT_DIRECTORY = "data";
   2776         }
   2777 
   2778         /**
   2779          * <p>
   2780          * A sub-directory of a single raw contact that contains all of its
   2781          * {@link ContactsContract.Data} rows. To access this directory append
   2782          * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See
   2783          * {@link RawContactsEntity} for a stand-alone table containing the same
   2784          * data.
   2785          * </p>
   2786          * <p>
   2787          * Entity has two ID fields: {@link #_ID} for the raw contact
   2788          * and {@link #DATA_ID} for the data rows.
   2789          * Entity always contains at least one row, even if there are no
   2790          * actual data rows. In this case the {@link #DATA_ID} field will be
   2791          * null.
   2792          * </p>
   2793          * <p>
   2794          * Using Entity should be preferred to using two separate queries:
   2795          * RawContacts followed by Data. The reason is that Entity reads all
   2796          * data for a raw contact in one transaction, so there is no possibility
   2797          * of the data changing between the two queries.
   2798          */
   2799         public static final class Entity implements BaseColumns, DataColumns {
   2800             /**
   2801              * no public constructor since this is a utility class
   2802              */
   2803             private Entity() {
   2804             }
   2805 
   2806             /**
   2807              * The directory twig for this sub-table
   2808              */
   2809             public static final String CONTENT_DIRECTORY = "entity";
   2810 
   2811             /**
   2812              * The ID of the data row. The value will be null if this raw contact has no
   2813              * data rows.
   2814              * <P>Type: INTEGER</P>
   2815              */
   2816             public static final String DATA_ID = "data_id";
   2817         }
   2818 
   2819         /**
   2820          * <p>
   2821          * A sub-directory of a single raw contact that contains all of its
   2822          * {@link ContactsContract.StreamItems} rows. To access this directory append
   2823          * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See
   2824          * {@link ContactsContract.StreamItems} for a stand-alone table containing the
   2825          * same data.
   2826          * </p>
   2827          * <p>
   2828          * Access to the social stream through this sub-directory requires additional permissions
   2829          * beyond the read/write contact permissions required by the provider.  Querying for
   2830          * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and
   2831          * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM
   2832          * permission.
   2833          * </p>
   2834          *
   2835          * @deprecated - Do not use. This will not be supported in the future. In the future,
   2836          * cursors returned from related queries will be empty.
   2837          *
   2838          * @hide
   2839          * @removed
   2840          */
   2841         @Deprecated
   2842         public static final class StreamItems implements BaseColumns, StreamItemsColumns {
   2843             /**
   2844              * No public constructor since this is a utility class
   2845              *
   2846              * @deprecated - Do not use. This will not be supported in the future. In the future,
   2847              * cursors returned from related queries will be empty.
   2848              */
   2849             @Deprecated
   2850             private StreamItems() {
   2851             }
   2852 
   2853             /**
   2854              * The directory twig for this sub-table
   2855              *
   2856              * @deprecated - Do not use. This will not be supported in the future. In the future,
   2857              * cursors returned from related queries will be empty.
   2858              */
   2859             @Deprecated
   2860             public static final String CONTENT_DIRECTORY = "stream_items";
   2861         }
   2862 
   2863         /**
   2864          * <p>
   2865          * A sub-directory of a single raw contact that represents its primary
   2866          * display photo.  To access this directory append
   2867          * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI.
   2868          * The resulting URI represents an image file, and should be interacted with
   2869          * using ContentResolver.openAssetFileDescriptor.
   2870          * <p>
   2871          * <p>
   2872          * Note that this sub-directory also supports opening the photo as an asset file
   2873          * in write mode.  Callers can create or replace the primary photo associated
   2874          * with this raw contact by opening the asset file and writing the full-size
   2875          * photo contents into it.  When the file is closed, the image will be parsed,
   2876          * sized down if necessary for the full-size display photo and thumbnail
   2877          * dimensions, and stored.
   2878          * </p>
   2879          * <p>
   2880          * Usage example:
   2881          * <pre>
   2882          * public void writeDisplayPhoto(long rawContactId, byte[] photo) {
   2883          *     Uri rawContactPhotoUri = Uri.withAppendedPath(
   2884          *             ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
   2885          *             RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
   2886          *     try {
   2887          *         AssetFileDescriptor fd =
   2888          *             getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw");
   2889          *         OutputStream os = fd.createOutputStream();
   2890          *         os.write(photo);
   2891          *         os.close();
   2892          *         fd.close();
   2893          *     } catch (IOException e) {
   2894          *         // Handle error cases.
   2895          *     }
   2896          * }
   2897          * </pre>
   2898          * </p>
   2899          */
   2900         public static final class DisplayPhoto {
   2901             /**
   2902              * No public constructor since this is a utility class
   2903              */
   2904             private DisplayPhoto() {
   2905             }
   2906 
   2907             /**
   2908              * The directory twig for this sub-table
   2909              */
   2910             public static final String CONTENT_DIRECTORY = "display_photo";
   2911         }
   2912 
   2913         /**
   2914          * TODO: javadoc
   2915          * @param cursor
   2916          * @return
   2917          */
   2918         public static EntityIterator newEntityIterator(Cursor cursor) {
   2919             return new EntityIteratorImpl(cursor);
   2920         }
   2921 
   2922         private static class EntityIteratorImpl extends CursorEntityIterator {
   2923             private static final String[] DATA_KEYS = new String[]{
   2924                     Data.DATA1,
   2925                     Data.DATA2,
   2926                     Data.DATA3,
   2927                     Data.DATA4,
   2928                     Data.DATA5,
   2929                     Data.DATA6,
   2930                     Data.DATA7,
   2931                     Data.DATA8,
   2932                     Data.DATA9,
   2933                     Data.DATA10,
   2934                     Data.DATA11,
   2935                     Data.DATA12,
   2936                     Data.DATA13,
   2937                     Data.DATA14,
   2938                     Data.DATA15,
   2939                     Data.SYNC1,
   2940                     Data.SYNC2,
   2941                     Data.SYNC3,
   2942                     Data.SYNC4};
   2943 
   2944             public EntityIteratorImpl(Cursor cursor) {
   2945                 super(cursor);
   2946             }
   2947 
   2948             @Override
   2949             public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
   2950                     throws RemoteException {
   2951                 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
   2952                 final long rawContactId = cursor.getLong(columnRawContactId);
   2953 
   2954                 // we expect the cursor is already at the row we need to read from
   2955                 ContentValues cv = new ContentValues();
   2956                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
   2957                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
   2958                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET);
   2959                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
   2960                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
   2961                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
   2962                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
   2963                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
   2964                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
   2965                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
   2966                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
   2967                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
   2968                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
   2969                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
   2970                 android.content.Entity contact = new android.content.Entity(cv);
   2971 
   2972                 // read data rows until the contact id changes
   2973                 do {
   2974                     if (rawContactId != cursor.getLong(columnRawContactId)) {
   2975                         break;
   2976                     }
   2977                     // add the data to to the contact
   2978                     cv = new ContentValues();
   2979                     cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
   2980                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
   2981                             Data.RES_PACKAGE);
   2982                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
   2983                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
   2984                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
   2985                             Data.IS_SUPER_PRIMARY);
   2986                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
   2987                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
   2988                             CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
   2989                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
   2990                             Data.DATA_VERSION);
   2991                     for (String key : DATA_KEYS) {
   2992                         final int columnIndex = cursor.getColumnIndexOrThrow(key);
   2993                         switch (cursor.getType(columnIndex)) {
   2994                             case Cursor.FIELD_TYPE_NULL:
   2995                                 // don't put anything
   2996                                 break;
   2997                             case Cursor.FIELD_TYPE_INTEGER:
   2998                             case Cursor.FIELD_TYPE_FLOAT:
   2999                             case Cursor.FIELD_TYPE_STRING:
   3000                                 cv.put(key, cursor.getString(columnIndex));
   3001                                 break;
   3002                             case Cursor.FIELD_TYPE_BLOB:
   3003                                 cv.put(key, cursor.getBlob(columnIndex));
   3004                                 break;
   3005                             default:
   3006                                 throw new IllegalStateException("Invalid or unhandled data type");
   3007                         }
   3008                     }
   3009                     contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
   3010                 } while (cursor.moveToNext());
   3011 
   3012                 return contact;
   3013             }
   3014 
   3015         }
   3016     }
   3017 
   3018     /**
   3019      * Social status update columns.
   3020      *
   3021      * @see StatusUpdates
   3022      * @see ContactsContract.Data
   3023      */
   3024     protected interface StatusColumns {
   3025         /**
   3026          * Contact's latest presence level.
   3027          * <P>Type: INTEGER (one of the values below)</P>
   3028          */
   3029         public static final String PRESENCE = "mode";
   3030 
   3031         /**
   3032          * @deprecated use {@link #PRESENCE}
   3033          */
   3034         @Deprecated
   3035         public static final String PRESENCE_STATUS = PRESENCE;
   3036 
   3037         /**
   3038          * An allowed value of {@link #PRESENCE}.
   3039          */
   3040         int OFFLINE = 0;
   3041 
   3042         /**
   3043          * An allowed value of {@link #PRESENCE}.
   3044          */
   3045         int INVISIBLE = 1;
   3046 
   3047         /**
   3048          * An allowed value of {@link #PRESENCE}.
   3049          */
   3050         int AWAY = 2;
   3051 
   3052         /**
   3053          * An allowed value of {@link #PRESENCE}.
   3054          */
   3055         int IDLE = 3;
   3056 
   3057         /**
   3058          * An allowed value of {@link #PRESENCE}.
   3059          */
   3060         int DO_NOT_DISTURB = 4;
   3061 
   3062         /**
   3063          * An allowed value of {@link #PRESENCE}.
   3064          */
   3065         int AVAILABLE = 5;
   3066 
   3067         /**
   3068          * Contact latest status update.
   3069          * <p>Type: TEXT</p>
   3070          */
   3071         public static final String STATUS = "status";
   3072 
   3073         /**
   3074          * @deprecated use {@link #STATUS}
   3075          */
   3076         @Deprecated
   3077         public static final String PRESENCE_CUSTOM_STATUS = STATUS;
   3078 
   3079         /**
   3080          * The absolute time in milliseconds when the latest status was inserted/updated.
   3081          * <p>Type: NUMBER</p>
   3082          */
   3083         public static final String STATUS_TIMESTAMP = "status_ts";
   3084 
   3085         /**
   3086          * The package containing resources for this status: label and icon.
   3087          * <p>Type: TEXT</p>
   3088          */
   3089         public static final String STATUS_RES_PACKAGE = "status_res_package";
   3090 
   3091         /**
   3092          * The resource ID of the label describing the source of the status update, e.g. "Google
   3093          * Talk".  This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
   3094          * <p>Type: NUMBER</p>
   3095          */
   3096         public static final String STATUS_LABEL = "status_label";
   3097 
   3098         /**
   3099          * The resource ID of the icon for the source of the status update.
   3100          * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
   3101          * <p>Type: NUMBER</p>
   3102          */
   3103         public static final String STATUS_ICON = "status_icon";
   3104 
   3105         /**
   3106          * Contact's audio/video chat capability level.
   3107          * <P>Type: INTEGER (one of the values below)</P>
   3108          */
   3109         public static final String CHAT_CAPABILITY = "chat_capability";
   3110 
   3111         /**
   3112          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone
   3113          * and speaker)
   3114          */
   3115         public static final int CAPABILITY_HAS_VOICE = 1;
   3116 
   3117         /**
   3118          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
   3119          * display a video feed.
   3120          */
   3121         public static final int CAPABILITY_HAS_VIDEO = 2;
   3122 
   3123         /**
   3124          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
   3125          * camera that can be used for video chat (e.g. a front-facing camera on a phone).
   3126          */
   3127         public static final int CAPABILITY_HAS_CAMERA = 4;
   3128     }
   3129 
   3130     /**
   3131      * <p>
   3132      * Constants for the stream_items table, which contains social stream updates from
   3133      * the user's contact list.
   3134      * </p>
   3135      * <p>
   3136      * Only a certain number of stream items will ever be stored under a given raw contact.
   3137      * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to
   3138      * determine this limit, and should restrict the number of items inserted in any given
   3139      * transaction correspondingly.  Insertion of more items beyond the limit will
   3140      * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}.
   3141      * </p>
   3142      * <p>
   3143      * Access to the social stream through these URIs requires additional permissions beyond the
   3144      * read/write contact permissions required by the provider.  Querying for social stream data
   3145      * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social
   3146      * stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
   3147      * </p>
   3148      * <h3>Account check</h3>
   3149      * <p>
   3150      * The content URIs to the insert, update and delete operations are required to have the account
   3151      * information matching that of the owning raw contact as query parameters, namely
   3152      * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
   3153      * {@link RawContacts#DATA_SET} isn't required.
   3154      * </p>
   3155      * <h3>Operations</h3>
   3156      * <dl>
   3157      * <dt><b>Insert</b></dt>
   3158      * <dd>
   3159      * <p>Social stream updates are always associated with a raw contact.  There are a couple
   3160      * of ways to insert these entries.
   3161      * <dl>
   3162      * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt>
   3163      * <dd>
   3164      * <pre>
   3165      * ContentValues values = new ContentValues();
   3166      * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
   3167      * values.put(StreamItems.TIMESTAMP, timestamp);
   3168      * values.put(StreamItems.COMMENTS, "3 people reshared this");
   3169      * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
   3170      * ContentUris.appendId(builder, rawContactId);
   3171      * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY);
   3172      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3173      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3174      * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
   3175      * long streamItemId = ContentUris.parseId(streamItemUri);
   3176      * </pre>
   3177      * </dd>
   3178      * <dt>Via {@link StreamItems#CONTENT_URI}:</dt>
   3179      * <dd>
   3180      *<pre>
   3181      * ContentValues values = new ContentValues();
   3182      * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
   3183      * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
   3184      * values.put(StreamItems.TIMESTAMP, timestamp);
   3185      * values.put(StreamItems.COMMENTS, "3 people reshared this");
   3186      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3187      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3188      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3189      * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
   3190      * long streamItemId = ContentUris.parseId(streamItemUri);
   3191      *</pre>
   3192      * </dd>
   3193      * </dl>
   3194      * </dd>
   3195      * </p>
   3196      * <p>
   3197      * Once a {@link StreamItems} entry has been inserted, photos associated with that
   3198      * social update can be inserted.  For example, after one of the insertions above,
   3199      * photos could be added to the stream item in one of the following ways:
   3200      * <dl>
   3201      * <dt>Via a URI including the stream item ID:</dt>
   3202      * <dd>
   3203      * <pre>
   3204      * values.clear();
   3205      * values.put(StreamItemPhotos.SORT_INDEX, 1);
   3206      * values.put(StreamItemPhotos.PHOTO, photoData);
   3207      * getContentResolver().insert(Uri.withAppendedPath(
   3208      *     ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId),
   3209      *     StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
   3210      * </pre>
   3211      * </dd>
   3212      * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt>
   3213      * <dd>
   3214      * <pre>
   3215      * values.clear();
   3216      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
   3217      * values.put(StreamItemPhotos.SORT_INDEX, 1);
   3218      * values.put(StreamItemPhotos.PHOTO, photoData);
   3219      * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
   3220      * </pre>
   3221      * <p>Note that this latter form allows the insertion of a stream item and its
   3222      * photos in a single transaction, by using {@link ContentProviderOperation} with
   3223      * back references to populate the stream item ID in the {@link ContentValues}.
   3224      * </dd>
   3225      * </dl>
   3226      * </p>
   3227      * </dd>
   3228      * <dt><b>Update</b></dt>
   3229      * <dd>Updates can be performed by appending the stream item ID to the
   3230      * {@link StreamItems#CONTENT_URI} URI.  Only social stream entries that were
   3231      * created by the calling package can be updated.</dd>
   3232      * <dt><b>Delete</b></dt>
   3233      * <dd>Deletes can be performed by appending the stream item ID to the
   3234      * {@link StreamItems#CONTENT_URI} URI.  Only social stream entries that were
   3235      * created by the calling package can be deleted.</dd>
   3236      * <dt><b>Query</b></dt>
   3237      * <dl>
   3238      * <dt>Finding all social stream updates for a given contact</dt>
   3239      * <dd>By Contact ID:
   3240      * <pre>
   3241      * Cursor c = getContentResolver().query(Uri.withAppendedPath(
   3242      *          ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
   3243      *          Contacts.StreamItems.CONTENT_DIRECTORY),
   3244      *          null, null, null, null);
   3245      * </pre>
   3246      * </dd>
   3247      * <dd>By lookup key:
   3248      * <pre>
   3249      * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
   3250      *          .appendPath(lookupKey)
   3251      *          .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
   3252      *          null, null, null, null);
   3253      * </pre>
   3254      * </dd>
   3255      * <dt>Finding all social stream updates for a given raw contact</dt>
   3256      * <dd>
   3257      * <pre>
   3258      * Cursor c = getContentResolver().query(Uri.withAppendedPath(
   3259      *          ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
   3260      *          RawContacts.StreamItems.CONTENT_DIRECTORY)),
   3261      *          null, null, null, null);
   3262      * </pre>
   3263      * </dd>
   3264      * <dt>Querying for a specific stream item by ID</dt>
   3265      * <dd>
   3266      * <pre>
   3267      * Cursor c = getContentResolver().query(ContentUris.withAppendedId(
   3268      *          StreamItems.CONTENT_URI, streamItemId),
   3269      *          null, null, null, null);
   3270      * </pre>
   3271      * </dd>
   3272      * </dl>
   3273      *
   3274      * @deprecated - Do not use. This will not be supported in the future. In the future,
   3275      * cursors returned from related queries will be empty.
   3276      *
   3277      * @hide
   3278      * @removed
   3279      */
   3280     @Deprecated
   3281     public static final class StreamItems implements BaseColumns, StreamItemsColumns {
   3282         /**
   3283          * This utility class cannot be instantiated
   3284          *
   3285          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3286          * cursors returned from related queries will be empty.
   3287          */
   3288         @Deprecated
   3289         private StreamItems() {
   3290         }
   3291 
   3292         /**
   3293          * The content:// style URI for this table, which handles social network stream
   3294          * updates for the user's contacts.
   3295          *
   3296          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3297          * cursors returned from related queries will be empty.
   3298          */
   3299         @Deprecated
   3300         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items");
   3301 
   3302         /**
   3303          * <p>
   3304          * A content:// style URI for the photos stored in a sub-table underneath
   3305          * stream items.  This is only used for inserts, and updates - queries and deletes
   3306          * for photos should be performed by appending
   3307          * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a
   3308          * specific stream item.
   3309          * </p>
   3310          * <p>
   3311          * When using this URI, the stream item ID for the photo(s) must be identified
   3312          * in the {@link ContentValues} passed in.
   3313          * </p>
   3314          *
   3315          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3316          * cursors returned from related queries will be empty.
   3317          */
   3318         @Deprecated
   3319         public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo");
   3320 
   3321         /**
   3322          * This URI allows the caller to query for the maximum number of stream items
   3323          * that will be stored under any single raw contact.
   3324          *
   3325          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3326          * cursors returned from related queries will be empty.
   3327          */
   3328         @Deprecated
   3329         public static final Uri CONTENT_LIMIT_URI =
   3330                 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
   3331 
   3332         /**
   3333          * The MIME type of a directory of stream items.
   3334          *
   3335          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3336          * cursors returned from related queries will be empty.
   3337          */
   3338         @Deprecated
   3339         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item";
   3340 
   3341         /**
   3342          * The MIME type of a single stream item.
   3343          *
   3344          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3345          * cursors returned from related queries will be empty.
   3346          */
   3347         @Deprecated
   3348         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item";
   3349 
   3350         /**
   3351          * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
   3352          * contain this column, with the value indicating the maximum number of
   3353          * stream items that will be stored under any single raw contact.
   3354          *
   3355          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3356          * cursors returned from related queries will be empty.
   3357          */
   3358         @Deprecated
   3359         public static final String MAX_ITEMS = "max_items";
   3360 
   3361         /**
   3362          * <p>
   3363          * A sub-directory of a single stream item entry that contains all of its
   3364          * photo rows. To access this
   3365          * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to
   3366          * an individual stream item URI.
   3367          * </p>
   3368          * <p>
   3369          * Access to social stream photos requires additional permissions beyond the read/write
   3370          * contact permissions required by the provider.  Querying for social stream photos
   3371          * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
   3372          * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
   3373          * </p>
   3374          *
   3375          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3376          * cursors returned from related queries will be empty.
   3377          *
   3378          * @hide
   3379          * @removed
   3380          */
   3381         @Deprecated
   3382         public static final class StreamItemPhotos
   3383                 implements BaseColumns, StreamItemPhotosColumns {
   3384             /**
   3385              * No public constructor since this is a utility class
   3386              *
   3387              * @deprecated - Do not use. This will not be supported in the future. In the future,
   3388              * cursors returned from related queries will be empty.
   3389              */
   3390             @Deprecated
   3391             private StreamItemPhotos() {
   3392             }
   3393 
   3394             /**
   3395              * The directory twig for this sub-table
   3396              *
   3397              * @deprecated - Do not use. This will not be supported in the future. In the future,
   3398              * cursors returned from related queries will be empty.
   3399              */
   3400             @Deprecated
   3401             public static final String CONTENT_DIRECTORY = "photo";
   3402 
   3403             /**
   3404              * The MIME type of a directory of stream item photos.
   3405              *
   3406              * @deprecated - Do not use. This will not be supported in the future. In the future,
   3407              * cursors returned from related queries will be empty.
   3408              */
   3409             @Deprecated
   3410             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo";
   3411 
   3412             /**
   3413              * The MIME type of a single stream item photo.
   3414              *
   3415              * @deprecated - Do not use. This will not be supported in the future. In the future,
   3416              * cursors returned from related queries will be empty.
   3417              */
   3418             @Deprecated
   3419             public static final String CONTENT_ITEM_TYPE
   3420                     = "vnd.android.cursor.item/stream_item_photo";
   3421         }
   3422     }
   3423 
   3424     /**
   3425      * Columns in the StreamItems table.
   3426      *
   3427      * @see ContactsContract.StreamItems
   3428      * @deprecated - Do not use. This will not be supported in the future. In the future,
   3429      * cursors returned from related queries will be empty.
   3430      *
   3431      * @hide
   3432      * @removed
   3433      */
   3434     @Deprecated
   3435     protected interface StreamItemsColumns {
   3436         /**
   3437          * A reference to the {@link android.provider.ContactsContract.Contacts#_ID}
   3438          * that this stream item belongs to.
   3439          *
   3440          * <p>Type: INTEGER</p>
   3441          * <p>read-only</p>
   3442          *
   3443          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3444          * cursors returned from related queries will be empty.
   3445          */
   3446         @Deprecated
   3447         public static final String CONTACT_ID = "contact_id";
   3448 
   3449         /**
   3450          * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY}
   3451          * that this stream item belongs to.
   3452          *
   3453          * <p>Type: TEXT</p>
   3454          * <p>read-only</p>
   3455          *
   3456          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3457          * cursors returned from related queries will be empty.
   3458          */
   3459         @Deprecated
   3460         public static final String CONTACT_LOOKUP_KEY = "contact_lookup";
   3461 
   3462         /**
   3463          * A reference to the {@link RawContacts#_ID}
   3464          * that this stream item belongs to.
   3465          * <p>Type: INTEGER</p>
   3466          *
   3467          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3468          * cursors returned from related queries will be empty.
   3469          */
   3470         @Deprecated
   3471         public static final String RAW_CONTACT_ID = "raw_contact_id";
   3472 
   3473         /**
   3474          * The package name to use when creating {@link Resources} objects for
   3475          * this stream item. This value is only designed for use when building
   3476          * user interfaces, and should not be used to infer the owner.
   3477          * <P>Type: TEXT</P>
   3478          *
   3479          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3480          * cursors returned from related queries will be empty.
   3481          */
   3482         @Deprecated
   3483         public static final String RES_PACKAGE = "res_package";
   3484 
   3485         /**
   3486          * The account type to which the raw_contact of this item is associated. See
   3487          * {@link RawContacts#ACCOUNT_TYPE}
   3488          *
   3489          * <p>Type: TEXT</p>
   3490          * <p>read-only</p>
   3491          *
   3492          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3493          * cursors returned from related queries will be empty.
   3494          */
   3495         @Deprecated
   3496         public static final String ACCOUNT_TYPE = "account_type";
   3497 
   3498         /**
   3499          * The account name to which the raw_contact of this item is associated. See
   3500          * {@link RawContacts#ACCOUNT_NAME}
   3501          *
   3502          * <p>Type: TEXT</p>
   3503          * <p>read-only</p>
   3504          *
   3505          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3506          * cursors returned from related queries will be empty.
   3507          */
   3508         @Deprecated
   3509         public static final String ACCOUNT_NAME = "account_name";
   3510 
   3511         /**
   3512          * The data set within the account that the raw_contact of this row belongs to. This allows
   3513          * multiple sync adapters for the same account type to distinguish between
   3514          * each others' data.
   3515          * {@link RawContacts#DATA_SET}
   3516          *
   3517          * <P>Type: TEXT</P>
   3518          * <p>read-only</p>
   3519          *
   3520          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3521          * cursors returned from related queries will be empty.
   3522          */
   3523         @Deprecated
   3524         public static final String DATA_SET = "data_set";
   3525 
   3526         /**
   3527          * The source_id of the raw_contact that this row belongs to.
   3528          * {@link RawContacts#SOURCE_ID}
   3529          *
   3530          * <P>Type: TEXT</P>
   3531          * <p>read-only</p>
   3532          *
   3533          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3534          * cursors returned from related queries will be empty.
   3535          */
   3536         @Deprecated
   3537         public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id";
   3538 
   3539         /**
   3540          * The resource name of the icon for the source of the stream item.
   3541          * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference
   3542          * drawables, the "@drawable/" prefix must be omitted.
   3543          * <P>Type: TEXT</P>
   3544          *
   3545          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3546          * cursors returned from related queries will be empty.
   3547          */
   3548         @Deprecated
   3549         public static final String RES_ICON = "icon";
   3550 
   3551         /**
   3552          * The resource name of the label describing the source of the status update, e.g. "Google
   3553          * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only
   3554          * reference strings, the "@string/" prefix must be omitted.
   3555          * <p>Type: TEXT</p>
   3556          *
   3557          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3558          * cursors returned from related queries will be empty.
   3559          */
   3560         @Deprecated
   3561         public static final String RES_LABEL = "label";
   3562 
   3563         /**
   3564          * <P>
   3565          * The main textual contents of the item. Typically this is content
   3566          * that was posted by the source of this stream item, but it can also
   3567          * be a textual representation of an action (e.g. Checked in at Joe's).
   3568          * This text is displayed to the user and allows formatting and embedded
   3569          * resource images via HTML (as parseable via
   3570          * {@link android.text.Html#fromHtml}).
   3571          * </P>
   3572          * <P>
   3573          * Long content may be truncated and/or ellipsized - the exact behavior
   3574          * is unspecified, but it should not break tags.
   3575          * </P>
   3576          * <P>Type: TEXT</P>
   3577          *
   3578          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3579          * cursors returned from related queries will be empty.
   3580          */
   3581         @Deprecated
   3582         public static final String TEXT = "text";
   3583 
   3584         /**
   3585          * The absolute time (milliseconds since epoch) when this stream item was
   3586          * inserted/updated.
   3587          * <P>Type: NUMBER</P>
   3588          *
   3589          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3590          * cursors returned from related queries will be empty.
   3591          */
   3592         @Deprecated
   3593         public static final String TIMESTAMP = "timestamp";
   3594 
   3595         /**
   3596          * <P>
   3597          * Summary information about the stream item, for example to indicate how
   3598          * many people have reshared it, how many have liked it, how many thumbs
   3599          * up and/or thumbs down it has, what the original source was, etc.
   3600          * </P>
   3601          * <P>
   3602          * This text is displayed to the user and allows simple formatting via
   3603          * HTML, in the same manner as {@link #TEXT} allows.
   3604          * </P>
   3605          * <P>
   3606          * Long content may be truncated and/or ellipsized - the exact behavior
   3607          * is unspecified, but it should not break tags.
   3608          * </P>
   3609          * <P>Type: TEXT</P>
   3610          *
   3611          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3612          * cursors returned from related queries will be empty.
   3613          */
   3614         @Deprecated
   3615         public static final String COMMENTS = "comments";
   3616 
   3617         /**
   3618          * Generic column for use by sync adapters.
   3619          *
   3620          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3621          * cursors returned from related queries will be empty.
   3622          */
   3623         @Deprecated
   3624         public static final String SYNC1 = "stream_item_sync1";
   3625         /**
   3626          * Generic column for use by sync adapters.
   3627          *
   3628          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3629          * cursors returned from related queries will be empty.
   3630          */
   3631         @Deprecated
   3632         public static final String SYNC2 = "stream_item_sync2";
   3633         /**
   3634          * Generic column for use by sync adapters.
   3635          *
   3636          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3637          * cursors returned from related queries will be empty.
   3638          */
   3639         @Deprecated
   3640         public static final String SYNC3 = "stream_item_sync3";
   3641         /**
   3642          * Generic column for use by sync adapters.
   3643          *
   3644          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3645          * cursors returned from related queries will be empty.
   3646          */
   3647         @Deprecated
   3648         public static final String SYNC4 = "stream_item_sync4";
   3649     }
   3650 
   3651     /**
   3652      * <p>
   3653      * Constants for the stream_item_photos table, which contains photos associated with
   3654      * social stream updates.
   3655      * </p>
   3656      * <p>
   3657      * Access to social stream photos requires additional permissions beyond the read/write
   3658      * contact permissions required by the provider.  Querying for social stream photos
   3659      * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
   3660      * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
   3661      * </p>
   3662      * <h3>Account check</h3>
   3663      * <p>
   3664      * The content URIs to the insert, update and delete operations are required to have the account
   3665      * information matching that of the owning raw contact as query parameters, namely
   3666      * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
   3667      * {@link RawContacts#DATA_SET} isn't required.
   3668      * </p>
   3669      * <h3>Operations</h3>
   3670      * <dl>
   3671      * <dt><b>Insert</b></dt>
   3672      * <dd>
   3673      * <p>Social stream photo entries are associated with a social stream item.  Photos
   3674      * can be inserted into a social stream item in a couple of ways:
   3675      * <dl>
   3676      * <dt>
   3677      * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
   3678      * stream item:
   3679      * </dt>
   3680      * <dd>
   3681      * <pre>
   3682      * ContentValues values = new ContentValues();
   3683      * values.put(StreamItemPhotos.SORT_INDEX, 1);
   3684      * values.put(StreamItemPhotos.PHOTO, photoData);
   3685      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3686      * ContentUris.appendId(builder, streamItemId);
   3687      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
   3688      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3689      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3690      * Uri photoUri = getContentResolver().insert(builder.build(), values);
   3691      * long photoId = ContentUris.parseId(photoUri);
   3692      * </pre>
   3693      * </dd>
   3694      * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
   3695      * <dd>
   3696      * <pre>
   3697      * ContentValues values = new ContentValues();
   3698      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
   3699      * values.put(StreamItemPhotos.SORT_INDEX, 1);
   3700      * values.put(StreamItemPhotos.PHOTO, photoData);
   3701      * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
   3702      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3703      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3704      * Uri photoUri = getContentResolver().insert(builder.build(), values);
   3705      * long photoId = ContentUris.parseId(photoUri);
   3706      * </pre>
   3707      * </dd>
   3708      * </dl>
   3709      * </p>
   3710      * </dd>
   3711      * <dt><b>Update</b></dt>
   3712      * <dd>
   3713      * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry,
   3714      * identified by both the stream item ID it belongs to and the stream item photo ID.
   3715      * This can be specified in two ways.
   3716      * <dl>
   3717      * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
   3718      * stream item:
   3719      * </dt>
   3720      * <dd>
   3721      * <pre>
   3722      * ContentValues values = new ContentValues();
   3723      * values.put(StreamItemPhotos.PHOTO, newPhotoData);
   3724      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3725      * ContentUris.appendId(builder, streamItemId);
   3726      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
   3727      * ContentUris.appendId(builder, streamItemPhotoId);
   3728      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3729      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3730      * getContentResolver().update(builder.build(), values, null, null);
   3731      * </pre>
   3732      * </dd>
   3733      * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
   3734      * <dd>
   3735      * <pre>
   3736      * ContentValues values = new ContentValues();
   3737      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
   3738      * values.put(StreamItemPhotos.PHOTO, newPhotoData);
   3739      * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
   3740      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3741      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3742      * getContentResolver().update(builder.build(), values);
   3743      * </pre>
   3744      * </dd>
   3745      * </dl>
   3746      * </p>
   3747      * </dd>
   3748      * <dt><b>Delete</b></dt>
   3749      * <dd>Deletes can be made against either a specific photo item in a stream item, or
   3750      * against all or a selected subset of photo items under a stream item.
   3751      * For example:
   3752      * <dl>
   3753      * <dt>Deleting a single photo via the
   3754      * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item:
   3755      * </dt>
   3756      * <dd>
   3757      * <pre>
   3758      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3759      * ContentUris.appendId(builder, streamItemId);
   3760      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
   3761      * ContentUris.appendId(builder, streamItemPhotoId);
   3762      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3763      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3764      * getContentResolver().delete(builder.build(), null, null);
   3765      * </pre>
   3766      * </dd>
   3767      * <dt>Deleting all photos under a stream item</dt>
   3768      * <dd>
   3769      * <pre>
   3770      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3771      * ContentUris.appendId(builder, streamItemId);
   3772      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
   3773      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3774      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3775      * getContentResolver().delete(builder.build(), null, null);
   3776      * </pre>
   3777      * </dd>
   3778      * </dl>
   3779      * </dd>
   3780      * <dt><b>Query</b></dt>
   3781      * <dl>
   3782      * <dt>Querying for a specific photo in a stream item</dt>
   3783      * <dd>
   3784      * <pre>
   3785      * Cursor c = getContentResolver().query(
   3786      *     ContentUris.withAppendedId(
   3787      *         Uri.withAppendedPath(
   3788      *             ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
   3789      *             StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
   3790      *         streamItemPhotoId), null, null, null, null);
   3791      * </pre>
   3792      * </dd>
   3793      * <dt>Querying for all photos in a stream item</dt>
   3794      * <dd>
   3795      * <pre>
   3796      * Cursor c = getContentResolver().query(
   3797      *     Uri.withAppendedPath(
   3798      *         ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
   3799      *         StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
   3800      *     null, null, null, StreamItemPhotos.SORT_INDEX);
   3801      * </pre>
   3802      * </dl>
   3803      * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a
   3804      * {@link StreamItemPhotos#PHOTO_URI}.  The {@link StreamItemPhotos#PHOTO_FILE_ID}
   3805      * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to
   3806      * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as
   3807      * an asset file, as follows:
   3808      * <pre>
   3809      * public InputStream openDisplayPhoto(String photoUri) {
   3810      *     try {
   3811      *         AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
   3812      *         return fd.createInputStream();
   3813      *     } catch (IOException e) {
   3814      *         return null;
   3815      *     }
   3816      * }
   3817      * <pre>
   3818      * </dd>
   3819      * </dl>
   3820      *
   3821      * @deprecated - Do not use. This will not be supported in the future. In the future,
   3822      * cursors returned from related queries will be empty.
   3823      *
   3824      * @hide
   3825      * @removed
   3826      */
   3827     @Deprecated
   3828     public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns {
   3829         /**
   3830          * No public constructor since this is a utility class
   3831          *
   3832          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3833          * cursors returned from related queries will be empty.
   3834          */
   3835         @Deprecated
   3836         private StreamItemPhotos() {
   3837         }
   3838 
   3839         /**
   3840          * <p>
   3841          * The binary representation of the photo.  Any size photo can be inserted;
   3842          * the provider will resize it appropriately for storage and display.
   3843          * </p>
   3844          * <p>
   3845          * This is only intended for use when inserting or updating a stream item photo.
   3846          * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI}
   3847          * as an asset file.
   3848          * </p>
   3849          * <P>Type: BLOB</P>
   3850          *
   3851          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3852          * cursors returned from related queries will be empty.
   3853          */
   3854         @Deprecated
   3855         public static final String PHOTO = "photo";
   3856     }
   3857 
   3858     /**
   3859      * Columns in the StreamItemPhotos table.
   3860      *
   3861      * @see ContactsContract.StreamItemPhotos
   3862      * @deprecated - Do not use. This will not be supported in the future. In the future,
   3863      * cursors returned from related queries will be empty.
   3864      *
   3865      * @hide
   3866      * @removed
   3867      */
   3868     @Deprecated
   3869     protected interface StreamItemPhotosColumns {
   3870         /**
   3871          * A reference to the {@link StreamItems#_ID} this photo is associated with.
   3872          * <P>Type: NUMBER</P>
   3873          *
   3874          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3875          * cursors returned from related queries will be empty.
   3876          */
   3877         @Deprecated
   3878         public static final String STREAM_ITEM_ID = "stream_item_id";
   3879 
   3880         /**
   3881          * An integer to use for sort order for photos in the stream item.  If not
   3882          * specified, the {@link StreamItemPhotos#_ID} will be used for sorting.
   3883          * <P>Type: NUMBER</P>
   3884          *
   3885          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3886          * cursors returned from related queries will be empty.
   3887          */
   3888         @Deprecated
   3889         public static final String SORT_INDEX = "sort_index";
   3890 
   3891         /**
   3892          * Photo file ID for the photo.
   3893          * See {@link ContactsContract.DisplayPhoto}.
   3894          * <P>Type: NUMBER</P>
   3895          *
   3896          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3897          * cursors returned from related queries will be empty.
   3898          */
   3899         @Deprecated
   3900         public static final String PHOTO_FILE_ID = "photo_file_id";
   3901 
   3902         /**
   3903          * URI for retrieving the photo content, automatically populated.  Callers
   3904          * may retrieve the photo content by opening this URI as an asset file.
   3905          * <P>Type: TEXT</P>
   3906          *
   3907          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3908          * cursors returned from related queries will be empty.
   3909          */
   3910         @Deprecated
   3911         public static final String PHOTO_URI = "photo_uri";
   3912 
   3913         /**
   3914          * Generic column for use by sync adapters.
   3915          *
   3916          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3917          * cursors returned from related queries will be empty.
   3918          */
   3919         @Deprecated
   3920         public static final String SYNC1 = "stream_item_photo_sync1";
   3921         /**
   3922          * Generic column for use by sync adapters.
   3923          *
   3924          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3925          * cursors returned from related queries will be empty.
   3926          */
   3927         @Deprecated
   3928         public static final String SYNC2 = "stream_item_photo_sync2";
   3929         /**
   3930          * Generic column for use by sync adapters.
   3931          *
   3932          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3933          * cursors returned from related queries will be empty.
   3934          */
   3935         @Deprecated
   3936         public static final String SYNC3 = "stream_item_photo_sync3";
   3937         /**
   3938          * Generic column for use by sync adapters.
   3939          *
   3940          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3941          * cursors returned from related queries will be empty.
   3942          */
   3943         @Deprecated
   3944         public static final String SYNC4 = "stream_item_photo_sync4";
   3945     }
   3946 
   3947     /**
   3948      * <p>
   3949      * Constants for the photo files table, which tracks metadata for hi-res photos
   3950      * stored in the file system.
   3951      * </p>
   3952      *
   3953      * @hide
   3954      */
   3955     public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns {
   3956         /**
   3957          * No public constructor since this is a utility class
   3958          */
   3959         private PhotoFiles() {
   3960         }
   3961     }
   3962 
   3963     /**
   3964      * Columns in the PhotoFiles table.
   3965      *
   3966      * @see ContactsContract.PhotoFiles
   3967      *
   3968      * @hide
   3969      */
   3970     protected interface PhotoFilesColumns {
   3971 
   3972         /**
   3973          * The height, in pixels, of the photo this entry is associated with.
   3974          * <P>Type: NUMBER</P>
   3975          */
   3976         public static final String HEIGHT = "height";
   3977 
   3978         /**
   3979          * The width, in pixels, of the photo this entry is associated with.
   3980          * <P>Type: NUMBER</P>
   3981          */
   3982         public static final String WIDTH = "width";
   3983 
   3984         /**
   3985          * The size, in bytes, of the photo stored on disk.
   3986          * <P>Type: NUMBER</P>
   3987          */
   3988         public static final String FILESIZE = "filesize";
   3989     }
   3990 
   3991     /**
   3992      * Columns in the Data table.
   3993      *
   3994      * @see ContactsContract.Data
   3995      */
   3996     protected interface DataColumns {
   3997         /**
   3998          * The package name to use when creating {@link Resources} objects for
   3999          * this data row. This value is only designed for use when building user
   4000          * interfaces, and should not be used to infer the owner.
   4001          */
   4002         public static final String RES_PACKAGE = "res_package";
   4003 
   4004         /**
   4005          * The MIME type of the item represented by this row.
   4006          */
   4007         public static final String MIMETYPE = "mimetype";
   4008 
   4009         /**
   4010          * Hash id on the data fields, used for backup and restore.
   4011          *
   4012          * @hide
   4013          */
   4014         public static final String HASH_ID = "hash_id";
   4015 
   4016         /**
   4017          * A reference to the {@link RawContacts#_ID}
   4018          * that this data belongs to.
   4019          */
   4020         public static final String RAW_CONTACT_ID = "raw_contact_id";
   4021 
   4022         /**
   4023          * Whether this is the primary entry of its kind for the raw contact it belongs to.
   4024          * <P>Type: INTEGER (if set, non-0 means true)</P>
   4025          */
   4026         public static final String IS_PRIMARY = "is_primary";
   4027 
   4028         /**
   4029          * Whether this is the primary entry of its kind for the aggregate
   4030          * contact it belongs to. Any data record that is "super primary" must
   4031          * also be "primary".
   4032          * <P>Type: INTEGER (if set, non-0 means true)</P>
   4033          */
   4034         public static final String IS_SUPER_PRIMARY = "is_super_primary";
   4035 
   4036         /**
   4037          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
   4038          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
   4039          * <P>Type: INTEGER</P>
   4040          */
   4041         public static final String IS_READ_ONLY = "is_read_only";
   4042 
   4043         /**
   4044          * The version of this data record. This is a read-only value. The data column is
   4045          * guaranteed to not change without the version going up. This value is monotonically
   4046          * increasing.
   4047          * <P>Type: INTEGER</P>
   4048          */
   4049         public static final String DATA_VERSION = "data_version";
   4050 
   4051         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4052         public static final String DATA1 = "data1";
   4053         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4054         public static final String DATA2 = "data2";
   4055         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4056         public static final String DATA3 = "data3";
   4057         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4058         public static final String DATA4 = "data4";
   4059         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4060         public static final String DATA5 = "data5";
   4061         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4062         public static final String DATA6 = "data6";
   4063         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4064         public static final String DATA7 = "data7";
   4065         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4066         public static final String DATA8 = "data8";
   4067         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4068         public static final String DATA9 = "data9";
   4069         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4070         public static final String DATA10 = "data10";
   4071         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4072         public static final String DATA11 = "data11";
   4073         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4074         public static final String DATA12 = "data12";
   4075         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4076         public static final String DATA13 = "data13";
   4077         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4078         public static final String DATA14 = "data14";
   4079         /**
   4080          * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
   4081          * this field is used to store BLOBs (binary data).
   4082          */
   4083         public static final String DATA15 = "data15";
   4084 
   4085         /** Generic column for use by sync adapters. */
   4086         public static final String SYNC1 = "data_sync1";
   4087         /** Generic column for use by sync adapters. */
   4088         public static final String SYNC2 = "data_sync2";
   4089         /** Generic column for use by sync adapters. */
   4090         public static final String SYNC3 = "data_sync3";
   4091         /** Generic column for use by sync adapters. */
   4092         public static final String SYNC4 = "data_sync4";
   4093 
   4094         /**
   4095          * Carrier presence information.
   4096          * <P>
   4097          * Type: INTEGER (A bitmask of CARRIER_PRESENCE_* fields)
   4098          * </P>
   4099          */
   4100         public static final String CARRIER_PRESENCE = "carrier_presence";
   4101 
   4102         /**
   4103          * Indicates that the entry is Video Telephony (VT) capable on the
   4104          * current carrier. An allowed bitmask of {@link #CARRIER_PRESENCE}.
   4105          */
   4106         public static final int CARRIER_PRESENCE_VT_CAPABLE = 0x01;
   4107     }
   4108 
   4109     /**
   4110      * Columns in the Data_Usage_Stat table
   4111      */
   4112     protected interface DataUsageStatColumns {
   4113         /** The last time (in milliseconds) this {@link Data} was used. */
   4114         public static final String LAST_TIME_USED = "last_time_used";
   4115 
   4116         /** The number of times the referenced {@link Data} has been used. */
   4117         public static final String TIMES_USED = "times_used";
   4118     }
   4119 
   4120     /**
   4121      * Combines all columns returned by {@link ContactsContract.Data} table queries.
   4122      *
   4123      * @see ContactsContract.Data
   4124      */
   4125     protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
   4126             RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
   4127             ContactStatusColumns, DataUsageStatColumns {
   4128     }
   4129 
   4130     /**
   4131      * <p>
   4132      * Constants for the data table, which contains data points tied to a raw
   4133      * contact.  Each row of the data table is typically used to store a single
   4134      * piece of contact
   4135      * information (such as a phone number) and its
   4136      * associated metadata (such as whether it is a work or home number).
   4137      * </p>
   4138      * <h3>Data kinds</h3>
   4139      * <p>
   4140      * Data is a generic table that can hold any kind of contact data.
   4141      * The kind of data stored in a given row is specified by the row's
   4142      * {@link #MIMETYPE} value, which determines the meaning of the
   4143      * generic columns {@link #DATA1} through
   4144      * {@link #DATA15}.
   4145      * For example, if the data kind is
   4146      * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
   4147      * {@link #DATA1} stores the
   4148      * phone number, but if the data kind is
   4149      * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
   4150      * stores the email address.
   4151      * Sync adapters and applications can introduce their own data kinds.
   4152      * </p>
   4153      * <p>
   4154      * ContactsContract defines a small number of pre-defined data kinds, e.g.
   4155      * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
   4156      * convenience, these classes define data kind specific aliases for DATA1 etc.
   4157      * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
   4158      * {@link ContactsContract.Data Data.DATA1}.
   4159      * </p>
   4160      * <p>
   4161      * {@link #DATA1} is an indexed column and should be used for the data element that is
   4162      * expected to be most frequently used in query selections. For example, in the
   4163      * case of a row representing email addresses {@link #DATA1} should probably
   4164      * be used for the email address itself, while {@link #DATA2} etc can be
   4165      * used for auxiliary information like type of email address.
   4166      * <p>
   4167      * <p>
   4168      * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
   4169      * </p>
   4170      * <p>
   4171      * The sync adapter for a given account type must correctly handle every data type
   4172      * used in the corresponding raw contacts.  Otherwise it could result in lost or
   4173      * corrupted data.
   4174      * </p>
   4175      * <p>
   4176      * Similarly, you should refrain from introducing new kinds of data for an other
   4177      * party's account types. For example, if you add a data row for
   4178      * "favorite song" to a raw contact owned by a Google account, it will not
   4179      * get synced to the server, because the Google sync adapter does not know
   4180      * how to handle this data kind. Thus new data kinds are typically
   4181      * introduced along with new account types, i.e. new sync adapters.
   4182      * </p>
   4183      * <h3>Batch operations</h3>
   4184      * <p>
   4185      * Data rows can be inserted/updated/deleted using the traditional
   4186      * {@link ContentResolver#insert}, {@link ContentResolver#update} and
   4187      * {@link ContentResolver#delete} methods, however the newer mechanism based
   4188      * on a batch of {@link ContentProviderOperation} will prove to be a better
   4189      * choice in almost all cases. All operations in a batch are executed in a
   4190      * single transaction, which ensures that the phone-side and server-side
   4191      * state of a raw contact are always consistent. Also, the batch-based
   4192      * approach is far more efficient: not only are the database operations
   4193      * faster when executed in a single transaction, but also sending a batch of
   4194      * commands to the content provider saves a lot of time on context switching
   4195      * between your process and the process in which the content provider runs.
   4196      * </p>
   4197      * <p>
   4198      * The flip side of using batched operations is that a large batch may lock
   4199      * up the database for a long time preventing other applications from
   4200      * accessing data and potentially causing ANRs ("Application Not Responding"
   4201      * dialogs.)
   4202      * </p>
   4203      * <p>
   4204      * To avoid such lockups of the database, make sure to insert "yield points"
   4205      * in the batch. A yield point indicates to the content provider that before
   4206      * executing the next operation it can commit the changes that have already
   4207      * been made, yield to other requests, open another transaction and continue
   4208      * processing operations. A yield point will not automatically commit the
   4209      * transaction, but only if there is another request waiting on the
   4210      * database. Normally a sync adapter should insert a yield point at the
   4211      * beginning of each raw contact operation sequence in the batch. See
   4212      * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
   4213      * </p>
   4214      * <h3>Operations</h3>
   4215      * <dl>
   4216      * <dt><b>Insert</b></dt>
   4217      * <dd>
   4218      * <p>
   4219      * An individual data row can be inserted using the traditional
   4220      * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
   4221      * should always be inserted as a batch.
   4222      * </p>
   4223      * <p>
   4224      * An example of a traditional insert:
   4225      * <pre>
   4226      * ContentValues values = new ContentValues();
   4227      * values.put(Data.RAW_CONTACT_ID, rawContactId);
   4228      * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
   4229      * values.put(Phone.NUMBER, "1-800-GOOG-411");
   4230      * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
   4231      * values.put(Phone.LABEL, "free directory assistance");
   4232      * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
   4233      * </pre>
   4234      * <p>
   4235      * The same done using ContentProviderOperations:
   4236      * <pre>
   4237      * ArrayList&lt;ContentProviderOperation&gt; ops =
   4238      *          new ArrayList&lt;ContentProviderOperation&gt;();
   4239      *
   4240      * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
   4241      *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
   4242      *          .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
   4243      *          .withValue(Phone.NUMBER, "1-800-GOOG-411")
   4244      *          .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
   4245      *          .withValue(Phone.LABEL, "free directory assistance")
   4246      *          .build());
   4247      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   4248      * </pre>
   4249      * </p>
   4250      * <dt><b>Update</b></dt>
   4251      * <dd>
   4252      * <p>
   4253      * Just as with insert, update can be done incrementally or as a batch,
   4254      * the batch mode being the preferred method:
   4255      * <pre>
   4256      * ArrayList&lt;ContentProviderOperation&gt; ops =
   4257      *          new ArrayList&lt;ContentProviderOperation&gt;();
   4258      *
   4259      * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
   4260      *          .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
   4261      *          .withValue(Email.DATA, "somebody (at) android.com")
   4262      *          .build());
   4263      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   4264      * </pre>
   4265      * </p>
   4266      * </dd>
   4267      * <dt><b>Delete</b></dt>
   4268      * <dd>
   4269      * <p>
   4270      * Just as with insert and update, deletion can be done either using the
   4271      * {@link ContentResolver#delete} method or using a ContentProviderOperation:
   4272      * <pre>
   4273      * ArrayList&lt;ContentProviderOperation&gt; ops =
   4274      *          new ArrayList&lt;ContentProviderOperation&gt;();
   4275      *
   4276      * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
   4277      *          .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
   4278      *          .build());
   4279      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   4280      * </pre>
   4281      * </p>
   4282      * </dd>
   4283      * <dt><b>Query</b></dt>
   4284      * <dd>
   4285      * <p>
   4286      * <dl>
   4287      * <dt>Finding all Data of a given type for a given contact</dt>
   4288      * <dd>
   4289      * <pre>
   4290      * Cursor c = getContentResolver().query(Data.CONTENT_URI,
   4291      *          new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
   4292      *          Data.CONTACT_ID + &quot;=?&quot; + " AND "
   4293      *                  + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
   4294      *          new String[] {String.valueOf(contactId)}, null);
   4295      * </pre>
   4296      * </p>
   4297      * <p>
   4298      * </dd>
   4299      * <dt>Finding all Data of a given type for a given raw contact</dt>
   4300      * <dd>
   4301      * <pre>
   4302      * Cursor c = getContentResolver().query(Data.CONTENT_URI,
   4303      *          new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
   4304      *          Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
   4305      *                  + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
   4306      *          new String[] {String.valueOf(rawContactId)}, null);
   4307      * </pre>
   4308      * </dd>
   4309      * <dt>Finding all Data for a given raw contact</dt>
   4310      * <dd>
   4311      * Most sync adapters will want to read all data rows for a raw contact
   4312      * along with the raw contact itself.  For that you should use the
   4313      * {@link RawContactsEntity}. See also {@link RawContacts}.
   4314      * </dd>
   4315      * </dl>
   4316      * </p>
   4317      * </dd>
   4318      * </dl>
   4319      * <h2>Columns</h2>
   4320      * <p>
   4321      * Many columns are available via a {@link Data#CONTENT_URI} query.  For best performance you
   4322      * should explicitly specify a projection to only those columns that you need.
   4323      * </p>
   4324      * <table class="jd-sumtable">
   4325      * <tr>
   4326      * <th colspan='4'>Data</th>
   4327      * </tr>
   4328      * <tr>
   4329      * <td style="width: 7em;">long</td>
   4330      * <td style="width: 20em;">{@link #_ID}</td>
   4331      * <td style="width: 5em;">read-only</td>
   4332      * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
   4333      * it would be a bad idea to delete and reinsert a data row. A sync adapter should
   4334      * always do an update instead.</td>
   4335      * </tr>
   4336      * <tr>
   4337      * <td>String</td>
   4338      * <td>{@link #MIMETYPE}</td>
   4339      * <td>read/write-once</td>
   4340      * <td>
   4341      * <p>The MIME type of the item represented by this row. Examples of common
   4342      * MIME types are:
   4343      * <ul>
   4344      * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
   4345      * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
   4346      * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
   4347      * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
   4348      * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
   4349      * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
   4350      * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
   4351      * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
   4352      * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
   4353      * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
   4354      * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
   4355      * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
   4356      * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
   4357      * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li>
   4358      * </ul>
   4359      * </p>
   4360      * </td>
   4361      * </tr>
   4362      * <tr>
   4363      * <td>long</td>
   4364      * <td>{@link #RAW_CONTACT_ID}</td>
   4365      * <td>read/write-once</td>
   4366      * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
   4367      * </tr>
   4368      * <tr>
   4369      * <td>int</td>
   4370      * <td>{@link #IS_PRIMARY}</td>
   4371      * <td>read/write</td>
   4372      * <td>Whether this is the primary entry of its kind for the raw contact it belongs to.
   4373      * "1" if true, "0" if false.
   4374      * </td>
   4375      * </tr>
   4376      * <tr>
   4377      * <td>int</td>
   4378      * <td>{@link #IS_SUPER_PRIMARY}</td>
   4379      * <td>read/write</td>
   4380      * <td>Whether this is the primary entry of its kind for the aggregate
   4381      * contact it belongs to. Any data record that is "super primary" must
   4382      * also be "primary".  For example, the super-primary entry may be
   4383      * interpreted as the default contact value of its kind (for example,
   4384      * the default phone number to use for the contact).</td>
   4385      * </tr>
   4386      * <tr>
   4387      * <td>int</td>
   4388      * <td>{@link #DATA_VERSION}</td>
   4389      * <td>read-only</td>
   4390      * <td>The version of this data record. Whenever the data row changes
   4391      * the version goes up. This value is monotonically increasing.</td>
   4392      * </tr>
   4393      * <tr>
   4394      * <td>Any type</td>
   4395      * <td>
   4396      * {@link #DATA1}<br>
   4397      * {@link #DATA2}<br>
   4398      * {@link #DATA3}<br>
   4399      * {@link #DATA4}<br>
   4400      * {@link #DATA5}<br>
   4401      * {@link #DATA6}<br>
   4402      * {@link #DATA7}<br>
   4403      * {@link #DATA8}<br>
   4404      * {@link #DATA9}<br>
   4405      * {@link #DATA10}<br>
   4406      * {@link #DATA11}<br>
   4407      * {@link #DATA12}<br>
   4408      * {@link #DATA13}<br>
   4409      * {@link #DATA14}<br>
   4410      * {@link #DATA15}
   4411      * </td>
   4412      * <td>read/write</td>
   4413      * <td>
   4414      * <p>
   4415      * Generic data columns.  The meaning of each column is determined by the
   4416      * {@link #MIMETYPE}.  By convention, {@link #DATA15} is used for storing
   4417      * BLOBs (binary data).
   4418      * </p>
   4419      * <p>
   4420      * Data columns whose meaning is not explicitly defined for a given MIMETYPE
   4421      * should not be used.  There is no guarantee that any sync adapter will
   4422      * preserve them.  Sync adapters themselves should not use such columns either,
   4423      * but should instead use {@link #SYNC1}-{@link #SYNC4}.
   4424      * </p>
   4425      * </td>
   4426      * </tr>
   4427      * <tr>
   4428      * <td>Any type</td>
   4429      * <td>
   4430      * {@link #SYNC1}<br>
   4431      * {@link #SYNC2}<br>
   4432      * {@link #SYNC3}<br>
   4433      * {@link #SYNC4}
   4434      * </td>
   4435      * <td>read/write</td>
   4436      * <td>Generic columns for use by sync adapters. For example, a Photo row
   4437      * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
   4438      * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
   4439      * </tr>
   4440      * </table>
   4441      *
   4442      * <p>
   4443      * Some columns from the most recent associated status update are also available
   4444      * through an implicit join.
   4445      * </p>
   4446      * <table class="jd-sumtable">
   4447      * <tr>
   4448      * <th colspan='4'>Join with {@link StatusUpdates}</th>
   4449      * </tr>
   4450      * <tr>
   4451      * <td style="width: 7em;">int</td>
   4452      * <td style="width: 20em;">{@link #PRESENCE}</td>
   4453      * <td style="width: 5em;">read-only</td>
   4454      * <td>IM presence status linked to this data row. Compare with
   4455      * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
   4456      * all IM rows. See {@link StatusUpdates} for individual status definitions.
   4457      * The provider may choose not to store this value
   4458      * in persistent storage. The expectation is that presence status will be
   4459      * updated on a regular basis.
   4460      * </td>
   4461      * </tr>
   4462      * <tr>
   4463      * <td>String</td>
   4464      * <td>{@link #STATUS}</td>
   4465      * <td>read-only</td>
   4466      * <td>Latest status update linked with this data row.</td>
   4467      * </tr>
   4468      * <tr>
   4469      * <td>long</td>
   4470      * <td>{@link #STATUS_TIMESTAMP}</td>
   4471      * <td>read-only</td>
   4472      * <td>The absolute time in milliseconds when the latest status was
   4473      * inserted/updated for this data row.</td>
   4474      * </tr>
   4475      * <tr>
   4476      * <td>String</td>
   4477      * <td>{@link #STATUS_RES_PACKAGE}</td>
   4478      * <td>read-only</td>
   4479      * <td>The package containing resources for this status: label and icon.</td>
   4480      * </tr>
   4481      * <tr>
   4482      * <td>long</td>
   4483      * <td>{@link #STATUS_LABEL}</td>
   4484      * <td>read-only</td>
   4485      * <td>The resource ID of the label describing the source of status update linked
   4486      * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
   4487      * </tr>
   4488      * <tr>
   4489      * <td>long</td>
   4490      * <td>{@link #STATUS_ICON}</td>
   4491      * <td>read-only</td>
   4492      * <td>The resource ID of the icon for the source of the status update linked
   4493      * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
   4494      * </tr>
   4495      * </table>
   4496      *
   4497      * <p>
   4498      * Some columns from the associated raw contact are also available through an
   4499      * implicit join.  The other columns are excluded as uninteresting in this
   4500      * context.
   4501      * </p>
   4502      *
   4503      * <table class="jd-sumtable">
   4504      * <tr>
   4505      * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
   4506      * </tr>
   4507      * <tr>
   4508      * <td style="width: 7em;">long</td>
   4509      * <td style="width: 20em;">{@link #CONTACT_ID}</td>
   4510      * <td style="width: 5em;">read-only</td>
   4511      * <td>The id of the row in the {@link Contacts} table that this data belongs
   4512      * to.</td>
   4513      * </tr>
   4514      * <tr>
   4515      * <td>int</td>
   4516      * <td>{@link #AGGREGATION_MODE}</td>
   4517      * <td>read-only</td>
   4518      * <td>See {@link RawContacts}.</td>
   4519      * </tr>
   4520      * <tr>
   4521      * <td>int</td>
   4522      * <td>{@link #DELETED}</td>
   4523      * <td>read-only</td>
   4524      * <td>See {@link RawContacts}.</td>
   4525      * </tr>
   4526      * </table>
   4527      *
   4528      * <p>
   4529      * The ID column for the associated aggregated contact table
   4530      * {@link ContactsContract.Contacts} is available
   4531      * via the implicit join to the {@link RawContacts} table, see above.
   4532      * The remaining columns from this table are also
   4533      * available, through an implicit join.  This
   4534      * facilitates lookup by
   4535      * the value of a single data element, such as the email address.
   4536      * </p>
   4537      *
   4538      * <table class="jd-sumtable">
   4539      * <tr>
   4540      * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
   4541      * </tr>
   4542      * <tr>
   4543      * <td style="width: 7em;">String</td>
   4544      * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
   4545      * <td style="width: 5em;">read-only</td>
   4546      * <td>See {@link ContactsContract.Contacts}</td>
   4547      * </tr>
   4548      * <tr>
   4549      * <td>String</td>
   4550      * <td>{@link #DISPLAY_NAME}</td>
   4551      * <td>read-only</td>
   4552      * <td>See {@link ContactsContract.Contacts}</td>
   4553      * </tr>
   4554      * <tr>
   4555      * <td>long</td>
   4556      * <td>{@link #PHOTO_ID}</td>
   4557      * <td>read-only</td>
   4558      * <td>See {@link ContactsContract.Contacts}.</td>
   4559      * </tr>
   4560      * <tr>
   4561      * <td>int</td>
   4562      * <td>{@link #IN_VISIBLE_GROUP}</td>
   4563      * <td>read-only</td>
   4564      * <td>See {@link ContactsContract.Contacts}.</td>
   4565      * </tr>
   4566      * <tr>
   4567      * <td>int</td>
   4568      * <td>{@link #HAS_PHONE_NUMBER}</td>
   4569      * <td>read-only</td>
   4570      * <td>See {@link ContactsContract.Contacts}.</td>
   4571      * </tr>
   4572      * <tr>
   4573      * <td>int</td>
   4574      * <td>{@link #TIMES_CONTACTED}</td>
   4575      * <td>read-only</td>
   4576      * <td>See {@link ContactsContract.Contacts}.</td>
   4577      * </tr>
   4578      * <tr>
   4579      * <td>long</td>
   4580      * <td>{@link #LAST_TIME_CONTACTED}</td>
   4581      * <td>read-only</td>
   4582      * <td>See {@link ContactsContract.Contacts}.</td>
   4583      * </tr>
   4584      * <tr>
   4585      * <td>int</td>
   4586      * <td>{@link #STARRED}</td>
   4587      * <td>read-only</td>
   4588      * <td>See {@link ContactsContract.Contacts}.</td>
   4589      * </tr>
   4590      * <tr>
   4591      * <td>String</td>
   4592      * <td>{@link #CUSTOM_RINGTONE}</td>
   4593      * <td>read-only</td>
   4594      * <td>See {@link ContactsContract.Contacts}.</td>
   4595      * </tr>
   4596      * <tr>
   4597      * <td>int</td>
   4598      * <td>{@link #SEND_TO_VOICEMAIL}</td>
   4599      * <td>read-only</td>
   4600      * <td>See {@link ContactsContract.Contacts}.</td>
   4601      * </tr>
   4602      * <tr>
   4603      * <td>int</td>
   4604      * <td>{@link #CONTACT_PRESENCE}</td>
   4605      * <td>read-only</td>
   4606      * <td>See {@link ContactsContract.Contacts}.</td>
   4607      * </tr>
   4608      * <tr>
   4609      * <td>String</td>
   4610      * <td>{@link #CONTACT_STATUS}</td>
   4611      * <td>read-only</td>
   4612      * <td>See {@link ContactsContract.Contacts}.</td>
   4613      * </tr>
   4614      * <tr>
   4615      * <td>long</td>
   4616      * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
   4617      * <td>read-only</td>
   4618      * <td>See {@link ContactsContract.Contacts}.</td>
   4619      * </tr>
   4620      * <tr>
   4621      * <td>String</td>
   4622      * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
   4623      * <td>read-only</td>
   4624      * <td>See {@link ContactsContract.Contacts}.</td>
   4625      * </tr>
   4626      * <tr>
   4627      * <td>long</td>
   4628      * <td>{@link #CONTACT_STATUS_LABEL}</td>
   4629      * <td>read-only</td>
   4630      * <td>See {@link ContactsContract.Contacts}.</td>
   4631      * </tr>
   4632      * <tr>
   4633      * <td>long</td>
   4634      * <td>{@link #CONTACT_STATUS_ICON}</td>
   4635      * <td>read-only</td>
   4636      * <td>See {@link ContactsContract.Contacts}.</td>
   4637      * </tr>
   4638      * </table>
   4639      */
   4640     public final static class Data implements DataColumnsWithJoins, ContactCounts {
   4641         /**
   4642          * This utility class cannot be instantiated
   4643          */
   4644         private Data() {}
   4645 
   4646         /**
   4647          * The content:// style URI for this table, which requests a directory
   4648          * of data rows matching the selection criteria.
   4649          */
   4650         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
   4651 
   4652         /**
   4653         * The content:// style URI for this table in managed profile, which requests a directory
   4654         * of data rows matching the selection criteria.
   4655         *
   4656         * @hide
   4657         */
   4658         static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
   4659                 "data_enterprise");
   4660 
   4661         /**
   4662          * A boolean parameter for {@link Data#CONTENT_URI}.
   4663          * This specifies whether or not the returned data items should be filtered to show
   4664          * data items belonging to visible contacts only.
   4665          */
   4666         public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
   4667 
   4668         /**
   4669          * The MIME type of the results from {@link #CONTENT_URI}.
   4670          */
   4671         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
   4672 
   4673         /**
   4674          * <p>
   4675          * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
   4676          * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
   4677          * entry of the given {@link ContactsContract.Data} entry.
   4678          * </p>
   4679          * <p>
   4680          * Returns the Uri for the contact in the first entry returned by
   4681          * {@link ContentResolver#query(Uri, String[], String, String[], String)}
   4682          * for the provided {@code dataUri}.  If the query returns null or empty
   4683          * results, silently returns null.
   4684          * </p>
   4685          */
   4686         public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
   4687             final Cursor cursor = resolver.query(dataUri, new String[] {
   4688                     RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
   4689             }, null, null, null);
   4690 
   4691             Uri lookupUri = null;
   4692             try {
   4693                 if (cursor != null && cursor.moveToFirst()) {
   4694                     final long contactId = cursor.getLong(0);
   4695                     final String lookupKey = cursor.getString(1);
   4696                     return Contacts.getLookupUri(contactId, lookupKey);
   4697                 }
   4698             } finally {
   4699                 if (cursor != null) cursor.close();
   4700             }
   4701             return lookupUri;
   4702         }
   4703     }
   4704 
   4705     /**
   4706      * <p>
   4707      * Constants for the raw contacts entities table, which can be thought of as
   4708      * an outer join of the raw_contacts table with the data table.  It is a strictly
   4709      * read-only table.
   4710      * </p>
   4711      * <p>
   4712      * If a raw contact has data rows, the RawContactsEntity cursor will contain
   4713      * a one row for each data row. If the raw contact has no data rows, the
   4714      * cursor will still contain one row with the raw contact-level information
   4715      * and nulls for data columns.
   4716      *
   4717      * <pre>
   4718      * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
   4719      * Cursor c = getContentResolver().query(entityUri,
   4720      *          new String[]{
   4721      *              RawContactsEntity.SOURCE_ID,
   4722      *              RawContactsEntity.DATA_ID,
   4723      *              RawContactsEntity.MIMETYPE,
   4724      *              RawContactsEntity.DATA1
   4725      *          }, null, null, null);
   4726      * try {
   4727      *     while (c.moveToNext()) {
   4728      *         String sourceId = c.getString(0);
   4729      *         if (!c.isNull(1)) {
   4730      *             String mimeType = c.getString(2);
   4731      *             String data = c.getString(3);
   4732      *             ...
   4733      *         }
   4734      *     }
   4735      * } finally {
   4736      *     c.close();
   4737      * }
   4738      * </pre>
   4739      *
   4740      * <h3>Columns</h3>
   4741      * RawContactsEntity has a combination of RawContact and Data columns.
   4742      *
   4743      * <table class="jd-sumtable">
   4744      * <tr>
   4745      * <th colspan='4'>RawContacts</th>
   4746      * </tr>
   4747      * <tr>
   4748      * <td style="width: 7em;">long</td>
   4749      * <td style="width: 20em;">{@link #_ID}</td>
   4750      * <td style="width: 5em;">read-only</td>
   4751      * <td>Raw contact row ID. See {@link RawContacts}.</td>
   4752      * </tr>
   4753      * <tr>
   4754      * <td>long</td>
   4755      * <td>{@link #CONTACT_ID}</td>
   4756      * <td>read-only</td>
   4757      * <td>See {@link RawContacts}.</td>
   4758      * </tr>
   4759      * <tr>
   4760      * <td>int</td>
   4761      * <td>{@link #AGGREGATION_MODE}</td>
   4762      * <td>read-only</td>
   4763      * <td>See {@link RawContacts}.</td>
   4764      * </tr>
   4765      * <tr>
   4766      * <td>int</td>
   4767      * <td>{@link #DELETED}</td>
   4768      * <td>read-only</td>
   4769      * <td>See {@link RawContacts}.</td>
   4770      * </tr>
   4771      * </table>
   4772      *
   4773      * <table class="jd-sumtable">
   4774      * <tr>
   4775      * <th colspan='4'>Data</th>
   4776      * </tr>
   4777      * <tr>
   4778      * <td style="width: 7em;">long</td>
   4779      * <td style="width: 20em;">{@link #DATA_ID}</td>
   4780      * <td style="width: 5em;">read-only</td>
   4781      * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
   4782      * </tr>
   4783      * <tr>
   4784      * <td>String</td>
   4785      * <td>{@link #MIMETYPE}</td>
   4786      * <td>read-only</td>
   4787      * <td>See {@link ContactsContract.Data}.</td>
   4788      * </tr>
   4789      * <tr>
   4790      * <td>int</td>
   4791      * <td>{@link #IS_PRIMARY}</td>
   4792      * <td>read-only</td>
   4793      * <td>See {@link ContactsContract.Data}.</td>
   4794      * </tr>
   4795      * <tr>
   4796      * <td>int</td>
   4797      * <td>{@link #IS_SUPER_PRIMARY}</td>
   4798      * <td>read-only</td>
   4799      * <td>See {@link ContactsContract.Data}.</td>
   4800      * </tr>
   4801      * <tr>
   4802      * <td>int</td>
   4803      * <td>{@link #DATA_VERSION}</td>
   4804      * <td>read-only</td>
   4805      * <td>See {@link ContactsContract.Data}.</td>
   4806      * </tr>
   4807      * <tr>
   4808      * <td>Any type</td>
   4809      * <td>
   4810      * {@link #DATA1}<br>
   4811      * {@link #DATA2}<br>
   4812      * {@link #DATA3}<br>
   4813      * {@link #DATA4}<br>
   4814      * {@link #DATA5}<br>
   4815      * {@link #DATA6}<br>
   4816      * {@link #DATA7}<br>
   4817      * {@link #DATA8}<br>
   4818      * {@link #DATA9}<br>
   4819      * {@link #DATA10}<br>
   4820      * {@link #DATA11}<br>
   4821      * {@link #DATA12}<br>
   4822      * {@link #DATA13}<br>
   4823      * {@link #DATA14}<br>
   4824      * {@link #DATA15}
   4825      * </td>
   4826      * <td>read-only</td>
   4827      * <td>See {@link ContactsContract.Data}.</td>
   4828      * </tr>
   4829      * <tr>
   4830      * <td>Any type</td>
   4831      * <td>
   4832      * {@link #SYNC1}<br>
   4833      * {@link #SYNC2}<br>
   4834      * {@link #SYNC3}<br>
   4835      * {@link #SYNC4}
   4836      * </td>
   4837      * <td>read-only</td>
   4838      * <td>See {@link ContactsContract.Data}.</td>
   4839      * </tr>
   4840      * </table>
   4841      */
   4842     public final static class RawContactsEntity
   4843             implements BaseColumns, DataColumns, RawContactsColumns {
   4844         /**
   4845          * This utility class cannot be instantiated
   4846          */
   4847         private RawContactsEntity() {}
   4848 
   4849         /**
   4850          * The content:// style URI for this table
   4851          */
   4852         public static final Uri CONTENT_URI =
   4853                 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
   4854 
   4855         /**
   4856         * The content:// style URI for this table in corp profile
   4857         *
   4858         * @hide
   4859         */
   4860         public static final Uri CORP_CONTENT_URI =
   4861                 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities_corp");
   4862 
   4863         /**
   4864          * The content:// style URI for this table, specific to the user's profile.
   4865          */
   4866         public static final Uri PROFILE_CONTENT_URI =
   4867                 Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities");
   4868 
   4869         /**
   4870          * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
   4871          */
   4872         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
   4873 
   4874         /**
   4875          * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
   4876          * Data.CONTENT_URI contains only exportable data.
   4877          *
   4878          * This flag is useful (currently) only for vCard exporter in Contacts app, which
   4879          * needs to exclude "un-exportable" data from available data to export, while
   4880          * Contacts app itself has priviledge to access all data including "un-expotable"
   4881          * ones and providers return all of them regardless of the callers' intention.
   4882          * <P>Type: INTEGER</p>
   4883          *
   4884          * @hide Maybe available only in Eclair and not really ready for public use.
   4885          * TODO: remove, or implement this feature completely. As of now (Eclair),
   4886          * we only use this flag in queryEntities(), not query().
   4887          */
   4888         public static final String FOR_EXPORT_ONLY = "for_export_only";
   4889 
   4890         /**
   4891          * The ID of the data column. The value will be null if this raw contact has no data rows.
   4892          * <P>Type: INTEGER</P>
   4893          */
   4894         public static final String DATA_ID = "data_id";
   4895     }
   4896 
   4897     /**
   4898      * @see PhoneLookup
   4899      */
   4900     protected interface PhoneLookupColumns {
   4901         /**
   4902          * The phone number as the user entered it.
   4903          * <P>Type: TEXT</P>
   4904          */
   4905         public static final String NUMBER = "number";
   4906 
   4907         /**
   4908          * The type of phone number, for example Home or Work.
   4909          * <P>Type: INTEGER</P>
   4910          */
   4911         public static final String TYPE = "type";
   4912 
   4913         /**
   4914          * The user defined label for the phone number.
   4915          * <P>Type: TEXT</P>
   4916          */
   4917         public static final String LABEL = "label";
   4918 
   4919         /**
   4920          * The phone number's E164 representation.
   4921          * <P>Type: TEXT</P>
   4922          */
   4923         public static final String NORMALIZED_NUMBER = "normalized_number";
   4924     }
   4925 
   4926     /**
   4927      * A table that represents the result of looking up a phone number, for
   4928      * example for caller ID. To perform a lookup you must append the number you
   4929      * want to find to {@link #CONTENT_FILTER_URI}.  This query is highly
   4930      * optimized.
   4931      * <pre>
   4932      * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
   4933      * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
   4934      * </pre>
   4935      *
   4936      * <h3>Columns</h3>
   4937      *
   4938      * <table class="jd-sumtable">
   4939      * <tr>
   4940      * <th colspan='4'>PhoneLookup</th>
   4941      * </tr>
   4942      * <tr>
   4943      * <td>String</td>
   4944      * <td>{@link #NUMBER}</td>
   4945      * <td>read-only</td>
   4946      * <td>Phone number.</td>
   4947      * </tr>
   4948      * <tr>
   4949      * <td>String</td>
   4950      * <td>{@link #TYPE}</td>
   4951      * <td>read-only</td>
   4952      * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
   4953      * </tr>
   4954      * <tr>
   4955      * <td>String</td>
   4956      * <td>{@link #LABEL}</td>
   4957      * <td>read-only</td>
   4958      * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
   4959      * </tr>
   4960      * </table>
   4961      * <p>
   4962      * Columns from the Contacts table are also available through a join.
   4963      * </p>
   4964      * <table class="jd-sumtable">
   4965      * <tr>
   4966      * <th colspan='4'>Join with {@link Contacts}</th>
   4967      * </tr>
   4968      * <tr>
   4969      * <td>long</td>
   4970      * <td>{@link #_ID}</td>
   4971      * <td>read-only</td>
   4972      * <td>Contact ID.</td>
   4973      * </tr>
   4974      * <tr>
   4975      * <td>String</td>
   4976      * <td>{@link #LOOKUP_KEY}</td>
   4977      * <td>read-only</td>
   4978      * <td>See {@link ContactsContract.Contacts}</td>
   4979      * </tr>
   4980      * <tr>
   4981      * <td>String</td>
   4982      * <td>{@link #DISPLAY_NAME}</td>
   4983      * <td>read-only</td>
   4984      * <td>See {@link ContactsContract.Contacts}</td>
   4985      * </tr>
   4986      * <tr>
   4987      * <td>long</td>
   4988      * <td>{@link #PHOTO_ID}</td>
   4989      * <td>read-only</td>
   4990      * <td>See {@link ContactsContract.Contacts}.</td>
   4991      * </tr>
   4992      * <tr>
   4993      * <td>int</td>
   4994      * <td>{@link #IN_VISIBLE_GROUP}</td>
   4995      * <td>read-only</td>
   4996      * <td>See {@link ContactsContract.Contacts}.</td>
   4997      * </tr>
   4998      * <tr>
   4999      * <td>int</td>
   5000      * <td>{@link #HAS_PHONE_NUMBER}</td>
   5001      * <td>read-only</td>
   5002      * <td>See {@link ContactsContract.Contacts}.</td>
   5003      * </tr>
   5004      * <tr>
   5005      * <td>int</td>
   5006      * <td>{@link #TIMES_CONTACTED}</td>
   5007      * <td>read-only</td>
   5008      * <td>See {@link ContactsContract.Contacts}.</td>
   5009      * </tr>
   5010      * <tr>
   5011      * <td>long</td>
   5012      * <td>{@link #LAST_TIME_CONTACTED}</td>
   5013      * <td>read-only</td>
   5014      * <td>See {@link ContactsContract.Contacts}.</td>
   5015      * </tr>
   5016      * <tr>
   5017      * <td>int</td>
   5018      * <td>{@link #STARRED}</td>
   5019      * <td>read-only</td>
   5020      * <td>See {@link ContactsContract.Contacts}.</td>
   5021      * </tr>
   5022      * <tr>
   5023      * <td>String</td>
   5024      * <td>{@link #CUSTOM_RINGTONE}</td>
   5025      * <td>read-only</td>
   5026      * <td>See {@link ContactsContract.Contacts}.</td>
   5027      * </tr>
   5028      * <tr>
   5029      * <td>int</td>
   5030      * <td>{@link #SEND_TO_VOICEMAIL}</td>
   5031      * <td>read-only</td>
   5032      * <td>See {@link ContactsContract.Contacts}.</td>
   5033      * </tr>
   5034      * </table>
   5035      */
   5036     public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
   5037             ContactsColumns, ContactOptionsColumns {
   5038         /**
   5039          * This utility class cannot be instantiated
   5040          */
   5041         private PhoneLookup() {}
   5042 
   5043         /**
   5044          * The content:// style URI for this table. Append the phone number you want to lookup
   5045          * to this URI and query it to perform a lookup. For example:
   5046          * <pre>
   5047          * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
   5048          *         Uri.encode(phoneNumber));
   5049          * </pre>
   5050          */
   5051         public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
   5052                 "phone_lookup");
   5053 
   5054         /**
   5055          * <p>URI used for the "enterprise caller-id".</p>
   5056          *
   5057          * <p>
   5058          * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same
   5059          * columns.  If the device has no corp profile that is linked to the current profile, it
   5060          * behaves in the exact same way as {@link #CONTENT_FILTER_URI}.  If there is a corp profile
   5061          * linked to the current profile, it first queries against the personal contact database,
   5062          * and if no matching contacts are found there, then queries against the
   5063          * corp contacts database.
   5064          * </p>
   5065          * <p>
   5066          * If a result is from the corp profile, it makes the following changes to the data:
   5067          * <ul>
   5068          *     <li>
   5069          *     {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
   5070          *     URIs.  Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
   5071          *     load pictures from them.
   5072          *     {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null.  Do not use them.
   5073          *     </li>
   5074          *     <li>
   5075          *     Corp contacts will get artificial {@link #_ID}s.  In order to tell whether a contact
   5076          *     is from the corp profile, use
   5077          *     {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
   5078          *     </li>
   5079          *     <li>
   5080          *     Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
   5081          *     </li>
   5082          * </ul>
   5083          * <p>
   5084          * A contact lookup URL built by
   5085          * {@link ContactsContract.Contacts#getLookupUri(long, String)}
   5086          * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
   5087          * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
   5088          * corp profile.
   5089          * </p>
   5090          *
   5091          * <pre>
   5092          * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
   5093          *         Uri.encode(phoneNumber));
   5094          * </pre>
   5095          */
   5096         public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
   5097                 "phone_lookup_enterprise");
   5098 
   5099         /**
   5100          * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows.
   5101          *
   5102          * @hide
   5103          */
   5104         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup";
   5105 
   5106         /**
   5107          * If this boolean parameter is set to true, then the appended query is treated as a
   5108          * SIP address and the lookup will be performed against SIP addresses in the user's
   5109          * contacts.
   5110          */
   5111         public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip";
   5112     }
   5113 
   5114     /**
   5115      * Additional data mixed in with {@link StatusColumns} to link
   5116      * back to specific {@link ContactsContract.Data#_ID} entries.
   5117      *
   5118      * @see StatusUpdates
   5119      */
   5120     protected interface PresenceColumns {
   5121 
   5122         /**
   5123          * Reference to the {@link Data#_ID} entry that owns this presence.
   5124          * <P>Type: INTEGER</P>
   5125          */
   5126         public static final String DATA_ID = "presence_data_id";
   5127 
   5128         /**
   5129          * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
   5130          * <p>Type: NUMBER</p>
   5131          */
   5132         public static final String PROTOCOL = "protocol";
   5133 
   5134         /**
   5135          * Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
   5136          * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
   5137          * omitted if {@link #PROTOCOL} value is not
   5138          * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
   5139          *
   5140          * <p>Type: NUMBER</p>
   5141          */
   5142         public static final String CUSTOM_PROTOCOL = "custom_protocol";
   5143 
   5144         /**
   5145          * The IM handle the presence item is for. The handle is scoped to
   5146          * {@link #PROTOCOL}.
   5147          * <P>Type: TEXT</P>
   5148          */
   5149         public static final String IM_HANDLE = "im_handle";
   5150 
   5151         /**
   5152          * The IM account for the local user that the presence data came from.
   5153          * <P>Type: TEXT</P>
   5154          */
   5155         public static final String IM_ACCOUNT = "im_account";
   5156     }
   5157 
   5158     /**
   5159      * <p>
   5160      * A status update is linked to a {@link ContactsContract.Data} row and captures
   5161      * the user's latest status update via the corresponding source, e.g.
   5162      * "Having lunch" via "Google Talk".
   5163      * </p>
   5164      * <p>
   5165      * There are two ways a status update can be inserted: by explicitly linking
   5166      * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
   5167      * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
   5168      * {@link #IM_HANDLE}.  There is no difference between insert and update, you can use
   5169      * either.
   5170      * </p>
   5171      * <p>
   5172      * Inserting or updating a status update for the user's profile requires either using
   5173      * the {@link #DATA_ID} to identify the data row to attach the update to, or
   5174      * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the
   5175      * profile.
   5176      * </p>
   5177      * <p>
   5178      * You cannot use {@link ContentResolver#update} to change a status, but
   5179      * {@link ContentResolver#insert} will replace the latests status if it already
   5180      * exists.
   5181      * </p>
   5182      * <p>
   5183      * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
   5184      * for multiple contacts at once.
   5185      * </p>
   5186      *
   5187      * <h3>Columns</h3>
   5188      * <table class="jd-sumtable">
   5189      * <tr>
   5190      * <th colspan='4'>StatusUpdates</th>
   5191      * </tr>
   5192      * <tr>
   5193      * <td>long</td>
   5194      * <td>{@link #DATA_ID}</td>
   5195      * <td>read/write</td>
   5196      * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
   5197      * field is <i>not</i> specified, the provider will attempt to find a data row
   5198      * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
   5199      * {@link #IM_HANDLE} columns.
   5200      * </td>
   5201      * </tr>
   5202      * <tr>
   5203      * <td>long</td>
   5204      * <td>{@link #PROTOCOL}</td>
   5205      * <td>read/write</td>
   5206      * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
   5207      * </tr>
   5208      * <tr>
   5209      * <td>String</td>
   5210      * <td>{@link #CUSTOM_PROTOCOL}</td>
   5211      * <td>read/write</td>
   5212      * <td>Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
   5213      * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
   5214      * omitted if {@link #PROTOCOL} value is not
   5215      * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
   5216      * </tr>
   5217      * <tr>
   5218      * <td>String</td>
   5219      * <td>{@link #IM_HANDLE}</td>
   5220      * <td>read/write</td>
   5221      * <td> The IM handle the presence item is for. The handle is scoped to
   5222      * {@link #PROTOCOL}.</td>
   5223      * </tr>
   5224      * <tr>
   5225      * <td>String</td>
   5226      * <td>{@link #IM_ACCOUNT}</td>
   5227      * <td>read/write</td>
   5228      * <td>The IM account for the local user that the presence data came from.</td>
   5229      * </tr>
   5230      * <tr>
   5231      * <td>int</td>
   5232      * <td>{@link #PRESENCE}</td>
   5233      * <td>read/write</td>
   5234      * <td>Contact IM presence status. The allowed values are:
   5235      * <p>
   5236      * <ul>
   5237      * <li>{@link #OFFLINE}</li>
   5238      * <li>{@link #INVISIBLE}</li>
   5239      * <li>{@link #AWAY}</li>
   5240      * <li>{@link #IDLE}</li>
   5241      * <li>{@link #DO_NOT_DISTURB}</li>
   5242      * <li>{@link #AVAILABLE}</li>
   5243      * </ul>
   5244      * </p>
   5245      * <p>
   5246      * Since presence status is inherently volatile, the content provider
   5247      * may choose not to store this field in long-term storage.
   5248      * </p>
   5249      * </td>
   5250      * </tr>
   5251      * <tr>
   5252      * <td>int</td>
   5253      * <td>{@link #CHAT_CAPABILITY}</td>
   5254      * <td>read/write</td>
   5255      * <td>Contact IM chat compatibility value. The allowed values combinations of the following
   5256      * flags. If None of these flags is set, the device can only do text messaging.
   5257      * <p>
   5258      * <ul>
   5259      * <li>{@link #CAPABILITY_HAS_VIDEO}</li>
   5260      * <li>{@link #CAPABILITY_HAS_VOICE}</li>
   5261      * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
   5262      * </ul>
   5263      * </p>
   5264      * <p>
   5265      * Since chat compatibility is inherently volatile as the contact's availability moves from
   5266      * one device to another, the content provider may choose not to store this field in long-term
   5267      * storage.
   5268      * </p>
   5269      * </td>
   5270      * </tr>
   5271      * <tr>
   5272      * <td>String</td>
   5273      * <td>{@link #STATUS}</td>
   5274      * <td>read/write</td>
   5275      * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
   5276      * </tr>
   5277      * <tr>
   5278      * <td>long</td>
   5279      * <td>{@link #STATUS_TIMESTAMP}</td>
   5280      * <td>read/write</td>
   5281      * <td>The absolute time in milliseconds when the status was
   5282      * entered by the user. If this value is not provided, the provider will follow
   5283      * this logic: if there was no prior status update, the value will be left as null.
   5284      * If there was a prior status update, the provider will default this field
   5285      * to the current time.</td>
   5286      * </tr>
   5287      * <tr>
   5288      * <td>String</td>
   5289      * <td>{@link #STATUS_RES_PACKAGE}</td>
   5290      * <td>read/write</td>
   5291      * <td> The package containing resources for this status: label and icon.</td>
   5292      * </tr>
   5293      * <tr>
   5294      * <td>long</td>
   5295      * <td>{@link #STATUS_LABEL}</td>
   5296      * <td>read/write</td>
   5297      * <td>The resource ID of the label describing the source of contact status,
   5298      * e.g. "Google Talk". This resource is scoped by the
   5299      * {@link #STATUS_RES_PACKAGE}.</td>
   5300      * </tr>
   5301      * <tr>
   5302      * <td>long</td>
   5303      * <td>{@link #STATUS_ICON}</td>
   5304      * <td>read/write</td>
   5305      * <td>The resource ID of the icon for the source of contact status. This
   5306      * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
   5307      * </tr>
   5308      * </table>
   5309      */
   5310     public static class StatusUpdates implements StatusColumns, PresenceColumns {
   5311 
   5312         /**
   5313          * This utility class cannot be instantiated
   5314          */
   5315         private StatusUpdates() {}
   5316 
   5317         /**
   5318          * The content:// style URI for this table
   5319          */
   5320         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
   5321 
   5322         /**
   5323          * The content:// style URI for this table, specific to the user's profile.
   5324          */
   5325         public static final Uri PROFILE_CONTENT_URI =
   5326                 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates");
   5327 
   5328         /**
   5329          * Gets the resource ID for the proper presence icon.
   5330          *
   5331          * @param status the status to get the icon for
   5332          * @return the resource ID for the proper presence icon
   5333          */
   5334         public static final int getPresenceIconResourceId(int status) {
   5335             switch (status) {
   5336                 case AVAILABLE:
   5337                     return android.R.drawable.presence_online;
   5338                 case IDLE:
   5339                 case AWAY:
   5340                     return android.R.drawable.presence_away;
   5341                 case DO_NOT_DISTURB:
   5342                     return android.R.drawable.presence_busy;
   5343                 case INVISIBLE:
   5344                     return android.R.drawable.presence_invisible;
   5345                 case OFFLINE:
   5346                 default:
   5347                     return android.R.drawable.presence_offline;
   5348             }
   5349         }
   5350 
   5351         /**
   5352          * Returns the precedence of the status code the higher number being the higher precedence.
   5353          *
   5354          * @param status The status code.
   5355          * @return An integer representing the precedence, 0 being the lowest.
   5356          */
   5357         public static final int getPresencePrecedence(int status) {
   5358             // Keep this function here incase we want to enforce a different precedence than the
   5359             // natural order of the status constants.
   5360             return status;
   5361         }
   5362 
   5363         /**
   5364          * The MIME type of {@link #CONTENT_URI} providing a directory of
   5365          * status update details.
   5366          */
   5367         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
   5368 
   5369         /**
   5370          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
   5371          * status update detail.
   5372          */
   5373         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
   5374     }
   5375 
   5376     /**
   5377      * @deprecated This old name was never meant to be made public. Do not use.
   5378      */
   5379     @Deprecated
   5380     public static final class Presence extends StatusUpdates {
   5381 
   5382     }
   5383 
   5384     /**
   5385      * Additional column returned by
   5386      * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining
   5387      * why the filter matched the contact. This column will contain extracts from the contact's
   5388      * constituent {@link Data Data} items, formatted in a way that indicates the section of the
   5389      * snippet that matched the filter.
   5390      *
   5391      * <p>
   5392      * The following example searches for all contacts that match the query "presi" and requests
   5393      * the snippet column as well.
   5394      * <pre>
   5395      * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
   5396      * builder.appendPath("presi");
   5397      * // Defer snippeting to the client side if possible, for performance reasons.
   5398      * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");
   5399      *
   5400      * Cursor cursor = getContentResolver().query(builder.build());
   5401      *
   5402      * Bundle extras = cursor.getExtras();
   5403      * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
   5404      *     // Do our own snippet formatting.
   5405      *     // For a contact with the email address (president (at) organization.com), the snippet
   5406      *     // column will contain the string "president (at) organization.com".
   5407      * } else {
   5408      *     // The snippet has already been pre-formatted, we can display it as is.
   5409      *     // For a contact with the email address (president (at) organization.com), the snippet
   5410      *     // column will contain the string "[presi]dent (at) organization.com".
   5411      * }
   5412      * </pre>
   5413      * </p>
   5414      */
   5415     public static class SearchSnippets {
   5416 
   5417         /**
   5418          * The search snippet constructed by SQLite snippeting functionality.
   5419          * <p>
   5420          * The snippet may contain (parts of) several data elements belonging to the contact,
   5421          * with the matching parts optionally surrounded by special characters that indicate the
   5422          * start and end of matching text.
   5423          *
   5424          * For example, if a contact has an address "123 Main Street", using a filter "mai" would
   5425          * return the formatted snippet "123 [Mai]n street".
   5426          *
   5427          * @see <a href="http://www.sqlite.org/fts3.html#snippet">
   5428          *         http://www.sqlite.org/fts3.html#snippet</a>
   5429          */
   5430         public static final String SNIPPET = "snippet";
   5431 
   5432         /**
   5433          * Comma-separated parameters for the generation of the snippet:
   5434          * <ul>
   5435          * <li>The "start match" text. Default is '['</li>
   5436          * <li>The "end match" text. Default is ']'</li>
   5437          * <li>The "ellipsis" text. Default is "..."</li>
   5438          * <li>Maximum number of tokens to include in the snippet. Can be either
   5439          * a positive or a negative number: A positive number indicates how many
   5440          * tokens can be returned in total. A negative number indicates how many
   5441          * tokens can be returned per occurrence of the search terms.</li>
   5442          * </ul>
   5443          *
   5444          * @hide
   5445          */
   5446         public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args";
   5447 
   5448         /**
   5449          * The key to ask the provider to defer the formatting of the snippet to the client if
   5450          * possible, for performance reasons.
   5451          * A value of 1 indicates true, 0 indicates false. False is the default.
   5452          * When a cursor is returned to the client, it should check for an extra with the name
   5453          * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client
   5454          * should do its own formatting of the snippet. If it doesn't exist, the snippet column
   5455          * in the cursor should already contain a formatted snippet.
   5456          */
   5457         public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting";
   5458     }
   5459 
   5460     /**
   5461      * Container for definitions of common data types stored in the {@link ContactsContract.Data}
   5462      * table.
   5463      */
   5464     public static final class CommonDataKinds {
   5465         /**
   5466          * This utility class cannot be instantiated
   5467          */
   5468         private CommonDataKinds() {}
   5469 
   5470         /**
   5471          * The {@link Data#RES_PACKAGE} value for common data that should be
   5472          * shown using a default style.
   5473          *
   5474          * @hide RES_PACKAGE is hidden
   5475          */
   5476         public static final String PACKAGE_COMMON = "common";
   5477 
   5478         /**
   5479          * The base types that all "Typed" data kinds support.
   5480          */
   5481         public interface BaseTypes {
   5482             /**
   5483              * A custom type. The custom label should be supplied by user.
   5484              */
   5485             public static int TYPE_CUSTOM = 0;
   5486         }
   5487 
   5488         /**
   5489          * Columns common across the specific types.
   5490          */
   5491         protected interface CommonColumns extends BaseTypes {
   5492             /**
   5493              * The data for the contact method.
   5494              * <P>Type: TEXT</P>
   5495              */
   5496             public static final String DATA = DataColumns.DATA1;
   5497 
   5498             /**
   5499              * The type of data, for example Home or Work.
   5500              * <P>Type: INTEGER</P>
   5501              */
   5502             public static final String TYPE = DataColumns.DATA2;
   5503 
   5504             /**
   5505              * The user defined label for the the contact method.
   5506              * <P>Type: TEXT</P>
   5507              */
   5508             public static final String LABEL = DataColumns.DATA3;
   5509         }
   5510 
   5511         /**
   5512          * A data kind representing the contact's proper name. You can use all
   5513          * columns defined for {@link ContactsContract.Data} as well as the following aliases.
   5514          *
   5515          * <h2>Column aliases</h2>
   5516          * <table class="jd-sumtable">
   5517          * <tr>
   5518          * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
   5519          * </tr>
   5520          * <tr>
   5521          * <td>String</td>
   5522          * <td>{@link #DISPLAY_NAME}</td>
   5523          * <td>{@link #DATA1}</td>
   5524          * <td></td>
   5525          * </tr>
   5526          * <tr>
   5527          * <td>String</td>
   5528          * <td>{@link #GIVEN_NAME}</td>
   5529          * <td>{@link #DATA2}</td>
   5530          * <td></td>
   5531          * </tr>
   5532          * <tr>
   5533          * <td>String</td>
   5534          * <td>{@link #FAMILY_NAME}</td>
   5535          * <td>{@link #DATA3}</td>
   5536          * <td></td>
   5537          * </tr>
   5538          * <tr>
   5539          * <td>String</td>
   5540          * <td>{@link #PREFIX}</td>
   5541          * <td>{@link #DATA4}</td>
   5542          * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
   5543          * </tr>
   5544          * <tr>
   5545          * <td>String</td>
   5546          * <td>{@link #MIDDLE_NAME}</td>
   5547          * <td>{@link #DATA5}</td>
   5548          * <td></td>
   5549          * </tr>
   5550          * <tr>
   5551          * <td>String</td>
   5552          * <td>{@link #SUFFIX}</td>
   5553          * <td>{@link #DATA6}</td>
   5554          * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
   5555          * </tr>
   5556          * <tr>
   5557          * <td>String</td>
   5558          * <td>{@link #PHONETIC_GIVEN_NAME}</td>
   5559          * <td>{@link #DATA7}</td>
   5560          * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
   5561          * </tr>
   5562          * <tr>
   5563          * <td>String</td>
   5564          * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
   5565          * <td>{@link #DATA8}</td>
   5566          * <td></td>
   5567          * </tr>
   5568          * <tr>
   5569          * <td>String</td>
   5570          * <td>{@link #PHONETIC_FAMILY_NAME}</td>
   5571          * <td>{@link #DATA9}</td>
   5572          * <td></td>
   5573          * </tr>
   5574          * </table>
   5575          */
   5576         public static final class StructuredName implements DataColumnsWithJoins, ContactCounts {
   5577             /**
   5578              * This utility class cannot be instantiated
   5579              */
   5580             private StructuredName() {}
   5581 
   5582             /** MIME type used when storing this in data table. */
   5583             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
   5584 
   5585             /**
   5586              * The name that should be used to display the contact.
   5587              * <i>Unstructured component of the name should be consistent with
   5588              * its structured representation.</i>
   5589              * <p>
   5590              * Type: TEXT
   5591              */
   5592             public static final String DISPLAY_NAME = DATA1;
   5593 
   5594             /**
   5595              * The given name for the contact.
   5596              * <P>Type: TEXT</P>
   5597              */
   5598             public static final String GIVEN_NAME = DATA2;
   5599 
   5600             /**
   5601              * The family name for the contact.
   5602              * <P>Type: TEXT</P>
   5603              */
   5604             public static final String FAMILY_NAME = DATA3;
   5605 
   5606             /**
   5607              * The contact's honorific prefix, e.g. "Sir"
   5608              * <P>Type: TEXT</P>
   5609              */
   5610             public static final String PREFIX = DATA4;
   5611 
   5612             /**
   5613              * The contact's middle name
   5614              * <P>Type: TEXT</P>
   5615              */
   5616             public static final String MIDDLE_NAME = DATA5;
   5617 
   5618             /**
   5619              * The contact's honorific suffix, e.g. "Jr"
   5620              */
   5621             public static final String SUFFIX = DATA6;
   5622 
   5623             /**
   5624              * The phonetic version of the given name for the contact.
   5625              * <P>Type: TEXT</P>
   5626              */
   5627             public static final String PHONETIC_GIVEN_NAME = DATA7;
   5628 
   5629             /**
   5630              * The phonetic version of the additional name for the contact.
   5631              * <P>Type: TEXT</P>
   5632              */
   5633             public static final String PHONETIC_MIDDLE_NAME = DATA8;
   5634 
   5635             /**
   5636              * The phonetic version of the family name for the contact.
   5637              * <P>Type: TEXT</P>
   5638              */
   5639             public static final String PHONETIC_FAMILY_NAME = DATA9;
   5640 
   5641             /**
   5642              * The style used for combining given/middle/family name into a full name.
   5643              * See {@link ContactsContract.FullNameStyle}.
   5644              */
   5645             public static final String FULL_NAME_STYLE = DATA10;
   5646 
   5647             /**
   5648              * The alphabet used for capturing the phonetic name.
   5649              * See ContactsContract.PhoneticNameStyle.
   5650              * @hide
   5651              */
   5652             public static final String PHONETIC_NAME_STYLE = DATA11;
   5653         }
   5654 
   5655         /**
   5656          * <p>A data kind representing the contact's nickname. For example, for
   5657          * Bob Parr ("Mr. Incredible"):
   5658          * <pre>
   5659          * ArrayList&lt;ContentProviderOperation&gt; ops =
   5660          *          new ArrayList&lt;ContentProviderOperation&gt;();
   5661          *
   5662          * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
   5663          *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
   5664          *          .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
   5665          *          .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
   5666          *          .build());
   5667          *
   5668          * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
   5669          *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
   5670          *          .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
   5671          *          .withValue(Nickname.NAME, "Mr. Incredible")
   5672          *          .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
   5673          *          .withValue(Nickname.LABEL, "Superhero")
   5674          *          .build());
   5675          *
   5676          * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   5677          * </pre>
   5678          * </p>
   5679          * <p>
   5680          * You can use all columns defined for {@link ContactsContract.Data} as well as the
   5681          * following aliases.
   5682          * </p>
   5683          *
   5684          * <h2>Column aliases</h2>
   5685          * <table class="jd-sumtable">
   5686          * <tr>
   5687          * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
   5688          * </tr>
   5689          * <tr>
   5690          * <td>String</td>
   5691          * <td>{@link #NAME}</td>
   5692          * <td>{@link #DATA1}</td>
   5693          * <td></td>
   5694          * </tr>
   5695          * <tr>
   5696          * <td>int</td>
   5697          * <td>{@link #TYPE}</td>
   5698          * <td>{@link #DATA2}</td>
   5699          * <td>
   5700          * Allowed values are:
   5701          * <p>
   5702          * <ul>
   5703          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   5704          * <li>{@link #TYPE_DEFAULT}</li>
   5705          * <li>{@link #TYPE_OTHER_NAME}</li>
   5706          * <li>{@link #TYPE_MAIDEN_NAME}</li>
   5707          * <li>{@link #TYPE_SHORT_NAME}</li>
   5708          * <li>{@link #TYPE_INITIALS}</li>
   5709          * </ul>
   5710          * </p>
   5711          * </td>
   5712          * </tr>
   5713          * <tr>
   5714          * <td>String</td>
   5715          * <td>{@link #LABEL}</td>
   5716          * <td>{@link #DATA3}</td>
   5717          * <td></td>
   5718          * </tr>
   5719          * </table>
   5720          */
   5721         public static final class Nickname implements DataColumnsWithJoins, CommonColumns,
   5722                 ContactCounts{
   5723             /**
   5724              * This utility class cannot be instantiated
   5725              */
   5726             private Nickname() {}
   5727 
   5728             /** MIME type used when storing this in data table. */
   5729             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
   5730 
   5731             public static final int TYPE_DEFAULT = 1;
   5732             public static final int TYPE_OTHER_NAME = 2;
   5733             public static final int TYPE_MAIDEN_NAME = 3;
   5734             /** @deprecated Use TYPE_MAIDEN_NAME instead. */
   5735             @Deprecated
   5736             public static final int TYPE_MAINDEN_NAME = 3;
   5737             public static final int TYPE_SHORT_NAME = 4;
   5738             public static final int TYPE_INITIALS = 5;
   5739 
   5740             /**
   5741              * The name itself
   5742              */
   5743             public static final String NAME = DATA;
   5744         }
   5745 
   5746         /**
   5747          * <p>
   5748          * A data kind representing a telephone number.
   5749          * </p>
   5750          * <p>
   5751          * You can use all columns defined for {@link ContactsContract.Data} as
   5752          * well as the following aliases.
   5753          * </p>
   5754          * <h2>Column aliases</h2>
   5755          * <table class="jd-sumtable">
   5756          * <tr>
   5757          * <th>Type</th>
   5758          * <th>Alias</th><th colspan='2'>Data column</th>
   5759          * </tr>
   5760          * <tr>
   5761          * <td>String</td>
   5762          * <td>{@link #NUMBER}</td>
   5763          * <td>{@link #DATA1}</td>
   5764          * <td></td>
   5765          * </tr>
   5766          * <tr>
   5767          * <td>int</td>
   5768          * <td>{@link #TYPE}</td>
   5769          * <td>{@link #DATA2}</td>
   5770          * <td>Allowed values are:
   5771          * <p>
   5772          * <ul>
   5773          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   5774          * <li>{@link #TYPE_HOME}</li>
   5775          * <li>{@link #TYPE_MOBILE}</li>
   5776          * <li>{@link #TYPE_WORK}</li>
   5777          * <li>{@link #TYPE_FAX_WORK}</li>
   5778          * <li>{@link #TYPE_FAX_HOME}</li>
   5779          * <li>{@link #TYPE_PAGER}</li>
   5780          * <li>{@link #TYPE_OTHER}</li>
   5781          * <li>{@link #TYPE_CALLBACK}</li>
   5782          * <li>{@link #TYPE_CAR}</li>
   5783          * <li>{@link #TYPE_COMPANY_MAIN}</li>
   5784          * <li>{@link #TYPE_ISDN}</li>
   5785          * <li>{@link #TYPE_MAIN}</li>
   5786          * <li>{@link #TYPE_OTHER_FAX}</li>
   5787          * <li>{@link #TYPE_RADIO}</li>
   5788          * <li>{@link #TYPE_TELEX}</li>
   5789          * <li>{@link #TYPE_TTY_TDD}</li>
   5790          * <li>{@link #TYPE_WORK_MOBILE}</li>
   5791          * <li>{@link #TYPE_WORK_PAGER}</li>
   5792          * <li>{@link #TYPE_ASSISTANT}</li>
   5793          * <li>{@link #TYPE_MMS}</li>
   5794          * </ul>
   5795          * </p>
   5796          * </td>
   5797          * </tr>
   5798          * <tr>
   5799          * <td>String</td>
   5800          * <td>{@link #LABEL}</td>
   5801          * <td>{@link #DATA3}</td>
   5802          * <td></td>
   5803          * </tr>
   5804          * </table>
   5805          */
   5806         public static final class Phone implements DataColumnsWithJoins, CommonColumns,
   5807                 ContactCounts {
   5808             /**
   5809              * This utility class cannot be instantiated
   5810              */
   5811             private Phone() {}
   5812 
   5813             /** MIME type used when storing this in data table. */
   5814             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
   5815 
   5816             /**
   5817              * The MIME type of {@link #CONTENT_URI} providing a directory of
   5818              * phones.
   5819              */
   5820             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
   5821 
   5822             /**
   5823              * The content:// style URI for all data records of the
   5824              * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
   5825              * associated raw contact and aggregate contact data.
   5826              */
   5827             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   5828                     "phones");
   5829 
   5830             /**
   5831             * URI used for getting all contacts from primary and managed profile.
   5832             *
   5833             * It supports the same semantics as {@link #CONTENT_URI} and returns the same
   5834             * columns.  If the device has no corp profile that is linked to the current profile, it
   5835             * behaves in the exact same way as {@link #CONTENT_URI}.  If there is a corp profile
   5836             * linked to the current profile, it will merge corp profile and current profile's
   5837             * results and return
   5838             *
   5839             * @hide
   5840             */
   5841             public static final Uri ENTERPRISE_CONTENT_URI =
   5842                     Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones");
   5843 
   5844             /**
   5845              * The content:// style URL for phone lookup using a filter. The filter returns
   5846              * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
   5847              * to display names as well as phone numbers. The filter argument should be passed
   5848              * as an additional path segment after this URI.
   5849              */
   5850             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
   5851                     "filter");
   5852 
   5853             /**
   5854              * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
   5855              * If "1" or "true", display names are searched.  If "0" or "false", display names
   5856              * are not searched.  Default is "1".
   5857              */
   5858             public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name";
   5859 
   5860             /**
   5861              * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
   5862              * If "1" or "true", phone numbers are searched.  If "0" or "false", phone numbers
   5863              * are not searched.  Default is "1".
   5864              */
   5865             public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number";
   5866 
   5867             public static final int TYPE_HOME = 1;
   5868             public static final int TYPE_MOBILE = 2;
   5869             public static final int TYPE_WORK = 3;
   5870             public static final int TYPE_FAX_WORK = 4;
   5871             public static final int TYPE_FAX_HOME = 5;
   5872             public static final int TYPE_PAGER = 6;
   5873             public static final int TYPE_OTHER = 7;
   5874             public static final int TYPE_CALLBACK = 8;
   5875             public static final int TYPE_CAR = 9;
   5876             public static final int TYPE_COMPANY_MAIN = 10;
   5877             public static final int TYPE_ISDN = 11;
   5878             public static final int TYPE_MAIN = 12;
   5879             public static final int TYPE_OTHER_FAX = 13;
   5880             public static final int TYPE_RADIO = 14;
   5881             public static final int TYPE_TELEX = 15;
   5882             public static final int TYPE_TTY_TDD = 16;
   5883             public static final int TYPE_WORK_MOBILE = 17;
   5884             public static final int TYPE_WORK_PAGER = 18;
   5885             public static final int TYPE_ASSISTANT = 19;
   5886             public static final int TYPE_MMS = 20;
   5887 
   5888             /**
   5889              * The phone number as the user entered it.
   5890              * <P>Type: TEXT</P>
   5891              */
   5892             public static final String NUMBER = DATA;
   5893 
   5894             /**
   5895              * The phone number's E164 representation. This value can be omitted in which
   5896              * case the provider will try to automatically infer it.  (It'll be left null if the
   5897              * provider fails to infer.)
   5898              * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise).
   5899              * <P>Type: TEXT</P>
   5900              */
   5901             public static final String NORMALIZED_NUMBER = DATA4;
   5902 
   5903             /**
   5904              * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
   5905              * @hide
   5906              */
   5907             @Deprecated
   5908             public static final CharSequence getDisplayLabel(Context context, int type,
   5909                     CharSequence label, CharSequence[] labelArray) {
   5910                 return getTypeLabel(context.getResources(), type, label);
   5911             }
   5912 
   5913             /**
   5914              * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
   5915              * @hide
   5916              */
   5917             @Deprecated
   5918             public static final CharSequence getDisplayLabel(Context context, int type,
   5919                     CharSequence label) {
   5920                 return getTypeLabel(context.getResources(), type, label);
   5921             }
   5922 
   5923             /**
   5924              * Return the string resource that best describes the given
   5925              * {@link #TYPE}. Will always return a valid resource.
   5926              */
   5927             public static final int getTypeLabelResource(int type) {
   5928                 switch (type) {
   5929                     case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
   5930                     case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
   5931                     case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
   5932                     case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
   5933                     case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
   5934                     case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
   5935                     case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
   5936                     case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
   5937                     case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
   5938                     case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
   5939                     case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
   5940                     case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
   5941                     case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
   5942                     case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
   5943                     case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
   5944                     case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
   5945                     case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
   5946                     case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
   5947                     case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
   5948                     case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
   5949                     default: return com.android.internal.R.string.phoneTypeCustom;
   5950                 }
   5951             }
   5952 
   5953             /**
   5954              * Return a {@link CharSequence} that best describes the given type,
   5955              * possibly substituting the given {@link #LABEL} value
   5956              * for {@link #TYPE_CUSTOM}.
   5957              */
   5958             public static final CharSequence getTypeLabel(Resources res, int type,
   5959                     CharSequence label) {
   5960                 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
   5961                     return label;
   5962                 } else {
   5963                     final int labelRes = getTypeLabelResource(type);
   5964                     return res.getText(labelRes);
   5965                 }
   5966             }
   5967         }
   5968 
   5969         /**
   5970          * <p>
   5971          * A data kind representing an email address.
   5972          * </p>
   5973          * <p>
   5974          * You can use all columns defined for {@link ContactsContract.Data} as
   5975          * well as the following aliases.
   5976          * </p>
   5977          * <h2>Column aliases</h2>
   5978          * <table class="jd-sumtable">
   5979          * <tr>
   5980          * <th>Type</th>
   5981          * <th>Alias</th><th colspan='2'>Data column</th>
   5982          * </tr>
   5983          * <tr>
   5984          * <td>String</td>
   5985          * <td>{@link #ADDRESS}</td>
   5986          * <td>{@link #DATA1}</td>
   5987          * <td>Email address itself.</td>
   5988          * </tr>
   5989          * <tr>
   5990          * <td>int</td>
   5991          * <td>{@link #TYPE}</td>
   5992          * <td>{@link #DATA2}</td>
   5993          * <td>Allowed values are:
   5994          * <p>
   5995          * <ul>
   5996          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   5997          * <li>{@link #TYPE_HOME}</li>
   5998          * <li>{@link #TYPE_WORK}</li>
   5999          * <li>{@link #TYPE_OTHER}</li>
   6000          * <li>{@link #TYPE_MOBILE}</li>
   6001          * </ul>
   6002          * </p>
   6003          * </td>
   6004          * </tr>
   6005          * <tr>
   6006          * <td>String</td>
   6007          * <td>{@link #LABEL}</td>
   6008          * <td>{@link #DATA3}</td>
   6009          * <td></td>
   6010          * </tr>
   6011          * </table>
   6012          */
   6013         public static final class Email implements DataColumnsWithJoins, CommonColumns,
   6014                 ContactCounts {
   6015             /**
   6016              * This utility class cannot be instantiated
   6017              */
   6018             private Email() {}
   6019 
   6020             /** MIME type used when storing this in data table. */
   6021             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
   6022 
   6023             /**
   6024              * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
   6025              */
   6026             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
   6027 
   6028             /**
   6029              * The content:// style URI for all data records of the
   6030              * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
   6031              * associated raw contact and aggregate contact data.
   6032              */
   6033             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   6034                     "emails");
   6035 
   6036             /**
   6037              * <p>
   6038              * The content:// style URL for looking up data rows by email address. The
   6039              * lookup argument, an email address, should be passed as an additional path segment
   6040              * after this URI.
   6041              * </p>
   6042              * <p>Example:
   6043              * <pre>
   6044              * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
   6045              * Cursor c = getContentResolver().query(uri,
   6046              *          new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
   6047              *          null, null, null);
   6048              * </pre>
   6049              * </p>
   6050              */
   6051             public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
   6052                     "lookup");
   6053 
   6054             /**
   6055             * <p>URI used for enterprise email lookup.</p>
   6056             *
   6057             * <p>
   6058             * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same
   6059             * columns.  If the device has no corp profile that is linked to the current profile, it
   6060             * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}.  If there is a
   6061             * corp profile linked to the current profile, it first queries against the personal contact database,
   6062             * and if no matching contacts are found there, then queries against the
   6063             * corp contacts database.
   6064             * </p>
   6065             * <p>
   6066             * If a result is from the corp profile, it makes the following changes to the data:
   6067             * <ul>
   6068             *     <li>
   6069             *     {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
   6070             *     URIs.  Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
   6071             *     load pictures from them.
   6072             *     {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null.  Do not
   6073             *     use them.
   6074             *     </li>
   6075             *     <li>
   6076             *     Corp contacts will get artificial {@link #CONTACT_ID}s.  In order to tell whether
   6077             *     a contact
   6078             *     is from the corp profile, use
   6079             *     {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
   6080              *     </li>
   6081              *     <li>
   6082              *     Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
   6083              *     </li>
   6084              * </ul>
   6085              * <p>
   6086              * A contact lookup URL built by
   6087              * {@link ContactsContract.Contacts#getLookupUri(long, String)}
   6088              * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
   6089              * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
   6090              * corp profile.
   6091              * </p>
   6092             *
   6093             * <pre>
   6094             * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI,
   6095             *         Uri.encode(email));
   6096             * </pre>
   6097             */
   6098             public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI =
   6099                     Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise");
   6100 
   6101             /**
   6102              * <p>
   6103              * The content:// style URL for email lookup using a filter. The filter returns
   6104              * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
   6105              * to display names as well as email addresses. The filter argument should be passed
   6106              * as an additional path segment after this URI.
   6107              * </p>
   6108              * <p>The query in the following example will return "Robert Parr (bob (at) incredibles.com)"
   6109              * as well as "Bob Parr (incredible (at) android.com)".
   6110              * <pre>
   6111              * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
   6112              * Cursor c = getContentResolver().query(uri,
   6113              *          new String[]{Email.DISPLAY_NAME, Email.DATA},
   6114              *          null, null, null);
   6115              * </pre>
   6116              * </p>
   6117              */
   6118             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
   6119                     "filter");
   6120 
   6121             /**
   6122              * The email address.
   6123              * <P>Type: TEXT</P>
   6124              */
   6125             public static final String ADDRESS = DATA1;
   6126 
   6127             public static final int TYPE_HOME = 1;
   6128             public static final int TYPE_WORK = 2;
   6129             public static final int TYPE_OTHER = 3;
   6130             public static final int TYPE_MOBILE = 4;
   6131 
   6132             /**
   6133              * The display name for the email address
   6134              * <P>Type: TEXT</P>
   6135              */
   6136             public static final String DISPLAY_NAME = DATA4;
   6137 
   6138             /**
   6139              * Return the string resource that best describes the given
   6140              * {@link #TYPE}. Will always return a valid resource.
   6141              */
   6142             public static final int getTypeLabelResource(int type) {
   6143                 switch (type) {
   6144                     case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
   6145                     case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
   6146                     case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
   6147                     case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
   6148                     default: return com.android.internal.R.string.emailTypeCustom;
   6149                 }
   6150             }
   6151 
   6152             /**
   6153              * Return a {@link CharSequence} that best describes the given type,
   6154              * possibly substituting the given {@link #LABEL} value
   6155              * for {@link #TYPE_CUSTOM}.
   6156              */
   6157             public static final CharSequence getTypeLabel(Resources res, int type,
   6158                     CharSequence label) {
   6159                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6160                     return label;
   6161                 } else {
   6162                     final int labelRes = getTypeLabelResource(type);
   6163                     return res.getText(labelRes);
   6164                 }
   6165             }
   6166         }
   6167 
   6168         /**
   6169          * <p>
   6170          * A data kind representing a postal addresses.
   6171          * </p>
   6172          * <p>
   6173          * You can use all columns defined for {@link ContactsContract.Data} as
   6174          * well as the following aliases.
   6175          * </p>
   6176          * <h2>Column aliases</h2>
   6177          * <table class="jd-sumtable">
   6178          * <tr>
   6179          * <th>Type</th>
   6180          * <th>Alias</th><th colspan='2'>Data column</th>
   6181          * </tr>
   6182          * <tr>
   6183          * <td>String</td>
   6184          * <td>{@link #FORMATTED_ADDRESS}</td>
   6185          * <td>{@link #DATA1}</td>
   6186          * <td></td>
   6187          * </tr>
   6188          * <tr>
   6189          * <td>int</td>
   6190          * <td>{@link #TYPE}</td>
   6191          * <td>{@link #DATA2}</td>
   6192          * <td>Allowed values are:
   6193          * <p>
   6194          * <ul>
   6195          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6196          * <li>{@link #TYPE_HOME}</li>
   6197          * <li>{@link #TYPE_WORK}</li>
   6198          * <li>{@link #TYPE_OTHER}</li>
   6199          * </ul>
   6200          * </p>
   6201          * </td>
   6202          * </tr>
   6203          * <tr>
   6204          * <td>String</td>
   6205          * <td>{@link #LABEL}</td>
   6206          * <td>{@link #DATA3}</td>
   6207          * <td></td>
   6208          * </tr>
   6209          * <tr>
   6210          * <td>String</td>
   6211          * <td>{@link #STREET}</td>
   6212          * <td>{@link #DATA4}</td>
   6213          * <td></td>
   6214          * </tr>
   6215          * <tr>
   6216          * <td>String</td>
   6217          * <td>{@link #POBOX}</td>
   6218          * <td>{@link #DATA5}</td>
   6219          * <td>Post Office Box number</td>
   6220          * </tr>
   6221          * <tr>
   6222          * <td>String</td>
   6223          * <td>{@link #NEIGHBORHOOD}</td>
   6224          * <td>{@link #DATA6}</td>
   6225          * <td></td>
   6226          * </tr>
   6227          * <tr>
   6228          * <td>String</td>
   6229          * <td>{@link #CITY}</td>
   6230          * <td>{@link #DATA7}</td>
   6231          * <td></td>
   6232          * </tr>
   6233          * <tr>
   6234          * <td>String</td>
   6235          * <td>{@link #REGION}</td>
   6236          * <td>{@link #DATA8}</td>
   6237          * <td></td>
   6238          * </tr>
   6239          * <tr>
   6240          * <td>String</td>
   6241          * <td>{@link #POSTCODE}</td>
   6242          * <td>{@link #DATA9}</td>
   6243          * <td></td>
   6244          * </tr>
   6245          * <tr>
   6246          * <td>String</td>
   6247          * <td>{@link #COUNTRY}</td>
   6248          * <td>{@link #DATA10}</td>
   6249          * <td></td>
   6250          * </tr>
   6251          * </table>
   6252          */
   6253         public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns,
   6254                 ContactCounts {
   6255             /**
   6256              * This utility class cannot be instantiated
   6257              */
   6258             private StructuredPostal() {
   6259             }
   6260 
   6261             /** MIME type used when storing this in data table. */
   6262             public static final String CONTENT_ITEM_TYPE =
   6263                     "vnd.android.cursor.item/postal-address_v2";
   6264 
   6265             /**
   6266              * The MIME type of {@link #CONTENT_URI} providing a directory of
   6267              * postal addresses.
   6268              */
   6269             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
   6270 
   6271             /**
   6272              * The content:// style URI for all data records of the
   6273              * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
   6274              */
   6275             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   6276                     "postals");
   6277 
   6278             public static final int TYPE_HOME = 1;
   6279             public static final int TYPE_WORK = 2;
   6280             public static final int TYPE_OTHER = 3;
   6281 
   6282             /**
   6283              * The full, unstructured postal address. <i>This field must be
   6284              * consistent with any structured data.</i>
   6285              * <p>
   6286              * Type: TEXT
   6287              */
   6288             public static final String FORMATTED_ADDRESS = DATA;
   6289 
   6290             /**
   6291              * Can be street, avenue, road, etc. This element also includes the
   6292              * house number and room/apartment/flat/floor number.
   6293              * <p>
   6294              * Type: TEXT
   6295              */
   6296             public static final String STREET = DATA4;
   6297 
   6298             /**
   6299              * Covers actual P.O. boxes, drawers, locked bags, etc. This is
   6300              * usually but not always mutually exclusive with street.
   6301              * <p>
   6302              * Type: TEXT
   6303              */
   6304             public static final String POBOX = DATA5;
   6305 
   6306             /**
   6307              * This is used to disambiguate a street address when a city
   6308              * contains more than one street with the same name, or to specify a
   6309              * small place whose mail is routed through a larger postal town. In
   6310              * China it could be a county or a minor city.
   6311              * <p>
   6312              * Type: TEXT
   6313              */
   6314             public static final String NEIGHBORHOOD = DATA6;
   6315 
   6316             /**
   6317              * Can be city, village, town, borough, etc. This is the postal town
   6318              * and not necessarily the place of residence or place of business.
   6319              * <p>
   6320              * Type: TEXT
   6321              */
   6322             public static final String CITY = DATA7;
   6323 
   6324             /**
   6325              * A state, province, county (in Ireland), Land (in Germany),
   6326              * departement (in France), etc.
   6327              * <p>
   6328              * Type: TEXT
   6329              */
   6330             public static final String REGION = DATA8;
   6331 
   6332             /**
   6333              * Postal code. Usually country-wide, but sometimes specific to the
   6334              * city (e.g. "2" in "Dublin 2, Ireland" addresses).
   6335              * <p>
   6336              * Type: TEXT
   6337              */
   6338             public static final String POSTCODE = DATA9;
   6339 
   6340             /**
   6341              * The name or code of the country.
   6342              * <p>
   6343              * Type: TEXT
   6344              */
   6345             public static final String COUNTRY = DATA10;
   6346 
   6347             /**
   6348              * Return the string resource that best describes the given
   6349              * {@link #TYPE}. Will always return a valid resource.
   6350              */
   6351             public static final int getTypeLabelResource(int type) {
   6352                 switch (type) {
   6353                     case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
   6354                     case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
   6355                     case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
   6356                     default: return com.android.internal.R.string.postalTypeCustom;
   6357                 }
   6358             }
   6359 
   6360             /**
   6361              * Return a {@link CharSequence} that best describes the given type,
   6362              * possibly substituting the given {@link #LABEL} value
   6363              * for {@link #TYPE_CUSTOM}.
   6364              */
   6365             public static final CharSequence getTypeLabel(Resources res, int type,
   6366                     CharSequence label) {
   6367                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6368                     return label;
   6369                 } else {
   6370                     final int labelRes = getTypeLabelResource(type);
   6371                     return res.getText(labelRes);
   6372                 }
   6373             }
   6374         }
   6375 
   6376         /**
   6377          * <p>
   6378          * A data kind representing an IM address
   6379          * </p>
   6380          * <p>
   6381          * You can use all columns defined for {@link ContactsContract.Data} as
   6382          * well as the following aliases.
   6383          * </p>
   6384          * <h2>Column aliases</h2>
   6385          * <table class="jd-sumtable">
   6386          * <tr>
   6387          * <th>Type</th>
   6388          * <th>Alias</th><th colspan='2'>Data column</th>
   6389          * </tr>
   6390          * <tr>
   6391          * <td>String</td>
   6392          * <td>{@link #DATA}</td>
   6393          * <td>{@link #DATA1}</td>
   6394          * <td></td>
   6395          * </tr>
   6396          * <tr>
   6397          * <td>int</td>
   6398          * <td>{@link #TYPE}</td>
   6399          * <td>{@link #DATA2}</td>
   6400          * <td>Allowed values are:
   6401          * <p>
   6402          * <ul>
   6403          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6404          * <li>{@link #TYPE_HOME}</li>
   6405          * <li>{@link #TYPE_WORK}</li>
   6406          * <li>{@link #TYPE_OTHER}</li>
   6407          * </ul>
   6408          * </p>
   6409          * </td>
   6410          * </tr>
   6411          * <tr>
   6412          * <td>String</td>
   6413          * <td>{@link #LABEL}</td>
   6414          * <td>{@link #DATA3}</td>
   6415          * <td></td>
   6416          * </tr>
   6417          * <tr>
   6418          * <td>String</td>
   6419          * <td>{@link #PROTOCOL}</td>
   6420          * <td>{@link #DATA5}</td>
   6421          * <td>
   6422          * <p>
   6423          * Allowed values:
   6424          * <ul>
   6425          * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
   6426          * as {@link #CUSTOM_PROTOCOL}.</li>
   6427          * <li>{@link #PROTOCOL_AIM}</li>
   6428          * <li>{@link #PROTOCOL_MSN}</li>
   6429          * <li>{@link #PROTOCOL_YAHOO}</li>
   6430          * <li>{@link #PROTOCOL_SKYPE}</li>
   6431          * <li>{@link #PROTOCOL_QQ}</li>
   6432          * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
   6433          * <li>{@link #PROTOCOL_ICQ}</li>
   6434          * <li>{@link #PROTOCOL_JABBER}</li>
   6435          * <li>{@link #PROTOCOL_NETMEETING}</li>
   6436          * </ul>
   6437          * </p>
   6438          * </td>
   6439          * </tr>
   6440          * <tr>
   6441          * <td>String</td>
   6442          * <td>{@link #CUSTOM_PROTOCOL}</td>
   6443          * <td>{@link #DATA6}</td>
   6444          * <td></td>
   6445          * </tr>
   6446          * </table>
   6447          */
   6448         public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts {
   6449             /**
   6450              * This utility class cannot be instantiated
   6451              */
   6452             private Im() {}
   6453 
   6454             /** MIME type used when storing this in data table. */
   6455             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
   6456 
   6457             public static final int TYPE_HOME = 1;
   6458             public static final int TYPE_WORK = 2;
   6459             public static final int TYPE_OTHER = 3;
   6460 
   6461             /**
   6462              * This column should be populated with one of the defined
   6463              * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
   6464              * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
   6465              * should contain the name of the custom protocol.
   6466              */
   6467             public static final String PROTOCOL = DATA5;
   6468 
   6469             public static final String CUSTOM_PROTOCOL = DATA6;
   6470 
   6471             /*
   6472              * The predefined IM protocol types.
   6473              */
   6474             public static final int PROTOCOL_CUSTOM = -1;
   6475             public static final int PROTOCOL_AIM = 0;
   6476             public static final int PROTOCOL_MSN = 1;
   6477             public static final int PROTOCOL_YAHOO = 2;
   6478             public static final int PROTOCOL_SKYPE = 3;
   6479             public static final int PROTOCOL_QQ = 4;
   6480             public static final int PROTOCOL_GOOGLE_TALK = 5;
   6481             public static final int PROTOCOL_ICQ = 6;
   6482             public static final int PROTOCOL_JABBER = 7;
   6483             public static final int PROTOCOL_NETMEETING = 8;
   6484 
   6485             /**
   6486              * Return the string resource that best describes the given
   6487              * {@link #TYPE}. Will always return a valid resource.
   6488              */
   6489             public static final int getTypeLabelResource(int type) {
   6490                 switch (type) {
   6491                     case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
   6492                     case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
   6493                     case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
   6494                     default: return com.android.internal.R.string.imTypeCustom;
   6495                 }
   6496             }
   6497 
   6498             /**
   6499              * Return a {@link CharSequence} that best describes the given type,
   6500              * possibly substituting the given {@link #LABEL} value
   6501              * for {@link #TYPE_CUSTOM}.
   6502              */
   6503             public static final CharSequence getTypeLabel(Resources res, int type,
   6504                     CharSequence label) {
   6505                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6506                     return label;
   6507                 } else {
   6508                     final int labelRes = getTypeLabelResource(type);
   6509                     return res.getText(labelRes);
   6510                 }
   6511             }
   6512 
   6513             /**
   6514              * Return the string resource that best describes the given
   6515              * {@link #PROTOCOL}. Will always return a valid resource.
   6516              */
   6517             public static final int getProtocolLabelResource(int type) {
   6518                 switch (type) {
   6519                     case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
   6520                     case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
   6521                     case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
   6522                     case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
   6523                     case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
   6524                     case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
   6525                     case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
   6526                     case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
   6527                     case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
   6528                     default: return com.android.internal.R.string.imProtocolCustom;
   6529                 }
   6530             }
   6531 
   6532             /**
   6533              * Return a {@link CharSequence} that best describes the given
   6534              * protocol, possibly substituting the given
   6535              * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
   6536              */
   6537             public static final CharSequence getProtocolLabel(Resources res, int type,
   6538                     CharSequence label) {
   6539                 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
   6540                     return label;
   6541                 } else {
   6542                     final int labelRes = getProtocolLabelResource(type);
   6543                     return res.getText(labelRes);
   6544                 }
   6545             }
   6546         }
   6547 
   6548         /**
   6549          * <p>
   6550          * A data kind representing an organization.
   6551          * </p>
   6552          * <p>
   6553          * You can use all columns defined for {@link ContactsContract.Data} as
   6554          * well as the following aliases.
   6555          * </p>
   6556          * <h2>Column aliases</h2>
   6557          * <table class="jd-sumtable">
   6558          * <tr>
   6559          * <th>Type</th>
   6560          * <th>Alias</th><th colspan='2'>Data column</th>
   6561          * </tr>
   6562          * <tr>
   6563          * <td>String</td>
   6564          * <td>{@link #COMPANY}</td>
   6565          * <td>{@link #DATA1}</td>
   6566          * <td></td>
   6567          * </tr>
   6568          * <tr>
   6569          * <td>int</td>
   6570          * <td>{@link #TYPE}</td>
   6571          * <td>{@link #DATA2}</td>
   6572          * <td>Allowed values are:
   6573          * <p>
   6574          * <ul>
   6575          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6576          * <li>{@link #TYPE_WORK}</li>
   6577          * <li>{@link #TYPE_OTHER}</li>
   6578          * </ul>
   6579          * </p>
   6580          * </td>
   6581          * </tr>
   6582          * <tr>
   6583          * <td>String</td>
   6584          * <td>{@link #LABEL}</td>
   6585          * <td>{@link #DATA3}</td>
   6586          * <td></td>
   6587          * </tr>
   6588          * <tr>
   6589          * <td>String</td>
   6590          * <td>{@link #TITLE}</td>
   6591          * <td>{@link #DATA4}</td>
   6592          * <td></td>
   6593          * </tr>
   6594          * <tr>
   6595          * <td>String</td>
   6596          * <td>{@link #DEPARTMENT}</td>
   6597          * <td>{@link #DATA5}</td>
   6598          * <td></td>
   6599          * </tr>
   6600          * <tr>
   6601          * <td>String</td>
   6602          * <td>{@link #JOB_DESCRIPTION}</td>
   6603          * <td>{@link #DATA6}</td>
   6604          * <td></td>
   6605          * </tr>
   6606          * <tr>
   6607          * <td>String</td>
   6608          * <td>{@link #SYMBOL}</td>
   6609          * <td>{@link #DATA7}</td>
   6610          * <td></td>
   6611          * </tr>
   6612          * <tr>
   6613          * <td>String</td>
   6614          * <td>{@link #PHONETIC_NAME}</td>
   6615          * <td>{@link #DATA8}</td>
   6616          * <td></td>
   6617          * </tr>
   6618          * <tr>
   6619          * <td>String</td>
   6620          * <td>{@link #OFFICE_LOCATION}</td>
   6621          * <td>{@link #DATA9}</td>
   6622          * <td></td>
   6623          * </tr>
   6624          * <tr>
   6625          * <td>String</td>
   6626          * <td>PHONETIC_NAME_STYLE</td>
   6627          * <td>{@link #DATA10}</td>
   6628          * <td></td>
   6629          * </tr>
   6630          * </table>
   6631          */
   6632         public static final class Organization implements DataColumnsWithJoins, CommonColumns,
   6633                 ContactCounts {
   6634             /**
   6635              * This utility class cannot be instantiated
   6636              */
   6637             private Organization() {}
   6638 
   6639             /** MIME type used when storing this in data table. */
   6640             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
   6641 
   6642             public static final int TYPE_WORK = 1;
   6643             public static final int TYPE_OTHER = 2;
   6644 
   6645             /**
   6646              * The company as the user entered it.
   6647              * <P>Type: TEXT</P>
   6648              */
   6649             public static final String COMPANY = DATA;
   6650 
   6651             /**
   6652              * The position title at this company as the user entered it.
   6653              * <P>Type: TEXT</P>
   6654              */
   6655             public static final String TITLE = DATA4;
   6656 
   6657             /**
   6658              * The department at this company as the user entered it.
   6659              * <P>Type: TEXT</P>
   6660              */
   6661             public static final String DEPARTMENT = DATA5;
   6662 
   6663             /**
   6664              * The job description at this company as the user entered it.
   6665              * <P>Type: TEXT</P>
   6666              */
   6667             public static final String JOB_DESCRIPTION = DATA6;
   6668 
   6669             /**
   6670              * The symbol of this company as the user entered it.
   6671              * <P>Type: TEXT</P>
   6672              */
   6673             public static final String SYMBOL = DATA7;
   6674 
   6675             /**
   6676              * The phonetic name of this company as the user entered it.
   6677              * <P>Type: TEXT</P>
   6678              */
   6679             public static final String PHONETIC_NAME = DATA8;
   6680 
   6681             /**
   6682              * The office location of this organization.
   6683              * <P>Type: TEXT</P>
   6684              */
   6685             public static final String OFFICE_LOCATION = DATA9;
   6686 
   6687             /**
   6688              * The alphabet used for capturing the phonetic name.
   6689              * See {@link ContactsContract.PhoneticNameStyle}.
   6690              * @hide
   6691              */
   6692             public static final String PHONETIC_NAME_STYLE = DATA10;
   6693 
   6694             /**
   6695              * Return the string resource that best describes the given
   6696              * {@link #TYPE}. Will always return a valid resource.
   6697              */
   6698             public static final int getTypeLabelResource(int type) {
   6699                 switch (type) {
   6700                     case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
   6701                     case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
   6702                     default: return com.android.internal.R.string.orgTypeCustom;
   6703                 }
   6704             }
   6705 
   6706             /**
   6707              * Return a {@link CharSequence} that best describes the given type,
   6708              * possibly substituting the given {@link #LABEL} value
   6709              * for {@link #TYPE_CUSTOM}.
   6710              */
   6711             public static final CharSequence getTypeLabel(Resources res, int type,
   6712                     CharSequence label) {
   6713                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6714                     return label;
   6715                 } else {
   6716                     final int labelRes = getTypeLabelResource(type);
   6717                     return res.getText(labelRes);
   6718                 }
   6719             }
   6720         }
   6721 
   6722         /**
   6723          * <p>
   6724          * A data kind representing a relation.
   6725          * </p>
   6726          * <p>
   6727          * You can use all columns defined for {@link ContactsContract.Data} as
   6728          * well as the following aliases.
   6729          * </p>
   6730          * <h2>Column aliases</h2>
   6731          * <table class="jd-sumtable">
   6732          * <tr>
   6733          * <th>Type</th>
   6734          * <th>Alias</th><th colspan='2'>Data column</th>
   6735          * </tr>
   6736          * <tr>
   6737          * <td>String</td>
   6738          * <td>{@link #NAME}</td>
   6739          * <td>{@link #DATA1}</td>
   6740          * <td></td>
   6741          * </tr>
   6742          * <tr>
   6743          * <td>int</td>
   6744          * <td>{@link #TYPE}</td>
   6745          * <td>{@link #DATA2}</td>
   6746          * <td>Allowed values are:
   6747          * <p>
   6748          * <ul>
   6749          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6750          * <li>{@link #TYPE_ASSISTANT}</li>
   6751          * <li>{@link #TYPE_BROTHER}</li>
   6752          * <li>{@link #TYPE_CHILD}</li>
   6753          * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
   6754          * <li>{@link #TYPE_FATHER}</li>
   6755          * <li>{@link #TYPE_FRIEND}</li>
   6756          * <li>{@link #TYPE_MANAGER}</li>
   6757          * <li>{@link #TYPE_MOTHER}</li>
   6758          * <li>{@link #TYPE_PARENT}</li>
   6759          * <li>{@link #TYPE_PARTNER}</li>
   6760          * <li>{@link #TYPE_REFERRED_BY}</li>
   6761          * <li>{@link #TYPE_RELATIVE}</li>
   6762          * <li>{@link #TYPE_SISTER}</li>
   6763          * <li>{@link #TYPE_SPOUSE}</li>
   6764          * </ul>
   6765          * </p>
   6766          * </td>
   6767          * </tr>
   6768          * <tr>
   6769          * <td>String</td>
   6770          * <td>{@link #LABEL}</td>
   6771          * <td>{@link #DATA3}</td>
   6772          * <td></td>
   6773          * </tr>
   6774          * </table>
   6775          */
   6776         public static final class Relation implements DataColumnsWithJoins, CommonColumns,
   6777                 ContactCounts {
   6778             /**
   6779              * This utility class cannot be instantiated
   6780              */
   6781             private Relation() {}
   6782 
   6783             /** MIME type used when storing this in data table. */
   6784             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
   6785 
   6786             public static final int TYPE_ASSISTANT = 1;
   6787             public static final int TYPE_BROTHER = 2;
   6788             public static final int TYPE_CHILD = 3;
   6789             public static final int TYPE_DOMESTIC_PARTNER = 4;
   6790             public static final int TYPE_FATHER = 5;
   6791             public static final int TYPE_FRIEND = 6;
   6792             public static final int TYPE_MANAGER = 7;
   6793             public static final int TYPE_MOTHER = 8;
   6794             public static final int TYPE_PARENT = 9;
   6795             public static final int TYPE_PARTNER = 10;
   6796             public static final int TYPE_REFERRED_BY = 11;
   6797             public static final int TYPE_RELATIVE = 12;
   6798             public static final int TYPE_SISTER = 13;
   6799             public static final int TYPE_SPOUSE = 14;
   6800 
   6801             /**
   6802              * The name of the relative as the user entered it.
   6803              * <P>Type: TEXT</P>
   6804              */
   6805             public static final String NAME = DATA;
   6806 
   6807             /**
   6808              * Return the string resource that best describes the given
   6809              * {@link #TYPE}. Will always return a valid resource.
   6810              */
   6811             public static final int getTypeLabelResource(int type) {
   6812                 switch (type) {
   6813                     case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant;
   6814                     case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother;
   6815                     case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild;
   6816                     case TYPE_DOMESTIC_PARTNER:
   6817                             return com.android.internal.R.string.relationTypeDomesticPartner;
   6818                     case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather;
   6819                     case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend;
   6820                     case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager;
   6821                     case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother;
   6822                     case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent;
   6823                     case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner;
   6824                     case TYPE_REFERRED_BY:
   6825                             return com.android.internal.R.string.relationTypeReferredBy;
   6826                     case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative;
   6827                     case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister;
   6828                     case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse;
   6829                     default: return com.android.internal.R.string.orgTypeCustom;
   6830                 }
   6831             }
   6832 
   6833             /**
   6834              * Return a {@link CharSequence} that best describes the given type,
   6835              * possibly substituting the given {@link #LABEL} value
   6836              * for {@link #TYPE_CUSTOM}.
   6837              */
   6838             public static final CharSequence getTypeLabel(Resources res, int type,
   6839                     CharSequence label) {
   6840                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6841                     return label;
   6842                 } else {
   6843                     final int labelRes = getTypeLabelResource(type);
   6844                     return res.getText(labelRes);
   6845                 }
   6846             }
   6847         }
   6848 
   6849         /**
   6850          * <p>
   6851          * A data kind representing an event.
   6852          * </p>
   6853          * <p>
   6854          * You can use all columns defined for {@link ContactsContract.Data} as
   6855          * well as the following aliases.
   6856          * </p>
   6857          * <h2>Column aliases</h2>
   6858          * <table class="jd-sumtable">
   6859          * <tr>
   6860          * <th>Type</th>
   6861          * <th>Alias</th><th colspan='2'>Data column</th>
   6862          * </tr>
   6863          * <tr>
   6864          * <td>String</td>
   6865          * <td>{@link #START_DATE}</td>
   6866          * <td>{@link #DATA1}</td>
   6867          * <td></td>
   6868          * </tr>
   6869          * <tr>
   6870          * <td>int</td>
   6871          * <td>{@link #TYPE}</td>
   6872          * <td>{@link #DATA2}</td>
   6873          * <td>Allowed values are:
   6874          * <p>
   6875          * <ul>
   6876          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6877          * <li>{@link #TYPE_ANNIVERSARY}</li>
   6878          * <li>{@link #TYPE_OTHER}</li>
   6879          * <li>{@link #TYPE_BIRTHDAY}</li>
   6880          * </ul>
   6881          * </p>
   6882          * </td>
   6883          * </tr>
   6884          * <tr>
   6885          * <td>String</td>
   6886          * <td>{@link #LABEL}</td>
   6887          * <td>{@link #DATA3}</td>
   6888          * <td></td>
   6889          * </tr>
   6890          * </table>
   6891          */
   6892         public static final class Event implements DataColumnsWithJoins, CommonColumns,
   6893                 ContactCounts {
   6894             /**
   6895              * This utility class cannot be instantiated
   6896              */
   6897             private Event() {}
   6898 
   6899             /** MIME type used when storing this in data table. */
   6900             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
   6901 
   6902             public static final int TYPE_ANNIVERSARY = 1;
   6903             public static final int TYPE_OTHER = 2;
   6904             public static final int TYPE_BIRTHDAY = 3;
   6905 
   6906             /**
   6907              * The event start date as the user entered it.
   6908              * <P>Type: TEXT</P>
   6909              */
   6910             public static final String START_DATE = DATA;
   6911 
   6912             /**
   6913              * Return the string resource that best describes the given
   6914              * {@link #TYPE}. Will always return a valid resource.
   6915              */
   6916             public static int getTypeResource(Integer type) {
   6917                 if (type == null) {
   6918                     return com.android.internal.R.string.eventTypeOther;
   6919                 }
   6920                 switch (type) {
   6921                     case TYPE_ANNIVERSARY:
   6922                         return com.android.internal.R.string.eventTypeAnniversary;
   6923                     case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
   6924                     case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
   6925                     default: return com.android.internal.R.string.eventTypeCustom;
   6926                 }
   6927             }
   6928 
   6929             /**
   6930              * Return a {@link CharSequence} that best describes the given type,
   6931              * possibly substituting the given {@link #LABEL} value
   6932              * for {@link #TYPE_CUSTOM}.
   6933              */
   6934             public static final CharSequence getTypeLabel(Resources res, int type,
   6935                     CharSequence label) {
   6936                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6937                     return label;
   6938                 } else {
   6939                     final int labelRes = getTypeResource(type);
   6940                     return res.getText(labelRes);
   6941                 }
   6942             }
   6943         }
   6944 
   6945         /**
   6946          * <p>
   6947          * A data kind representing a photo for the contact.
   6948          * </p>
   6949          * <p>
   6950          * Some sync adapters will choose to download photos in a separate
   6951          * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
   6952          * through {@link ContactsContract.Data#SYNC4} to store temporary
   6953          * data, e.g. the image URL or ID, state of download, server-side version
   6954          * of the image.  It is allowed for the {@link #PHOTO} to be null.
   6955          * </p>
   6956          * <p>
   6957          * You can use all columns defined for {@link ContactsContract.Data} as
   6958          * well as the following aliases.
   6959          * </p>
   6960          * <h2>Column aliases</h2>
   6961          * <table class="jd-sumtable">
   6962          * <tr>
   6963          * <th>Type</th>
   6964          * <th>Alias</th><th colspan='2'>Data column</th>
   6965          * </tr>
   6966          * <tr>
   6967          * <td>NUMBER</td>
   6968          * <td>{@link #PHOTO_FILE_ID}</td>
   6969          * <td>{@link #DATA14}</td>
   6970          * <td>ID of the hi-res photo file.</td>
   6971          * </tr>
   6972          * <tr>
   6973          * <td>BLOB</td>
   6974          * <td>{@link #PHOTO}</td>
   6975          * <td>{@link #DATA15}</td>
   6976          * <td>By convention, binary data is stored in DATA15.  The thumbnail of the
   6977          * photo is stored in this column.</td>
   6978          * </tr>
   6979          * </table>
   6980          */
   6981         public static final class Photo implements DataColumnsWithJoins, ContactCounts {
   6982             /**
   6983              * This utility class cannot be instantiated
   6984              */
   6985             private Photo() {}
   6986 
   6987             /** MIME type used when storing this in data table. */
   6988             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
   6989 
   6990             /**
   6991              * Photo file ID for the display photo of the raw contact.
   6992              * See {@link ContactsContract.DisplayPhoto}.
   6993              * <p>
   6994              * Type: NUMBER
   6995              */
   6996             public static final String PHOTO_FILE_ID = DATA14;
   6997 
   6998             /**
   6999              * Thumbnail photo of the raw contact. This is the raw bytes of an image
   7000              * that could be inflated using {@link android.graphics.BitmapFactory}.
   7001              * <p>
   7002              * Type: BLOB
   7003              */
   7004             public static final String PHOTO = DATA15;
   7005         }
   7006 
   7007         /**
   7008          * <p>
   7009          * Notes about the contact.
   7010          * </p>
   7011          * <p>
   7012          * You can use all columns defined for {@link ContactsContract.Data} as
   7013          * well as the following aliases.
   7014          * </p>
   7015          * <h2>Column aliases</h2>
   7016          * <table class="jd-sumtable">
   7017          * <tr>
   7018          * <th>Type</th>
   7019          * <th>Alias</th><th colspan='2'>Data column</th>
   7020          * </tr>
   7021          * <tr>
   7022          * <td>String</td>
   7023          * <td>{@link #NOTE}</td>
   7024          * <td>{@link #DATA1}</td>
   7025          * <td></td>
   7026          * </tr>
   7027          * </table>
   7028          */
   7029         public static final class Note implements DataColumnsWithJoins, ContactCounts {
   7030             /**
   7031              * This utility class cannot be instantiated
   7032              */
   7033             private Note() {}
   7034 
   7035             /** MIME type used when storing this in data table. */
   7036             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
   7037 
   7038             /**
   7039              * The note text.
   7040              * <P>Type: TEXT</P>
   7041              */
   7042             public static final String NOTE = DATA1;
   7043         }
   7044 
   7045         /**
   7046          * <p>
   7047          * Group Membership.
   7048          * </p>
   7049          * <p>
   7050          * You can use all columns defined for {@link ContactsContract.Data} as
   7051          * well as the following aliases.
   7052          * </p>
   7053          * <h2>Column aliases</h2>
   7054          * <table class="jd-sumtable">
   7055          * <tr>
   7056          * <th>Type</th>
   7057          * <th>Alias</th><th colspan='2'>Data column</th>
   7058          * </tr>
   7059          * <tr>
   7060          * <td>long</td>
   7061          * <td>{@link #GROUP_ROW_ID}</td>
   7062          * <td>{@link #DATA1}</td>
   7063          * <td></td>
   7064          * </tr>
   7065          * <tr>
   7066          * <td>String</td>
   7067          * <td>{@link #GROUP_SOURCE_ID}</td>
   7068          * <td>none</td>
   7069          * <td>
   7070          * <p>
   7071          * The sourceid of the group that this group membership refers to.
   7072          * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
   7073          * inserting a row.
   7074          * </p>
   7075          * <p>
   7076          * If this field is specified, the provider will first try to
   7077          * look up a group with this {@link Groups Groups.SOURCE_ID}.  If such a group
   7078          * is found, it will use the corresponding row id.  If the group is not
   7079          * found, it will create one.
   7080          * </td>
   7081          * </tr>
   7082          * </table>
   7083          */
   7084         public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts {
   7085             /**
   7086              * This utility class cannot be instantiated
   7087              */
   7088             private GroupMembership() {}
   7089 
   7090             /** MIME type used when storing this in data table. */
   7091             public static final String CONTENT_ITEM_TYPE =
   7092                     "vnd.android.cursor.item/group_membership";
   7093 
   7094             /**
   7095              * The row id of the group that this group membership refers to. Exactly one of
   7096              * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
   7097              * <P>Type: INTEGER</P>
   7098              */
   7099             public static final String GROUP_ROW_ID = DATA1;
   7100 
   7101             /**
   7102              * The sourceid of the group that this group membership refers to.  Exactly one of
   7103              * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
   7104              * <P>Type: TEXT</P>
   7105              */
   7106             public static final String GROUP_SOURCE_ID = "group_sourceid";
   7107         }
   7108 
   7109         /**
   7110          * <p>
   7111          * A data kind representing a website related to the contact.
   7112          * </p>
   7113          * <p>
   7114          * You can use all columns defined for {@link ContactsContract.Data} as
   7115          * well as the following aliases.
   7116          * </p>
   7117          * <h2>Column aliases</h2>
   7118          * <table class="jd-sumtable">
   7119          * <tr>
   7120          * <th>Type</th>
   7121          * <th>Alias</th><th colspan='2'>Data column</th>
   7122          * </tr>
   7123          * <tr>
   7124          * <td>String</td>
   7125          * <td>{@link #URL}</td>
   7126          * <td>{@link #DATA1}</td>
   7127          * <td></td>
   7128          * </tr>
   7129          * <tr>
   7130          * <td>int</td>
   7131          * <td>{@link #TYPE}</td>
   7132          * <td>{@link #DATA2}</td>
   7133          * <td>Allowed values are:
   7134          * <p>
   7135          * <ul>
   7136          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   7137          * <li>{@link #TYPE_HOMEPAGE}</li>
   7138          * <li>{@link #TYPE_BLOG}</li>
   7139          * <li>{@link #TYPE_PROFILE}</li>
   7140          * <li>{@link #TYPE_HOME}</li>
   7141          * <li>{@link #TYPE_WORK}</li>
   7142          * <li>{@link #TYPE_FTP}</li>
   7143          * <li>{@link #TYPE_OTHER}</li>
   7144          * </ul>
   7145          * </p>
   7146          * </td>
   7147          * </tr>
   7148          * <tr>
   7149          * <td>String</td>
   7150          * <td>{@link #LABEL}</td>
   7151          * <td>{@link #DATA3}</td>
   7152          * <td></td>
   7153          * </tr>
   7154          * </table>
   7155          */
   7156         public static final class Website implements DataColumnsWithJoins, CommonColumns,
   7157                 ContactCounts {
   7158             /**
   7159              * This utility class cannot be instantiated
   7160              */
   7161             private Website() {}
   7162 
   7163             /** MIME type used when storing this in data table. */
   7164             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
   7165 
   7166             public static final int TYPE_HOMEPAGE = 1;
   7167             public static final int TYPE_BLOG = 2;
   7168             public static final int TYPE_PROFILE = 3;
   7169             public static final int TYPE_HOME = 4;
   7170             public static final int TYPE_WORK = 5;
   7171             public static final int TYPE_FTP = 6;
   7172             public static final int TYPE_OTHER = 7;
   7173 
   7174             /**
   7175              * The website URL string.
   7176              * <P>Type: TEXT</P>
   7177              */
   7178             public static final String URL = DATA;
   7179         }
   7180 
   7181         /**
   7182          * <p>
   7183          * A data kind representing a SIP address for the contact.
   7184          * </p>
   7185          * <p>
   7186          * You can use all columns defined for {@link ContactsContract.Data} as
   7187          * well as the following aliases.
   7188          * </p>
   7189          * <h2>Column aliases</h2>
   7190          * <table class="jd-sumtable">
   7191          * <tr>
   7192          * <th>Type</th>
   7193          * <th>Alias</th><th colspan='2'>Data column</th>
   7194          * </tr>
   7195          * <tr>
   7196          * <td>String</td>
   7197          * <td>{@link #SIP_ADDRESS}</td>
   7198          * <td>{@link #DATA1}</td>
   7199          * <td></td>
   7200          * </tr>
   7201          * <tr>
   7202          * <td>int</td>
   7203          * <td>{@link #TYPE}</td>
   7204          * <td>{@link #DATA2}</td>
   7205          * <td>Allowed values are:
   7206          * <p>
   7207          * <ul>
   7208          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   7209          * <li>{@link #TYPE_HOME}</li>
   7210          * <li>{@link #TYPE_WORK}</li>
   7211          * <li>{@link #TYPE_OTHER}</li>
   7212          * </ul>
   7213          * </p>
   7214          * </td>
   7215          * </tr>
   7216          * <tr>
   7217          * <td>String</td>
   7218          * <td>{@link #LABEL}</td>
   7219          * <td>{@link #DATA3}</td>
   7220          * <td></td>
   7221          * </tr>
   7222          * </table>
   7223          */
   7224         public static final class SipAddress implements DataColumnsWithJoins, CommonColumns,
   7225                 ContactCounts {
   7226             /**
   7227              * This utility class cannot be instantiated
   7228              */
   7229             private SipAddress() {}
   7230 
   7231             /** MIME type used when storing this in data table. */
   7232             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address";
   7233 
   7234             public static final int TYPE_HOME = 1;
   7235             public static final int TYPE_WORK = 2;
   7236             public static final int TYPE_OTHER = 3;
   7237 
   7238             /**
   7239              * The SIP address.
   7240              * <P>Type: TEXT</P>
   7241              */
   7242             public static final String SIP_ADDRESS = DATA1;
   7243             // ...and TYPE and LABEL come from the CommonColumns interface.
   7244 
   7245             /**
   7246              * Return the string resource that best describes the given
   7247              * {@link #TYPE}. Will always return a valid resource.
   7248              */
   7249             public static final int getTypeLabelResource(int type) {
   7250                 switch (type) {
   7251                     case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome;
   7252                     case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork;
   7253                     case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther;
   7254                     default: return com.android.internal.R.string.sipAddressTypeCustom;
   7255                 }
   7256             }
   7257 
   7258             /**
   7259              * Return a {@link CharSequence} that best describes the given type,
   7260              * possibly substituting the given {@link #LABEL} value
   7261              * for {@link #TYPE_CUSTOM}.
   7262              */
   7263             public static final CharSequence getTypeLabel(Resources res, int type,
   7264                     CharSequence label) {
   7265                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   7266                     return label;
   7267                 } else {
   7268                     final int labelRes = getTypeLabelResource(type);
   7269                     return res.getText(labelRes);
   7270                 }
   7271             }
   7272         }
   7273 
   7274         /**
   7275          * A data kind representing an Identity related to the contact.
   7276          * <p>
   7277          * This can be used as a signal by the aggregator to combine raw contacts into
   7278          * contacts, e.g. if two contacts have Identity rows with
   7279          * the same NAMESPACE and IDENTITY values the aggregator can know that they refer
   7280          * to the same person.
   7281          * </p>
   7282          */
   7283         public static final class Identity implements DataColumnsWithJoins, ContactCounts {
   7284             /**
   7285              * This utility class cannot be instantiated
   7286              */
   7287             private Identity() {}
   7288 
   7289             /** MIME type used when storing this in data table. */
   7290             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity";
   7291 
   7292             /**
   7293              * The identity string.
   7294              * <P>Type: TEXT</P>
   7295              */
   7296             public static final String IDENTITY = DataColumns.DATA1;
   7297 
   7298             /**
   7299              * The namespace of the identity string, e.g. "com.google"
   7300              * <P>Type: TEXT</P>
   7301              */
   7302             public static final String NAMESPACE = DataColumns.DATA2;
   7303         }
   7304 
   7305         /**
   7306          * <p>
   7307          * Convenient functionalities for "callable" data. Note that, this is NOT a separate data
   7308          * kind.
   7309          * </p>
   7310          * <p>
   7311          * This URI allows the ContactsProvider to return a unified result for "callable" data
   7312          * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the
   7313          * current examples for "callable", but may be expanded to the other types.
   7314          * </p>
   7315          * <p>
   7316          * Each returned row may have a different MIMETYPE and thus different interpretation for
   7317          * each column. For example the meaning for {@link Phone}'s type is different than
   7318          * {@link SipAddress}'s.
   7319          * </p>
   7320          */
   7321         public static final class Callable implements DataColumnsWithJoins, CommonColumns,
   7322                 ContactCounts {
   7323             /**
   7324              * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only
   7325              * phone numbers.
   7326              */
   7327             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   7328                     "callables");
   7329             /**
   7330              * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable
   7331              * data.
   7332              */
   7333             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
   7334                     "filter");
   7335         }
   7336 
   7337         /**
   7338          * A special class of data items, used to refer to types of data that can be used to attempt
   7339          * to start communicating with a person ({@link Phone} and {@link Email}). Note that this
   7340          * is NOT a separate data kind.
   7341          *
   7342          * This URI allows the ContactsProvider to return a unified result for data items that users
   7343          * can use to initiate communications with another contact. {@link Phone} and {@link Email}
   7344          * are the current data types in this category.
   7345          */
   7346         public static final class Contactables implements DataColumnsWithJoins, CommonColumns,
   7347                 ContactCounts {
   7348             /**
   7349              * The content:// style URI for these data items, which requests a directory of data
   7350              * rows matching the selection criteria.
   7351              */
   7352             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   7353                     "contactables");
   7354 
   7355             /**
   7356              * The content:// style URI for these data items, which allows for a query parameter to
   7357              * be appended onto the end to filter for data items matching the query.
   7358              */
   7359             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
   7360                     Contactables.CONTENT_URI, "filter");
   7361 
   7362             /**
   7363              * A boolean parameter for {@link Data#CONTENT_URI}.
   7364              * This specifies whether or not the returned data items should be filtered to show
   7365              * data items belonging to visible contacts only.
   7366              */
   7367             public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
   7368         }
   7369     }
   7370 
   7371     /**
   7372      * @see Groups
   7373      */
   7374     protected interface GroupsColumns {
   7375         /**
   7376          * The data set within the account that this group belongs to.  This allows
   7377          * multiple sync adapters for the same account type to distinguish between
   7378          * each others' group data.
   7379          *
   7380          * This is empty by default, and is completely optional.  It only needs to
   7381          * be populated if multiple sync adapters are entering distinct group data
   7382          * for the same account type and account name.
   7383          * <P>Type: TEXT</P>
   7384          */
   7385         public static final String DATA_SET = "data_set";
   7386 
   7387         /**
   7388          * A concatenation of the account type and data set (delimited by a forward
   7389          * slash) - if the data set is empty, this will be the same as the account
   7390          * type.  For applications that need to be aware of the data set, this can
   7391          * be used instead of account type to distinguish sets of data.  This is
   7392          * never intended to be used for specifying accounts.
   7393          * @hide
   7394          */
   7395         public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
   7396 
   7397         /**
   7398          * The display title of this group.
   7399          * <p>
   7400          * Type: TEXT
   7401          */
   7402         public static final String TITLE = "title";
   7403 
   7404         /**
   7405          * The package name to use when creating {@link Resources} objects for
   7406          * this group. This value is only designed for use when building user
   7407          * interfaces, and should not be used to infer the owner.
   7408          */
   7409         public static final String RES_PACKAGE = "res_package";
   7410 
   7411         /**
   7412          * The display title of this group to load as a resource from
   7413          * {@link #RES_PACKAGE}, which may be localized.
   7414          * <P>Type: TEXT</P>
   7415          */
   7416         public static final String TITLE_RES = "title_res";
   7417 
   7418         /**
   7419          * Notes about the group.
   7420          * <p>
   7421          * Type: TEXT
   7422          */
   7423         public static final String NOTES = "notes";
   7424 
   7425         /**
   7426          * The ID of this group if it is a System Group, i.e. a group that has a special meaning
   7427          * to the sync adapter, null otherwise.
   7428          * <P>Type: TEXT</P>
   7429          */
   7430         public static final String SYSTEM_ID = "system_id";
   7431 
   7432         /**
   7433          * The total number of {@link Contacts} that have
   7434          * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
   7435          * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
   7436          * <p>
   7437          * Type: INTEGER
   7438          */
   7439         public static final String SUMMARY_COUNT = "summ_count";
   7440 
   7441         /**
   7442          * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}.
   7443          * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}.
   7444          *
   7445          * @hide
   7446          */
   7447         public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT =
   7448                 "return_group_count_per_account";
   7449 
   7450         /**
   7451          * The total number of groups of the account that a group belongs to.
   7452          * This column is available only when the parameter
   7453          * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in
   7454          * {@link Groups#CONTENT_SUMMARY_URI}.
   7455          *
   7456          * For example, when the account "A" has two groups "group1" and "group2", and the account
   7457          * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for
   7458          * "group3" returns "1" for this column.
   7459          *
   7460          * Note: This counts only non-favorites, non-auto-add, and not deleted groups.
   7461          *
   7462          * Type: INTEGER
   7463          * @hide
   7464          */
   7465         public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account";
   7466 
   7467         /**
   7468          * The total number of {@link Contacts} that have both
   7469          * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
   7470          * Read-only value that is only present when querying
   7471          * {@link Groups#CONTENT_SUMMARY_URI}.
   7472          * <p>
   7473          * Type: INTEGER
   7474          */
   7475         public static final String SUMMARY_WITH_PHONES = "summ_phones";
   7476 
   7477         /**
   7478          * Flag indicating if the contacts belonging to this group should be
   7479          * visible in any user interface.
   7480          * <p>
   7481          * Type: INTEGER (boolean)
   7482          */
   7483         public static final String GROUP_VISIBLE = "group_visible";
   7484 
   7485         /**
   7486          * The "deleted" flag: "0" by default, "1" if the row has been marked
   7487          * for deletion. When {@link android.content.ContentResolver#delete} is
   7488          * called on a group, it is marked for deletion. The sync adaptor
   7489          * deletes the group on the server and then calls ContactResolver.delete
   7490          * once more, this time setting the the
   7491          * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
   7492          * finalize the data removal.
   7493          * <P>Type: INTEGER</P>
   7494          */
   7495         public static final String DELETED = "deleted";
   7496 
   7497         /**
   7498          * Whether this group should be synced if the SYNC_EVERYTHING settings
   7499          * is false for this group's account.
   7500          * <p>
   7501          * Type: INTEGER (boolean)
   7502          */
   7503         public static final String SHOULD_SYNC = "should_sync";
   7504 
   7505         /**
   7506          * Any newly created contacts will automatically be added to groups that have this
   7507          * flag set to true.
   7508          * <p>
   7509          * Type: INTEGER (boolean)
   7510          */
   7511         public static final String AUTO_ADD = "auto_add";
   7512 
   7513         /**
   7514          * When a contacts is marked as a favorites it will be automatically added
   7515          * to the groups that have this flag set, and when it is removed from favorites
   7516          * it will be removed from these groups.
   7517          * <p>
   7518          * Type: INTEGER (boolean)
   7519          */
   7520         public static final String FAVORITES = "favorites";
   7521 
   7522         /**
   7523          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
   7524          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
   7525          * <P>Type: INTEGER</P>
   7526          */
   7527         public static final String GROUP_IS_READ_ONLY = "group_is_read_only";
   7528     }
   7529 
   7530     /**
   7531      * Constants for the groups table. Only per-account groups are supported.
   7532      * <h2>Columns</h2>
   7533      * <table class="jd-sumtable">
   7534      * <tr>
   7535      * <th colspan='4'>Groups</th>
   7536      * </tr>
   7537      * <tr>
   7538      * <td>long</td>
   7539      * <td>{@link #_ID}</td>
   7540      * <td>read-only</td>
   7541      * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
   7542      * In other words, it would be a really bad idea to delete and reinsert a
   7543      * group. A sync adapter should always do an update instead.</td>
   7544      * </tr>
   7545      # <tr>
   7546      * <td>String</td>
   7547      * <td>{@link #DATA_SET}</td>
   7548      * <td>read/write-once</td>
   7549      * <td>
   7550      * <p>
   7551      * The data set within the account that this group belongs to.  This allows
   7552      * multiple sync adapters for the same account type to distinguish between
   7553      * each others' group data.  The combination of {@link #ACCOUNT_TYPE},
   7554      * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
   7555      * that is associated with a single sync adapter.
   7556      * </p>
   7557      * <p>
   7558      * This is empty by default, and is completely optional.  It only needs to
   7559      * be populated if multiple sync adapters are entering distinct data for
   7560      * the same account type and account name.
   7561      * </p>
   7562      * <p>
   7563      * It should be set at the time the group is inserted and never changed
   7564      * afterwards.
   7565      * </p>
   7566      * </td>
   7567      * </tr>
   7568      * <tr>
   7569      * <td>String</td>
   7570      * <td>{@link #TITLE}</td>
   7571      * <td>read/write</td>
   7572      * <td>The display title of this group.</td>
   7573      * </tr>
   7574      * <tr>
   7575      * <td>String</td>
   7576      * <td>{@link #NOTES}</td>
   7577      * <td>read/write</td>
   7578      * <td>Notes about the group.</td>
   7579      * </tr>
   7580      * <tr>
   7581      * <td>String</td>
   7582      * <td>{@link #SYSTEM_ID}</td>
   7583      * <td>read/write</td>
   7584      * <td>The ID of this group if it is a System Group, i.e. a group that has a
   7585      * special meaning to the sync adapter, null otherwise.</td>
   7586      * </tr>
   7587      * <tr>
   7588      * <td>int</td>
   7589      * <td>{@link #SUMMARY_COUNT}</td>
   7590      * <td>read-only</td>
   7591      * <td>The total number of {@link Contacts} that have
   7592      * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
   7593      * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
   7594      * </tr>
   7595      * <tr>
   7596      * <td>int</td>
   7597      * <td>{@link #SUMMARY_WITH_PHONES}</td>
   7598      * <td>read-only</td>
   7599      * <td>The total number of {@link Contacts} that have both
   7600      * {@link CommonDataKinds.GroupMembership} in this group, and also have
   7601      * phone numbers. Read-only value that is only present when querying
   7602      * {@link Groups#CONTENT_SUMMARY_URI}.</td>
   7603      * </tr>
   7604      * <tr>
   7605      * <td>int</td>
   7606      * <td>{@link #GROUP_VISIBLE}</td>
   7607      * <td>read-only</td>
   7608      * <td>Flag indicating if the contacts belonging to this group should be
   7609      * visible in any user interface. Allowed values: 0 and 1.</td>
   7610      * </tr>
   7611      * <tr>
   7612      * <td>int</td>
   7613      * <td>{@link #DELETED}</td>
   7614      * <td>read/write</td>
   7615      * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
   7616      * for deletion. When {@link android.content.ContentResolver#delete} is
   7617      * called on a group, it is marked for deletion. The sync adaptor deletes
   7618      * the group on the server and then calls ContactResolver.delete once more,
   7619      * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
   7620      * query parameter to finalize the data removal.</td>
   7621      * </tr>
   7622      * <tr>
   7623      * <td>int</td>
   7624      * <td>{@link #SHOULD_SYNC}</td>
   7625      * <td>read/write</td>
   7626      * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
   7627      * is false for this group's account.</td>
   7628      * </tr>
   7629      * </table>
   7630      */
   7631     public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
   7632         /**
   7633          * This utility class cannot be instantiated
   7634          */
   7635         private Groups() {
   7636         }
   7637 
   7638         /**
   7639          * The content:// style URI for this table
   7640          */
   7641         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
   7642 
   7643         /**
   7644          * The content:// style URI for this table joined with details data from
   7645          * {@link ContactsContract.Data}.
   7646          */
   7647         public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
   7648                 "groups_summary");
   7649 
   7650         /**
   7651          * The MIME type of a directory of groups.
   7652          */
   7653         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
   7654 
   7655         /**
   7656          * The MIME type of a single group.
   7657          */
   7658         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
   7659 
   7660         public static EntityIterator newEntityIterator(Cursor cursor) {
   7661             return new EntityIteratorImpl(cursor);
   7662         }
   7663 
   7664         private static class EntityIteratorImpl extends CursorEntityIterator {
   7665             public EntityIteratorImpl(Cursor cursor) {
   7666                 super(cursor);
   7667             }
   7668 
   7669             @Override
   7670             public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
   7671                 // we expect the cursor is already at the row we need to read from
   7672                 final ContentValues values = new ContentValues();
   7673                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
   7674                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
   7675                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
   7676                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
   7677                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
   7678                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
   7679                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
   7680                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
   7681                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
   7682                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
   7683                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
   7684                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
   7685                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
   7686                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
   7687                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
   7688                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
   7689                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
   7690                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
   7691                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES);
   7692                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD);
   7693                 cursor.moveToNext();
   7694                 return new Entity(values);
   7695             }
   7696         }
   7697     }
   7698 
   7699     /**
   7700      * <p>
   7701      * Constants for the contact aggregation exceptions table, which contains
   7702      * aggregation rules overriding those used by automatic aggregation. This
   7703      * type only supports query and update. Neither insert nor delete are
   7704      * supported.
   7705      * </p>
   7706      * <h2>Columns</h2>
   7707      * <table class="jd-sumtable">
   7708      * <tr>
   7709      * <th colspan='4'>AggregationExceptions</th>
   7710      * </tr>
   7711      * <tr>
   7712      * <td>int</td>
   7713      * <td>{@link #TYPE}</td>
   7714      * <td>read/write</td>
   7715      * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
   7716      * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
   7717      * </tr>
   7718      * <tr>
   7719      * <td>long</td>
   7720      * <td>{@link #RAW_CONTACT_ID1}</td>
   7721      * <td>read/write</td>
   7722      * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
   7723      * the rule applies to.</td>
   7724      * </tr>
   7725      * <tr>
   7726      * <td>long</td>
   7727      * <td>{@link #RAW_CONTACT_ID2}</td>
   7728      * <td>read/write</td>
   7729      * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
   7730      * that the rule applies to.</td>
   7731      * </tr>
   7732      * </table>
   7733      */
   7734     public static final class AggregationExceptions implements BaseColumns {
   7735         /**
   7736          * This utility class cannot be instantiated
   7737          */
   7738         private AggregationExceptions() {}
   7739 
   7740         /**
   7741          * The content:// style URI for this table
   7742          */
   7743         public static final Uri CONTENT_URI =
   7744                 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
   7745 
   7746         /**
   7747          * The MIME type of {@link #CONTENT_URI} providing a directory of data.
   7748          */
   7749         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
   7750 
   7751         /**
   7752          * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
   7753          */
   7754         public static final String CONTENT_ITEM_TYPE =
   7755                 "vnd.android.cursor.item/aggregation_exception";
   7756 
   7757         /**
   7758          * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
   7759          * {@link #TYPE_AUTOMATIC}.
   7760          *
   7761          * <P>Type: INTEGER</P>
   7762          */
   7763         public static final String TYPE = "type";
   7764 
   7765         /**
   7766          * Allows the provider to automatically decide whether the specified raw contacts should
   7767          * be included in the same aggregate contact or not.
   7768          */
   7769         public static final int TYPE_AUTOMATIC = 0;
   7770 
   7771         /**
   7772          * Makes sure that the specified raw contacts are included in the same
   7773          * aggregate contact.
   7774          */
   7775         public static final int TYPE_KEEP_TOGETHER = 1;
   7776 
   7777         /**
   7778          * Makes sure that the specified raw contacts are NOT included in the same
   7779          * aggregate contact.
   7780          */
   7781         public static final int TYPE_KEEP_SEPARATE = 2;
   7782 
   7783         /**
   7784          * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
   7785          */
   7786         public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
   7787 
   7788         /**
   7789          * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
   7790          * applies to.
   7791          */
   7792         public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
   7793     }
   7794 
   7795     /**
   7796      * @see Settings
   7797      */
   7798     protected interface SettingsColumns {
   7799         /**
   7800          * The name of the account instance to which this row belongs.
   7801          * <P>Type: TEXT</P>
   7802          */
   7803         public static final String ACCOUNT_NAME = "account_name";
   7804 
   7805         /**
   7806          * The type of account to which this row belongs, which when paired with
   7807          * {@link #ACCOUNT_NAME} identifies a specific account.
   7808          * <P>Type: TEXT</P>
   7809          */
   7810         public static final String ACCOUNT_TYPE = "account_type";
   7811 
   7812         /**
   7813          * The data set within the account that this row belongs to.  This allows
   7814          * multiple sync adapters for the same account type to distinguish between
   7815          * each others' data.
   7816          *
   7817          * This is empty by default, and is completely optional.  It only needs to
   7818          * be populated if multiple sync adapters are entering distinct data for
   7819          * the same account type and account name.
   7820          * <P>Type: TEXT</P>
   7821          */
   7822         public static final String DATA_SET = "data_set";
   7823 
   7824         /**
   7825          * Depending on the mode defined by the sync-adapter, this flag controls
   7826          * the top-level sync behavior for this data source.
   7827          * <p>
   7828          * Type: INTEGER (boolean)
   7829          */
   7830         public static final String SHOULD_SYNC = "should_sync";
   7831 
   7832         /**
   7833          * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
   7834          * entries should be visible in any user interface.
   7835          * <p>
   7836          * Type: INTEGER (boolean)
   7837          */
   7838         public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
   7839 
   7840         /**
   7841          * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
   7842          * {@link Groups#SHOULD_SYNC} under this account have been marked as
   7843          * unsynced.
   7844          */
   7845         public static final String ANY_UNSYNCED = "any_unsynced";
   7846 
   7847         /**
   7848          * Read-only count of {@link Contacts} from a specific source that have
   7849          * no {@link CommonDataKinds.GroupMembership} entries.
   7850          * <p>
   7851          * Type: INTEGER
   7852          */
   7853         public static final String UNGROUPED_COUNT = "summ_count";
   7854 
   7855         /**
   7856          * Read-only count of {@link Contacts} from a specific source that have
   7857          * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
   7858          * <p>
   7859          * Type: INTEGER
   7860          */
   7861         public static final String UNGROUPED_WITH_PHONES = "summ_phones";
   7862     }
   7863 
   7864     /**
   7865      * <p>
   7866      * Contacts-specific settings for various {@link Account}'s.
   7867      * </p>
   7868      * <h2>Columns</h2>
   7869      * <table class="jd-sumtable">
   7870      * <tr>
   7871      * <th colspan='4'>Settings</th>
   7872      * </tr>
   7873      * <tr>
   7874      * <td>String</td>
   7875      * <td>{@link #ACCOUNT_NAME}</td>
   7876      * <td>read/write-once</td>
   7877      * <td>The name of the account instance to which this row belongs.</td>
   7878      * </tr>
   7879      * <tr>
   7880      * <td>String</td>
   7881      * <td>{@link #ACCOUNT_TYPE}</td>
   7882      * <td>read/write-once</td>
   7883      * <td>The type of account to which this row belongs, which when paired with
   7884      * {@link #ACCOUNT_NAME} identifies a specific account.</td>
   7885      * </tr>
   7886      * <tr>
   7887      * <td>int</td>
   7888      * <td>{@link #SHOULD_SYNC}</td>
   7889      * <td>read/write</td>
   7890      * <td>Depending on the mode defined by the sync-adapter, this flag controls
   7891      * the top-level sync behavior for this data source.</td>
   7892      * </tr>
   7893      * <tr>
   7894      * <td>int</td>
   7895      * <td>{@link #UNGROUPED_VISIBLE}</td>
   7896      * <td>read/write</td>
   7897      * <td>Flag indicating if contacts without any
   7898      * {@link CommonDataKinds.GroupMembership} entries should be visible in any
   7899      * user interface.</td>
   7900      * </tr>
   7901      * <tr>
   7902      * <td>int</td>
   7903      * <td>{@link #ANY_UNSYNCED}</td>
   7904      * <td>read-only</td>
   7905      * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
   7906      * {@link Groups#SHOULD_SYNC} under this account have been marked as
   7907      * unsynced.</td>
   7908      * </tr>
   7909      * <tr>
   7910      * <td>int</td>
   7911      * <td>{@link #UNGROUPED_COUNT}</td>
   7912      * <td>read-only</td>
   7913      * <td>Read-only count of {@link Contacts} from a specific source that have
   7914      * no {@link CommonDataKinds.GroupMembership} entries.</td>
   7915      * </tr>
   7916      * <tr>
   7917      * <td>int</td>
   7918      * <td>{@link #UNGROUPED_WITH_PHONES}</td>
   7919      * <td>read-only</td>
   7920      * <td>Read-only count of {@link Contacts} from a specific source that have
   7921      * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
   7922      * numbers.</td>
   7923      * </tr>
   7924      * </table>
   7925      */
   7926     public static final class Settings implements SettingsColumns {
   7927         /**
   7928          * This utility class cannot be instantiated
   7929          */
   7930         private Settings() {
   7931         }
   7932 
   7933         /**
   7934          * The content:// style URI for this table
   7935          */
   7936         public static final Uri CONTENT_URI =
   7937                 Uri.withAppendedPath(AUTHORITY_URI, "settings");
   7938 
   7939         /**
   7940          * The MIME-type of {@link #CONTENT_URI} providing a directory of
   7941          * settings.
   7942          */
   7943         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
   7944 
   7945         /**
   7946          * The MIME-type of {@link #CONTENT_URI} providing a single setting.
   7947          */
   7948         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
   7949     }
   7950 
   7951     /**
   7952      * API for inquiring about the general status of the provider.
   7953      */
   7954     public static final class ProviderStatus {
   7955 
   7956         /**
   7957          * Not instantiable.
   7958          */
   7959         private ProviderStatus() {
   7960         }
   7961 
   7962         /**
   7963          * The content:// style URI for this table.  Requests to this URI can be
   7964          * performed on the UI thread because they are always unblocking.
   7965          */
   7966         public static final Uri CONTENT_URI =
   7967                 Uri.withAppendedPath(AUTHORITY_URI, "provider_status");
   7968 
   7969         /**
   7970          * The MIME-type of {@link #CONTENT_URI} providing a directory of
   7971          * settings.
   7972          */
   7973         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status";
   7974 
   7975         /**
   7976          * An integer representing the current status of the provider.
   7977          */
   7978         public static final String STATUS = "status";
   7979 
   7980         /**
   7981          * Default status of the provider.
   7982          */
   7983         public static final int STATUS_NORMAL = 0;
   7984 
   7985         /**
   7986          * The provider won't respond to queries. It is in the middle of a long running task, such
   7987          * as a database upgrade or locale change.
   7988          */
   7989         public static final int STATUS_BUSY = 1;
   7990 
   7991         /**
   7992          * The status that indicates that there are no accounts and no contacts
   7993          * on the device.
   7994          */
   7995         public static final int STATUS_EMPTY = 2;
   7996     }
   7997 
   7998     /**
   7999      * <p>
   8000      * API allowing applications to send usage information for each {@link Data} row to the
   8001      * Contacts Provider.  Applications can also clear all usage information.
   8002      * </p>
   8003      * <p>
   8004      * With the feedback, Contacts Provider may return more contextually appropriate results for
   8005      * Data listing, typically supplied with
   8006      * {@link ContactsContract.Contacts#CONTENT_FILTER_URI},
   8007      * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI},
   8008      * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit
   8009      * from better ranked (sorted) lists in applications that show auto-complete list.
   8010      * </p>
   8011      * <p>
   8012      * There is no guarantee for how this feedback is used, or even whether it is used at all.
   8013      * The ranking algorithm will make best efforts to use the feedback data, but the exact
   8014      * implementation, the storage data structures as well as the resulting sort order is device
   8015      * and version specific and can change over time.
   8016      * </p>
   8017      * <p>
   8018      * When updating usage information, users of this API need to use
   8019      * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed
   8020      * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as
   8021      * its last path. They also need to append a query parameter to the Uri, to specify the type of
   8022      * the communication, which enables the Contacts Provider to differentiate between kinds of
   8023      * interactions using the same contact data field (for example a phone number can be used to
   8024      * make phone calls or send SMS).
   8025      * </p>
   8026      * <p>
   8027      * Selection and selectionArgs are ignored and must be set to null. To get data ids,
   8028      * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)}
   8029      * toward {@link Data#CONTENT_URI}.
   8030      * </p>
   8031      * <p>
   8032      * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive
   8033      * integer when successful, and returns 0 if no contact with that id was found.
   8034      * </p>
   8035      * <p>
   8036      * Example:
   8037      * <pre>
   8038      * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
   8039      *         .appendPath(TextUtils.join(",", dataIds))
   8040      *         .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
   8041      *                 DataUsageFeedback.USAGE_TYPE_CALL)
   8042      *         .build();
   8043      * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0;
   8044      * </pre>
   8045      * </p>
   8046      * <p>
   8047      * Applications can also clear all usage information with:
   8048      * <pre>
   8049      * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0;
   8050      * </pre>
   8051      * </p>
   8052      */
   8053     public static final class DataUsageFeedback {
   8054 
   8055         /**
   8056          * The content:// style URI for sending usage feedback.
   8057          * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}.
   8058          */
   8059         public static final Uri FEEDBACK_URI =
   8060                 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback");
   8061 
   8062         /**
   8063          * The content:// style URI for deleting all usage information.
   8064          * Must be used with {@link ContentResolver#delete(Uri, String, String[])}.
   8065          * The {@code where} and {@code selectionArgs} parameters are ignored.
   8066          */
   8067         public static final Uri DELETE_USAGE_URI =
   8068                 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage");
   8069 
   8070         /**
   8071          * <p>
   8072          * Name for query parameter specifying the type of data usage.
   8073          * </p>
   8074          */
   8075         public static final String USAGE_TYPE = "type";
   8076 
   8077         /**
   8078          * <p>
   8079          * Type of usage for voice interaction, which includes phone call, voice chat, and
   8080          * video chat.
   8081          * </p>
   8082          */
   8083         public static final String USAGE_TYPE_CALL = "call";
   8084 
   8085         /**
   8086          * <p>
   8087          * Type of usage for text interaction involving longer messages, which includes email.
   8088          * </p>
   8089          */
   8090         public static final String USAGE_TYPE_LONG_TEXT = "long_text";
   8091 
   8092         /**
   8093          * <p>
   8094          * Type of usage for text interaction involving shorter messages, which includes SMS,
   8095          * text chat with email addresses.
   8096          * </p>
   8097          */
   8098         public static final String USAGE_TYPE_SHORT_TEXT = "short_text";
   8099     }
   8100 
   8101     /**
   8102      * <p>
   8103      * Contact-specific information about whether or not a contact has been pinned by the user
   8104      * at a particular position within the system contact application's user interface.
   8105      * </p>
   8106      *
   8107      * <p>
   8108      * This pinning information can be used by individual applications to customize how
   8109      * they order particular pinned contacts. For example, a Dialer application could
   8110      * use pinned information to order user-pinned contacts in a top row of favorites.
   8111      * </p>
   8112      *
   8113      * <p>
   8114      * It is possible for two or more contacts to occupy the same pinned position (due
   8115      * to aggregation and sync), so this pinning information should be used on a best-effort
   8116      * basis to order contacts in-application rather than an absolute guide on where a contact
   8117      * should be positioned. Contacts returned by the ContactsProvider will not be ordered based
   8118      * on this information, so it is up to the client application to reorder these contacts within
   8119      * their own UI adhering to (or ignoring as appropriate) information stored in the pinned
   8120      * column.
   8121      * </p>
   8122      *
   8123      * <p>
   8124      * By default, unpinned contacts will have a pinned position of
   8125      * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive
   8126      * integers that are greater than 1.
   8127      * </p>
   8128      */
   8129     public static final class PinnedPositions {
   8130         /**
   8131          * The method to invoke in order to undemote a formerly demoted contact. The contact id of
   8132          * the contact must be provided as an argument. If the contact was not previously demoted,
   8133          * nothing will be done.
   8134          * @hide
   8135          */
   8136         public static final String UNDEMOTE_METHOD = "undemote";
   8137 
   8138         /**
   8139          * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing
   8140          * will be done.
   8141          *
   8142          * @param contentResolver to perform the undemote operation on.
   8143          * @param contactId the id of the contact to undemote.
   8144          */
   8145         public static void undemote(ContentResolver contentResolver, long contactId) {
   8146             contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD,
   8147                     String.valueOf(contactId), null);
   8148         }
   8149 
   8150         /**
   8151          * Pins a contact at a provided position, or unpins a contact.
   8152          *
   8153          * @param contentResolver to perform the pinning operation on.
   8154          * @param pinnedPosition the position to pin the contact at. To unpin a contact, use
   8155          *         {@link PinnedPositions#UNPINNED}.
   8156          */
   8157         public static void pin(
   8158                 ContentResolver contentResolver, long contactId, int pinnedPosition) {
   8159             final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId));
   8160             final ContentValues values = new ContentValues();
   8161             values.put(Contacts.PINNED, pinnedPosition);
   8162             contentResolver.update(uri, values, null, null);
   8163         }
   8164 
   8165         /**
   8166          * Default value for the pinned position of an unpinned contact.
   8167          */
   8168         public static final int UNPINNED = 0;
   8169 
   8170         /**
   8171          * Value of pinned position for a contact that a user has indicated should be considered
   8172          * of the lowest priority. It is up to the client application to determine how to present
   8173          * such a contact - for example all the way at the bottom of a contact list, or simply
   8174          * just hidden from view.
   8175          */
   8176         public static final int DEMOTED = -1;
   8177     }
   8178 
   8179     /**
   8180      * Helper methods to display QuickContact dialogs that display all the information belonging to
   8181      * a specific {@link Contacts} entry.
   8182      */
   8183     public static final class QuickContact {
   8184         /**
   8185          * Action used to launch the system contacts application and bring up a QuickContact dialog
   8186          * for the provided {@link Contacts} entry.
   8187          */
   8188         public static final String ACTION_QUICK_CONTACT =
   8189                 "android.provider.action.QUICK_CONTACT";
   8190 
   8191         /**
   8192          * Extra used to specify pivot dialog location in screen coordinates.
   8193          * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
   8194          * @hide
   8195          */
   8196         @Deprecated
   8197         public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT";
   8198 
   8199         /**
   8200          * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts
   8201          * will respect this extra's value.
   8202          *
   8203          * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
   8204          */
   8205         public static final String EXTRA_MODE = "android.provider.extra.MODE";
   8206 
   8207         /**
   8208          * Extra used to specify which mimetype should be prioritized in the QuickContacts UI.
   8209          * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can
   8210          * cause phone numbers to be displayed more prominently in QuickContacts.
   8211          */
   8212         public static final String EXTRA_PRIORITIZED_MIMETYPE
   8213                 = "android.provider.extra.PRIORITIZED_MIMETYPE";
   8214 
   8215         /**
   8216          * Extra used to indicate a list of specific MIME-types to exclude and not display in the
   8217          * QuickContacts dialog. Stored as a {@link String} array.
   8218          */
   8219         public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES";
   8220 
   8221         /**
   8222          * Small QuickContact mode, usually presented with minimal actions.
   8223          */
   8224         public static final int MODE_SMALL = 1;
   8225 
   8226         /**
   8227          * Medium QuickContact mode, includes actions and light summary describing
   8228          * the {@link Contacts} entry being shown. This may include social
   8229          * status and presence details.
   8230          */
   8231         public static final int MODE_MEDIUM = 2;
   8232 
   8233         /**
   8234          * Large QuickContact mode, includes actions and larger, card-like summary
   8235          * of the {@link Contacts} entry being shown. This may include detailed
   8236          * information, such as a photo.
   8237          */
   8238         public static final int MODE_LARGE = 3;
   8239 
   8240         /** @hide */
   8241         public static final int MODE_DEFAULT = MODE_LARGE;
   8242 
   8243         /**
   8244          * Constructs the QuickContacts intent with a view's rect.
   8245          * @hide
   8246          */
   8247         public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri,
   8248                 int mode, String[] excludeMimes) {
   8249             // Find location and bounds of target view, adjusting based on the
   8250             // assumed local density.
   8251             final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
   8252             final int[] pos = new int[2];
   8253             target.getLocationOnScreen(pos);
   8254 
   8255             final Rect rect = new Rect();
   8256             rect.left = (int) (pos[0] * appScale + 0.5f);
   8257             rect.top = (int) (pos[1] * appScale + 0.5f);
   8258             rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
   8259             rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
   8260 
   8261             return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes);
   8262         }
   8263 
   8264         /**
   8265          * Constructs the QuickContacts intent.
   8266          * @hide
   8267          */
   8268         public static Intent composeQuickContactsIntent(Context context, Rect target,
   8269                 Uri lookupUri, int mode, String[] excludeMimes) {
   8270             // When launching from an Activiy, we don't want to start a new task, but otherwise
   8271             // we *must* start a new task.  (Otherwise startActivity() would crash.)
   8272             Context actualContext = context;
   8273             while ((actualContext instanceof ContextWrapper)
   8274                     && !(actualContext instanceof Activity)) {
   8275                 actualContext = ((ContextWrapper) actualContext).getBaseContext();
   8276             }
   8277             final int intentFlags = ((actualContext instanceof Activity)
   8278                     ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
   8279                     // Workaround for b/16898764. Declaring singleTop in manifest doesn't work.
   8280                     | Intent.FLAG_ACTIVITY_SINGLE_TOP;
   8281 
   8282             // Launch pivot dialog through intent for now
   8283             final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
   8284 
   8285             // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync.
   8286             intent.setData(lookupUri);
   8287             intent.setSourceBounds(target);
   8288             intent.putExtra(EXTRA_MODE, mode);
   8289             intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
   8290             return intent;
   8291         }
   8292 
   8293         /**
   8294          * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager
   8295          * to strip off anything not necessary.
   8296          *
   8297          * @hide
   8298          */
   8299         public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId,
   8300                 Intent originalIntent) {
   8301             final Intent intent = new Intent(ACTION_QUICK_CONTACT);
   8302             // Rebuild the URI from a lookup key and a contact ID.
   8303             intent.setData(Contacts.getLookupUri(contactId, lookupKey));
   8304 
   8305             // Copy flags and always set NEW_TASK because it won't have a parent activity.
   8306             intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
   8307 
   8308             // Copy extras.
   8309             intent.setSourceBounds(originalIntent.getSourceBounds());
   8310             intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT));
   8311             intent.putExtra(EXTRA_EXCLUDE_MIMES,
   8312                     originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES));
   8313             return intent;
   8314         }
   8315 
   8316 
   8317         /**
   8318          * Trigger a dialog that lists the various methods of interacting with
   8319          * the requested {@link Contacts} entry. This may be based on available
   8320          * {@link ContactsContract.Data} rows under that contact, and may also
   8321          * include social status and presence details.
   8322          *
   8323          * @param context The parent {@link Context} that may be used as the
   8324          *            parent for this dialog.
   8325          * @param target Specific {@link View} from your layout that this dialog
   8326          *            should be centered around. In particular, if the dialog
   8327          *            has a "callout" arrow, it will be pointed and centered
   8328          *            around this {@link View}.
   8329          * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
   8330          *            {@link Uri} that describes a specific contact to feature
   8331          *            in this dialog.
   8332          * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
   8333          *            {@link #MODE_LARGE}, indicating the desired dialog size,
   8334          *            when supported.
   8335          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
   8336          *            to exclude when showing this dialog. For example, when
   8337          *            already viewing the contact details card, this can be used
   8338          *            to omit the details entry from the dialog.
   8339          */
   8340         public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
   8341                 String[] excludeMimes) {
   8342             // Trigger with obtained rectangle
   8343             Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
   8344                     excludeMimes);
   8345             ContactsInternal.startQuickContactWithErrorToast(context, intent);
   8346         }
   8347 
   8348         /**
   8349          * Trigger a dialog that lists the various methods of interacting with
   8350          * the requested {@link Contacts} entry. This may be based on available
   8351          * {@link ContactsContract.Data} rows under that contact, and may also
   8352          * include social status and presence details.
   8353          *
   8354          * @param context The parent {@link Context} that may be used as the
   8355          *            parent for this dialog.
   8356          * @param target Specific {@link Rect} that this dialog should be
   8357          *            centered around, in screen coordinates. In particular, if
   8358          *            the dialog has a "callout" arrow, it will be pointed and
   8359          *            centered around this {@link Rect}. If you are running at a
   8360          *            non-native density, you need to manually adjust using
   8361          *            {@link DisplayMetrics#density} before calling.
   8362          * @param lookupUri A
   8363          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
   8364          *            {@link Uri} that describes a specific contact to feature
   8365          *            in this dialog.
   8366          * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
   8367          *            {@link #MODE_LARGE}, indicating the desired dialog size,
   8368          *            when supported.
   8369          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
   8370          *            to exclude when showing this dialog. For example, when
   8371          *            already viewing the contact details card, this can be used
   8372          *            to omit the details entry from the dialog.
   8373          */
   8374         public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
   8375                 String[] excludeMimes) {
   8376             Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
   8377                     excludeMimes);
   8378             ContactsInternal.startQuickContactWithErrorToast(context, intent);
   8379         }
   8380 
   8381         /**
   8382          * Trigger a dialog that lists the various methods of interacting with
   8383          * the requested {@link Contacts} entry. This may be based on available
   8384          * {@link ContactsContract.Data} rows under that contact, and may also
   8385          * include social status and presence details.
   8386          *
   8387          * @param context The parent {@link Context} that may be used as the
   8388          *            parent for this dialog.
   8389          * @param target Specific {@link View} from your layout that this dialog
   8390          *            should be centered around. In particular, if the dialog
   8391          *            has a "callout" arrow, it will be pointed and centered
   8392          *            around this {@link View}.
   8393          * @param lookupUri A
   8394          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
   8395          *            {@link Uri} that describes a specific contact to feature
   8396          *            in this dialog.
   8397          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
   8398          *            to exclude when showing this dialog. For example, when
   8399          *            already viewing the contact details card, this can be used
   8400          *            to omit the details entry from the dialog.
   8401          * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI.
   8402          *             For example, passing the value
   8403          *             {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be
   8404          *             displayed more prominently in QuickContacts.
   8405          */
   8406         public static void showQuickContact(Context context, View target, Uri lookupUri,
   8407                 String[] excludeMimes, String prioritizedMimeType) {
   8408             // Use MODE_LARGE instead of accepting mode as a parameter. The different mode
   8409             // values defined in ContactsContract only affect very old implementations
   8410             // of QuickContacts.
   8411             Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
   8412                     excludeMimes);
   8413             intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
   8414             ContactsInternal.startQuickContactWithErrorToast(context, intent);
   8415         }
   8416 
   8417         /**
   8418          * Trigger a dialog that lists the various methods of interacting with
   8419          * the requested {@link Contacts} entry. This may be based on available
   8420          * {@link ContactsContract.Data} rows under that contact, and may also
   8421          * include social status and presence details.
   8422          *
   8423          * @param context The parent {@link Context} that may be used as the
   8424          *            parent for this dialog.
   8425          * @param target Specific {@link Rect} that this dialog should be
   8426          *            centered around, in screen coordinates. In particular, if
   8427          *            the dialog has a "callout" arrow, it will be pointed and
   8428          *            centered around this {@link Rect}. If you are running at a
   8429          *            non-native density, you need to manually adjust using
   8430          *            {@link DisplayMetrics#density} before calling.
   8431          * @param lookupUri A
   8432          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
   8433          *            {@link Uri} that describes a specific contact to feature
   8434          *            in this dialog.
   8435          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
   8436          *            to exclude when showing this dialog. For example, when
   8437          *            already viewing the contact details card, this can be used
   8438          *            to omit the details entry from the dialog.
   8439          * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI.
   8440          *             For example, passing the value
   8441          *             {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be
   8442          *             displayed more prominently in QuickContacts.
   8443          */
   8444         public static void showQuickContact(Context context, Rect target, Uri lookupUri,
   8445                 String[] excludeMimes, String prioritizedMimeType) {
   8446             // Use MODE_LARGE instead of accepting mode as a parameter. The different mode
   8447             // values defined in ContactsContract only affect very old implementations
   8448             // of QuickContacts.
   8449             Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
   8450                     excludeMimes);
   8451             intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
   8452             ContactsInternal.startQuickContactWithErrorToast(context, intent);
   8453         }
   8454     }
   8455 
   8456     /**
   8457      * Helper class for accessing full-size photos by photo file ID.
   8458      * <p>
   8459      * Usage example:
   8460      * <dl>
   8461      * <dt>Retrieving a full-size photo by photo file ID (see
   8462      * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID})
   8463      * </dt>
   8464      * <dd>
   8465      * <pre>
   8466      * public InputStream openDisplayPhoto(long photoFileId) {
   8467      *     Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
   8468      *     try {
   8469      *         AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
   8470      *             displayPhotoUri, "r");
   8471      *         return fd.createInputStream();
   8472      *     } catch (IOException e) {
   8473      *         return null;
   8474      *     }
   8475      * }
   8476      * </pre>
   8477      * </dd>
   8478      * </dl>
   8479      * </p>
   8480      */
   8481     public static final class DisplayPhoto {
   8482         /**
   8483          * no public constructor since this is a utility class
   8484          */
   8485         private DisplayPhoto() {}
   8486 
   8487         /**
   8488          * The content:// style URI for this class, which allows access to full-size photos,
   8489          * given a key.
   8490          */
   8491         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo");
   8492 
   8493         /**
   8494          * This URI allows the caller to query for the maximum dimensions of a display photo
   8495          * or thumbnail.  Requests to this URI can be performed on the UI thread because
   8496          * they are always unblocking.
   8497          */
   8498         public static final Uri CONTENT_MAX_DIMENSIONS_URI =
   8499                 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions");
   8500 
   8501         /**
   8502          * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
   8503          * contain this column, populated with the maximum height and width (in pixels)
   8504          * that will be stored for a display photo.  Larger photos will be down-sized to
   8505          * fit within a square of this many pixels.
   8506          */
   8507         public static final String DISPLAY_MAX_DIM = "display_max_dim";
   8508 
   8509         /**
   8510          * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
   8511          * contain this column, populated with the height and width (in pixels) for photo
   8512          * thumbnails.
   8513          */
   8514         public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim";
   8515     }
   8516 
   8517     /**
   8518      * Contains helper classes used to create or manage {@link android.content.Intent Intents}
   8519      * that involve contacts.
   8520      */
   8521     public static final class Intents {
   8522         /**
   8523          * This is the intent that is fired when a search suggestion is clicked on.
   8524          */
   8525         public static final String SEARCH_SUGGESTION_CLICKED =
   8526                 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
   8527 
   8528         /**
   8529          * This is the intent that is fired when a search suggestion for dialing a number
   8530          * is clicked on.
   8531          */
   8532         public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
   8533                 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
   8534 
   8535         /**
   8536          * This is the intent that is fired when a search suggestion for creating a contact
   8537          * is clicked on.
   8538          */
   8539         public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
   8540                 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
   8541 
   8542         /**
   8543          * This is the intent that is fired when the contacts database is created. <p> The
   8544          * READ_CONTACT permission is required to receive these broadcasts.
   8545          */
   8546         public static final String CONTACTS_DATABASE_CREATED =
   8547                 "android.provider.Contacts.DATABASE_CREATED";
   8548 
   8549         /**
   8550          * Starts an Activity that lets the user pick a contact to attach an image to.
   8551          * After picking the contact it launches the image cropper in face detection mode.
   8552          */
   8553         public static final String ATTACH_IMAGE =
   8554                 "com.android.contacts.action.ATTACH_IMAGE";
   8555 
   8556         /**
   8557          * This is the intent that is fired when the user clicks the "invite to the network" button
   8558          * on a contact.  Only sent to an activity which is explicitly registered by a contact
   8559          * provider which supports the "invite to the network" feature.
   8560          * <p>
   8561          * {@link Intent#getData()} contains the lookup URI for the contact.
   8562          */
   8563         public static final String INVITE_CONTACT =
   8564                 "com.android.contacts.action.INVITE_CONTACT";
   8565 
   8566         /**
   8567          * Takes as input a data URI with a mailto: or tel: scheme. If a single
   8568          * contact exists with the given data it will be shown. If no contact
   8569          * exists, a dialog will ask the user if they want to create a new
   8570          * contact with the provided details filled in. If multiple contacts
   8571          * share the data the user will be prompted to pick which contact they
   8572          * want to view.
   8573          * <p>
   8574          * For <code>mailto:</code> URIs, the scheme specific portion must be a
   8575          * raw email address, such as one built using
   8576          * {@link Uri#fromParts(String, String, String)}.
   8577          * <p>
   8578          * For <code>tel:</code> URIs, the scheme specific portion is compared
   8579          * to existing numbers using the standard caller ID lookup algorithm.
   8580          * The number must be properly encoded, for example using
   8581          * {@link Uri#fromParts(String, String, String)}.
   8582          * <p>
   8583          * Any extras from the {@link Insert} class will be passed along to the
   8584          * create activity if there are no contacts to show.
   8585          * <p>
   8586          * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
   8587          * prompting the user when the contact doesn't exist.
   8588          */
   8589         public static final String SHOW_OR_CREATE_CONTACT =
   8590                 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
   8591 
   8592         /**
   8593          * Starts an Activity that lets the user select the multiple phones from a
   8594          * list of phone numbers which come from the contacts or
   8595          * {@link #EXTRA_PHONE_URIS}.
   8596          * <p>
   8597          * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS}
   8598          * could belong to the contacts or not, and will be selected by default.
   8599          * <p>
   8600          * The user's selection will be returned from
   8601          * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
   8602          * if the resultCode is
   8603          * {@link android.app.Activity#RESULT_OK}, the array of picked phone
   8604          * numbers are in the Intent's
   8605          * {@link #EXTRA_PHONE_URIS}; otherwise, the
   8606          * {@link android.app.Activity#RESULT_CANCELED} is returned if the user
   8607          * left the Activity without changing the selection.
   8608          *
   8609          * @hide
   8610          */
   8611         public static final String ACTION_GET_MULTIPLE_PHONES =
   8612                 "com.android.contacts.action.GET_MULTIPLE_PHONES";
   8613 
   8614         /**
   8615          * A broadcast action which is sent when any change has been made to the profile, such
   8616          * as the profile name or the picture.  A receiver must have
   8617          * the android.permission.READ_PROFILE permission.
   8618          *
   8619          * @hide
   8620          */
   8621         public static final String ACTION_PROFILE_CHANGED =
   8622                 "android.provider.Contacts.PROFILE_CHANGED";
   8623 
   8624         /**
   8625          * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
   8626          * contact if no matching contact found. Otherwise, default behavior is
   8627          * to prompt user with dialog before creating.
   8628          * <p>
   8629          * Type: BOOLEAN
   8630          */
   8631         public static final String EXTRA_FORCE_CREATE =
   8632                 "com.android.contacts.action.FORCE_CREATE";
   8633 
   8634         /**
   8635          * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
   8636          * description to be shown when prompting user about creating a new
   8637          * contact.
   8638          * <p>
   8639          * Type: STRING
   8640          */
   8641         public static final String EXTRA_CREATE_DESCRIPTION =
   8642             "com.android.contacts.action.CREATE_DESCRIPTION";
   8643 
   8644         /**
   8645          * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value.
   8646          * <p>
   8647          * The phone numbers want to be picked by default should be passed in as
   8648          * input value. These phone numbers could belong to the contacts or not.
   8649          * <p>
   8650          * The phone numbers which were picked by the user are returned as output
   8651          * value.
   8652          * <p>
   8653          * Type: array of URIs, the tel URI is used for the phone numbers which don't
   8654          * belong to any contact, the content URI is used for phone id in contacts.
   8655          *
   8656          * @hide
   8657          */
   8658         public static final String EXTRA_PHONE_URIS =
   8659             "com.android.contacts.extra.PHONE_URIS";
   8660 
   8661         /**
   8662          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
   8663          * dialog location using screen coordinates. When not specified, the
   8664          * dialog will be centered.
   8665          *
   8666          * @hide
   8667          */
   8668         @Deprecated
   8669         public static final String EXTRA_TARGET_RECT = "target_rect";
   8670 
   8671         /**
   8672          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
   8673          * desired dialog style, usually a variation on size. One of
   8674          * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
   8675          *
   8676          * @hide
   8677          */
   8678         @Deprecated
   8679         public static final String EXTRA_MODE = "mode";
   8680 
   8681         /**
   8682          * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
   8683          *
   8684          * @hide
   8685          */
   8686         @Deprecated
   8687         public static final int MODE_SMALL = 1;
   8688 
   8689         /**
   8690          * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
   8691          *
   8692          * @hide
   8693          */
   8694         @Deprecated
   8695         public static final int MODE_MEDIUM = 2;
   8696 
   8697         /**
   8698          * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
   8699          *
   8700          * @hide
   8701          */
   8702         @Deprecated
   8703         public static final int MODE_LARGE = 3;
   8704 
   8705         /**
   8706          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
   8707          * a list of specific MIME-types to exclude and not display. Stored as a
   8708          * {@link String} array.
   8709          *
   8710          * @hide
   8711          */
   8712         @Deprecated
   8713         public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
   8714 
   8715         /**
   8716          * Convenience class that contains string constants used
   8717          * to create contact {@link android.content.Intent Intents}.
   8718          */
   8719         public static final class Insert {
   8720             /** The action code to use when adding a contact */
   8721             public static final String ACTION = Intent.ACTION_INSERT;
   8722 
   8723             /**
   8724              * If present, forces a bypass of quick insert mode.
   8725              */
   8726             public static final String FULL_MODE = "full_mode";
   8727 
   8728             /**
   8729              * The extra field for the contact name.
   8730              * <P>Type: String</P>
   8731              */
   8732             public static final String NAME = "name";
   8733 
   8734             // TODO add structured name values here.
   8735 
   8736             /**
   8737              * The extra field for the contact phonetic name.
   8738              * <P>Type: String</P>
   8739              */
   8740             public static final String PHONETIC_NAME = "phonetic_name";
   8741 
   8742             /**
   8743              * The extra field for the contact company.
   8744              * <P>Type: String</P>
   8745              */
   8746             public static final String COMPANY = "company";
   8747 
   8748             /**
   8749              * The extra field for the contact job title.
   8750              * <P>Type: String</P>
   8751              */
   8752             public static final String JOB_TITLE = "job_title";
   8753 
   8754             /**
   8755              * The extra field for the contact notes.
   8756              * <P>Type: String</P>
   8757              */
   8758             public static final String NOTES = "notes";
   8759 
   8760             /**
   8761              * The extra field for the contact phone number.
   8762              * <P>Type: String</P>
   8763              */
   8764             public static final String PHONE = "phone";
   8765 
   8766             /**
   8767              * The extra field for the contact phone number type.
   8768              * <P>Type: Either an integer value from
   8769              * {@link CommonDataKinds.Phone},
   8770              *  or a string specifying a custom label.</P>
   8771              */
   8772             public static final String PHONE_TYPE = "phone_type";
   8773 
   8774             /**
   8775              * The extra field for the phone isprimary flag.
   8776              * <P>Type: boolean</P>
   8777              */
   8778             public static final String PHONE_ISPRIMARY = "phone_isprimary";
   8779 
   8780             /**
   8781              * The extra field for an optional second contact phone number.
   8782              * <P>Type: String</P>
   8783              */
   8784             public static final String SECONDARY_PHONE = "secondary_phone";
   8785 
   8786             /**
   8787              * The extra field for an optional second contact phone number type.
   8788              * <P>Type: Either an integer value from
   8789              * {@link CommonDataKinds.Phone},
   8790              *  or a string specifying a custom label.</P>
   8791              */
   8792             public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
   8793 
   8794             /**
   8795              * The extra field for an optional third contact phone number.
   8796              * <P>Type: String</P>
   8797              */
   8798             public static final String TERTIARY_PHONE = "tertiary_phone";
   8799 
   8800             /**
   8801              * The extra field for an optional third contact phone number type.
   8802              * <P>Type: Either an integer value from
   8803              * {@link CommonDataKinds.Phone},
   8804              *  or a string specifying a custom label.</P>
   8805              */
   8806             public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
   8807 
   8808             /**
   8809              * The extra field for the contact email address.
   8810              * <P>Type: String</P>
   8811              */
   8812             public static final String EMAIL = "email";
   8813 
   8814             /**
   8815              * The extra field for the contact email type.
   8816              * <P>Type: Either an integer value from
   8817              * {@link CommonDataKinds.Email}
   8818              *  or a string specifying a custom label.</P>
   8819              */
   8820             public static final String EMAIL_TYPE = "email_type";
   8821 
   8822             /**
   8823              * The extra field for the email isprimary flag.
   8824              * <P>Type: boolean</P>
   8825              */
   8826             public static final String EMAIL_ISPRIMARY = "email_isprimary";
   8827 
   8828             /**
   8829              * The extra field for an optional second contact email address.
   8830              * <P>Type: String</P>
   8831              */
   8832             public static final String SECONDARY_EMAIL = "secondary_email";
   8833 
   8834             /**
   8835              * The extra field for an optional second contact email type.
   8836              * <P>Type: Either an integer value from
   8837              * {@link CommonDataKinds.Email}
   8838              *  or a string specifying a custom label.</P>
   8839              */
   8840             public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
   8841 
   8842             /**
   8843              * The extra field for an optional third contact email address.
   8844              * <P>Type: String</P>
   8845              */
   8846             public static final String TERTIARY_EMAIL = "tertiary_email";
   8847 
   8848             /**
   8849              * The extra field for an optional third contact email type.
   8850              * <P>Type: Either an integer value from
   8851              * {@link CommonDataKinds.Email}
   8852              *  or a string specifying a custom label.</P>
   8853              */
   8854             public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
   8855 
   8856             /**
   8857              * The extra field for the contact postal address.
   8858              * <P>Type: String</P>
   8859              */
   8860             public static final String POSTAL = "postal";
   8861 
   8862             /**
   8863              * The extra field for the contact postal address type.
   8864              * <P>Type: Either an integer value from
   8865              * {@link CommonDataKinds.StructuredPostal}
   8866              *  or a string specifying a custom label.</P>
   8867              */
   8868             public static final String POSTAL_TYPE = "postal_type";
   8869 
   8870             /**
   8871              * The extra field for the postal isprimary flag.
   8872              * <P>Type: boolean</P>
   8873              */
   8874             public static final String POSTAL_ISPRIMARY = "postal_isprimary";
   8875 
   8876             /**
   8877              * The extra field for an IM handle.
   8878              * <P>Type: String</P>
   8879              */
   8880             public static final String IM_HANDLE = "im_handle";
   8881 
   8882             /**
   8883              * The extra field for the IM protocol
   8884              */
   8885             public static final String IM_PROTOCOL = "im_protocol";
   8886 
   8887             /**
   8888              * The extra field for the IM isprimary flag.
   8889              * <P>Type: boolean</P>
   8890              */
   8891             public static final String IM_ISPRIMARY = "im_isprimary";
   8892 
   8893             /**
   8894              * The extra field that allows the client to supply multiple rows of
   8895              * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT}
   8896              * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of
   8897              * {@link ContentValues}, one per data row. Supplying this extra is
   8898              * similar to inserting multiple rows into the {@link Data} table,
   8899              * except the user gets a chance to see and edit them before saving.
   8900              * Each ContentValues object must have a value for {@link Data#MIMETYPE}.
   8901              * If supplied values are not visible in the editor UI, they will be
   8902              * dropped.  Duplicate data will dropped.  Some fields
   8903              * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically
   8904              * adjusted to comply with the constraints of the specific account type.
   8905              * For example, an Exchange contact can only have one phone numbers of type Home,
   8906              * so the contact editor may choose a different type for this phone number to
   8907              * avoid dropping the valueable part of the row, which is the phone number.
   8908              * <p>
   8909              * Example:
   8910              * <pre>
   8911              *  ArrayList&lt;ContentValues&gt; data = new ArrayList&lt;ContentValues&gt;();
   8912              *
   8913              *  ContentValues row1 = new ContentValues();
   8914              *  row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE);
   8915              *  row1.put(Organization.COMPANY, "Android");
   8916              *  data.add(row1);
   8917              *
   8918              *  ContentValues row2 = new ContentValues();
   8919              *  row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
   8920              *  row2.put(Email.TYPE, Email.TYPE_CUSTOM);
   8921              *  row2.put(Email.LABEL, "Green Bot");
   8922              *  row2.put(Email.ADDRESS, "android (at) android.com");
   8923              *  data.add(row2);
   8924              *
   8925              *  Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
   8926              *  intent.putParcelableArrayListExtra(Insert.DATA, data);
   8927              *
   8928              *  startActivity(intent);
   8929              * </pre>
   8930              */
   8931             public static final String DATA = "data";
   8932 
   8933             /**
   8934              * Used to specify the account in which to create the new contact.
   8935              * <p>
   8936              * If this value is not provided, the user is presented with a disambiguation
   8937              * dialog to chose an account
   8938              * <p>
   8939              * Type: {@link Account}
   8940              */
   8941             public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT";
   8942 
   8943             /**
   8944              * Used to specify the data set within the account in which to create the
   8945              * new contact.
   8946              * <p>
   8947              * This value is optional - if it is not specified, the contact will be
   8948              * created in the base account, with no data set.
   8949              * <p>
   8950              * Type: String
   8951              */
   8952             public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET";
   8953         }
   8954     }
   8955 }
   8956