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