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