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