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