ContactsContract.java revision da072b3e38ff41ee3e8867cc85d0281422a17cb0
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 phone number as the user entered it. 4986 * <P>Type: TEXT</P> 4987 */ 4988 public static final String NUMBER = "number"; 4989 4990 /** 4991 * The type of phone number, for example Home or Work. 4992 * <P>Type: INTEGER</P> 4993 */ 4994 public static final String TYPE = "type"; 4995 4996 /** 4997 * The user defined label for the phone number. 4998 * <P>Type: TEXT</P> 4999 */ 5000 public static final String LABEL = "label"; 5001 5002 /** 5003 * The phone number's E164 representation. 5004 * <P>Type: TEXT</P> 5005 */ 5006 public static final String NORMALIZED_NUMBER = "normalized_number"; 5007 } 5008 5009 /** 5010 * A table that represents the result of looking up a phone number, for 5011 * example for caller ID. To perform a lookup you must append the number you 5012 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly 5013 * optimized. 5014 * <pre> 5015 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); 5016 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... 5017 * </pre> 5018 * 5019 * <h3>Columns</h3> 5020 * 5021 * <table class="jd-sumtable"> 5022 * <tr> 5023 * <th colspan='4'>PhoneLookup</th> 5024 * </tr> 5025 * <tr> 5026 * <td>String</td> 5027 * <td>{@link #NUMBER}</td> 5028 * <td>read-only</td> 5029 * <td>Phone number.</td> 5030 * </tr> 5031 * <tr> 5032 * <td>String</td> 5033 * <td>{@link #TYPE}</td> 5034 * <td>read-only</td> 5035 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> 5036 * </tr> 5037 * <tr> 5038 * <td>String</td> 5039 * <td>{@link #LABEL}</td> 5040 * <td>read-only</td> 5041 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> 5042 * </tr> 5043 * </table> 5044 * <p> 5045 * Columns from the Contacts table are also available through a join. 5046 * </p> 5047 * <table class="jd-sumtable"> 5048 * <tr> 5049 * <th colspan='4'>Join with {@link Contacts}</th> 5050 * </tr> 5051 * <tr> 5052 * <td>long</td> 5053 * <td>{@link #_ID}</td> 5054 * <td>read-only</td> 5055 * <td>Contact ID.</td> 5056 * </tr> 5057 * <tr> 5058 * <td>String</td> 5059 * <td>{@link #LOOKUP_KEY}</td> 5060 * <td>read-only</td> 5061 * <td>See {@link ContactsContract.Contacts}</td> 5062 * </tr> 5063 * <tr> 5064 * <td>String</td> 5065 * <td>{@link #DISPLAY_NAME}</td> 5066 * <td>read-only</td> 5067 * <td>See {@link ContactsContract.Contacts}</td> 5068 * </tr> 5069 * <tr> 5070 * <td>long</td> 5071 * <td>{@link #PHOTO_ID}</td> 5072 * <td>read-only</td> 5073 * <td>See {@link ContactsContract.Contacts}.</td> 5074 * </tr> 5075 * <tr> 5076 * <td>int</td> 5077 * <td>{@link #IN_VISIBLE_GROUP}</td> 5078 * <td>read-only</td> 5079 * <td>See {@link ContactsContract.Contacts}.</td> 5080 * </tr> 5081 * <tr> 5082 * <td>int</td> 5083 * <td>{@link #HAS_PHONE_NUMBER}</td> 5084 * <td>read-only</td> 5085 * <td>See {@link ContactsContract.Contacts}.</td> 5086 * </tr> 5087 * <tr> 5088 * <td>int</td> 5089 * <td>{@link #TIMES_CONTACTED}</td> 5090 * <td>read-only</td> 5091 * <td>See {@link ContactsContract.Contacts}.</td> 5092 * </tr> 5093 * <tr> 5094 * <td>long</td> 5095 * <td>{@link #LAST_TIME_CONTACTED}</td> 5096 * <td>read-only</td> 5097 * <td>See {@link ContactsContract.Contacts}.</td> 5098 * </tr> 5099 * <tr> 5100 * <td>int</td> 5101 * <td>{@link #STARRED}</td> 5102 * <td>read-only</td> 5103 * <td>See {@link ContactsContract.Contacts}.</td> 5104 * </tr> 5105 * <tr> 5106 * <td>String</td> 5107 * <td>{@link #CUSTOM_RINGTONE}</td> 5108 * <td>read-only</td> 5109 * <td>See {@link ContactsContract.Contacts}.</td> 5110 * </tr> 5111 * <tr> 5112 * <td>int</td> 5113 * <td>{@link #SEND_TO_VOICEMAIL}</td> 5114 * <td>read-only</td> 5115 * <td>See {@link ContactsContract.Contacts}.</td> 5116 * </tr> 5117 * </table> 5118 */ 5119 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, 5120 ContactsColumns, ContactOptionsColumns { 5121 /** 5122 * This utility class cannot be instantiated 5123 */ 5124 private PhoneLookup() {} 5125 5126 /** 5127 * The content:// style URI for this table. Append the phone number you want to lookup 5128 * to this URI and query it to perform a lookup. For example: 5129 * <pre> 5130 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, 5131 * Uri.encode(phoneNumber)); 5132 * </pre> 5133 */ 5134 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, 5135 "phone_lookup"); 5136 5137 /** 5138 * <p>URI used for the "enterprise caller-id".</p> 5139 * 5140 * <p> 5141 * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same 5142 * columns. If the device has no corp profile that is linked to the current profile, it 5143 * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile 5144 * linked to the current profile, it first queries against the personal contact database, 5145 * and if no matching contacts are found there, then queries against the 5146 * corp contacts database. 5147 * </p> 5148 * <p> 5149 * If a result is from the corp profile, it makes the following changes to the data: 5150 * <ul> 5151 * <li> 5152 * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special 5153 * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to 5154 * load pictures from them. 5155 * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them. 5156 * </li> 5157 * <li> 5158 * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact 5159 * is from the corp profile, use 5160 * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. 5161 * </li> 5162 * <li> 5163 * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. 5164 * </li> 5165 * </ul> 5166 * <p> 5167 * A contact lookup URL built by 5168 * {@link ContactsContract.Contacts#getLookupUri(long, String)} 5169 * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to 5170 * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the 5171 * corp profile. 5172 * </p> 5173 * 5174 * <pre> 5175 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, 5176 * Uri.encode(phoneNumber)); 5177 * </pre> 5178 */ 5179 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, 5180 "phone_lookup_enterprise"); 5181 5182 /** 5183 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. 5184 * 5185 * @hide 5186 */ 5187 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; 5188 5189 /** 5190 * If this boolean parameter is set to true, then the appended query is treated as a 5191 * SIP address and the lookup will be performed against SIP addresses in the user's 5192 * contacts. 5193 */ 5194 public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; 5195 } 5196 5197 /** 5198 * Additional data mixed in with {@link StatusColumns} to link 5199 * back to specific {@link ContactsContract.Data#_ID} entries. 5200 * 5201 * @see StatusUpdates 5202 */ 5203 protected interface PresenceColumns { 5204 5205 /** 5206 * Reference to the {@link Data#_ID} entry that owns this presence. 5207 * <P>Type: INTEGER</P> 5208 */ 5209 public static final String DATA_ID = "presence_data_id"; 5210 5211 /** 5212 * See {@link CommonDataKinds.Im} for a list of defined protocol constants. 5213 * <p>Type: NUMBER</p> 5214 */ 5215 public static final String PROTOCOL = "protocol"; 5216 5217 /** 5218 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 5219 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 5220 * omitted if {@link #PROTOCOL} value is not 5221 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. 5222 * 5223 * <p>Type: NUMBER</p> 5224 */ 5225 public static final String CUSTOM_PROTOCOL = "custom_protocol"; 5226 5227 /** 5228 * The IM handle the presence item is for. The handle is scoped to 5229 * {@link #PROTOCOL}. 5230 * <P>Type: TEXT</P> 5231 */ 5232 public static final String IM_HANDLE = "im_handle"; 5233 5234 /** 5235 * The IM account for the local user that the presence data came from. 5236 * <P>Type: TEXT</P> 5237 */ 5238 public static final String IM_ACCOUNT = "im_account"; 5239 } 5240 5241 /** 5242 * <p> 5243 * A status update is linked to a {@link ContactsContract.Data} row and captures 5244 * the user's latest status update via the corresponding source, e.g. 5245 * "Having lunch" via "Google Talk". 5246 * </p> 5247 * <p> 5248 * There are two ways a status update can be inserted: by explicitly linking 5249 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row 5250 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 5251 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use 5252 * either. 5253 * </p> 5254 * <p> 5255 * Inserting or updating a status update for the user's profile requires either using 5256 * the {@link #DATA_ID} to identify the data row to attach the update to, or 5257 * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the 5258 * profile. 5259 * </p> 5260 * <p> 5261 * You cannot use {@link ContentResolver#update} to change a status, but 5262 * {@link ContentResolver#insert} will replace the latests status if it already 5263 * exists. 5264 * </p> 5265 * <p> 5266 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses 5267 * for multiple contacts at once. 5268 * </p> 5269 * 5270 * <h3>Columns</h3> 5271 * <table class="jd-sumtable"> 5272 * <tr> 5273 * <th colspan='4'>StatusUpdates</th> 5274 * </tr> 5275 * <tr> 5276 * <td>long</td> 5277 * <td>{@link #DATA_ID}</td> 5278 * <td>read/write</td> 5279 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this 5280 * field is <i>not</i> specified, the provider will attempt to find a data row 5281 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 5282 * {@link #IM_HANDLE} columns. 5283 * </td> 5284 * </tr> 5285 * <tr> 5286 * <td>long</td> 5287 * <td>{@link #PROTOCOL}</td> 5288 * <td>read/write</td> 5289 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> 5290 * </tr> 5291 * <tr> 5292 * <td>String</td> 5293 * <td>{@link #CUSTOM_PROTOCOL}</td> 5294 * <td>read/write</td> 5295 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 5296 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 5297 * omitted if {@link #PROTOCOL} value is not 5298 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> 5299 * </tr> 5300 * <tr> 5301 * <td>String</td> 5302 * <td>{@link #IM_HANDLE}</td> 5303 * <td>read/write</td> 5304 * <td> The IM handle the presence item is for. The handle is scoped to 5305 * {@link #PROTOCOL}.</td> 5306 * </tr> 5307 * <tr> 5308 * <td>String</td> 5309 * <td>{@link #IM_ACCOUNT}</td> 5310 * <td>read/write</td> 5311 * <td>The IM account for the local user that the presence data came from.</td> 5312 * </tr> 5313 * <tr> 5314 * <td>int</td> 5315 * <td>{@link #PRESENCE}</td> 5316 * <td>read/write</td> 5317 * <td>Contact IM presence status. The allowed values are: 5318 * <p> 5319 * <ul> 5320 * <li>{@link #OFFLINE}</li> 5321 * <li>{@link #INVISIBLE}</li> 5322 * <li>{@link #AWAY}</li> 5323 * <li>{@link #IDLE}</li> 5324 * <li>{@link #DO_NOT_DISTURB}</li> 5325 * <li>{@link #AVAILABLE}</li> 5326 * </ul> 5327 * </p> 5328 * <p> 5329 * Since presence status is inherently volatile, the content provider 5330 * may choose not to store this field in long-term storage. 5331 * </p> 5332 * </td> 5333 * </tr> 5334 * <tr> 5335 * <td>int</td> 5336 * <td>{@link #CHAT_CAPABILITY}</td> 5337 * <td>read/write</td> 5338 * <td>Contact IM chat compatibility value. The allowed values combinations of the following 5339 * flags. If None of these flags is set, the device can only do text messaging. 5340 * <p> 5341 * <ul> 5342 * <li>{@link #CAPABILITY_HAS_VIDEO}</li> 5343 * <li>{@link #CAPABILITY_HAS_VOICE}</li> 5344 * <li>{@link #CAPABILITY_HAS_CAMERA}</li> 5345 * </ul> 5346 * </p> 5347 * <p> 5348 * Since chat compatibility is inherently volatile as the contact's availability moves from 5349 * one device to another, the content provider may choose not to store this field in long-term 5350 * storage. 5351 * </p> 5352 * </td> 5353 * </tr> 5354 * <tr> 5355 * <td>String</td> 5356 * <td>{@link #STATUS}</td> 5357 * <td>read/write</td> 5358 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> 5359 * </tr> 5360 * <tr> 5361 * <td>long</td> 5362 * <td>{@link #STATUS_TIMESTAMP}</td> 5363 * <td>read/write</td> 5364 * <td>The absolute time in milliseconds when the status was 5365 * entered by the user. If this value is not provided, the provider will follow 5366 * this logic: if there was no prior status update, the value will be left as null. 5367 * If there was a prior status update, the provider will default this field 5368 * to the current time.</td> 5369 * </tr> 5370 * <tr> 5371 * <td>String</td> 5372 * <td>{@link #STATUS_RES_PACKAGE}</td> 5373 * <td>read/write</td> 5374 * <td> The package containing resources for this status: label and icon.</td> 5375 * </tr> 5376 * <tr> 5377 * <td>long</td> 5378 * <td>{@link #STATUS_LABEL}</td> 5379 * <td>read/write</td> 5380 * <td>The resource ID of the label describing the source of contact status, 5381 * e.g. "Google Talk". This resource is scoped by the 5382 * {@link #STATUS_RES_PACKAGE}.</td> 5383 * </tr> 5384 * <tr> 5385 * <td>long</td> 5386 * <td>{@link #STATUS_ICON}</td> 5387 * <td>read/write</td> 5388 * <td>The resource ID of the icon for the source of contact status. This 5389 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 5390 * </tr> 5391 * </table> 5392 */ 5393 public static class StatusUpdates implements StatusColumns, PresenceColumns { 5394 5395 /** 5396 * This utility class cannot be instantiated 5397 */ 5398 private StatusUpdates() {} 5399 5400 /** 5401 * The content:// style URI for this table 5402 */ 5403 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); 5404 5405 /** 5406 * The content:// style URI for this table, specific to the user's profile. 5407 */ 5408 public static final Uri PROFILE_CONTENT_URI = 5409 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); 5410 5411 /** 5412 * Gets the resource ID for the proper presence icon. 5413 * 5414 * @param status the status to get the icon for 5415 * @return the resource ID for the proper presence icon 5416 */ 5417 public static final int getPresenceIconResourceId(int status) { 5418 switch (status) { 5419 case AVAILABLE: 5420 return android.R.drawable.presence_online; 5421 case IDLE: 5422 case AWAY: 5423 return android.R.drawable.presence_away; 5424 case DO_NOT_DISTURB: 5425 return android.R.drawable.presence_busy; 5426 case INVISIBLE: 5427 return android.R.drawable.presence_invisible; 5428 case OFFLINE: 5429 default: 5430 return android.R.drawable.presence_offline; 5431 } 5432 } 5433 5434 /** 5435 * Returns the precedence of the status code the higher number being the higher precedence. 5436 * 5437 * @param status The status code. 5438 * @return An integer representing the precedence, 0 being the lowest. 5439 */ 5440 public static final int getPresencePrecedence(int status) { 5441 // Keep this function here incase we want to enforce a different precedence than the 5442 // natural order of the status constants. 5443 return status; 5444 } 5445 5446 /** 5447 * The MIME type of {@link #CONTENT_URI} providing a directory of 5448 * status update details. 5449 */ 5450 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; 5451 5452 /** 5453 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 5454 * status update detail. 5455 */ 5456 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; 5457 } 5458 5459 /** 5460 * @deprecated This old name was never meant to be made public. Do not use. 5461 */ 5462 @Deprecated 5463 public static final class Presence extends StatusUpdates { 5464 5465 } 5466 5467 /** 5468 * Additional column returned by 5469 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining 5470 * why the filter matched the contact. This column will contain extracts from the contact's 5471 * constituent {@link Data Data} items, formatted in a way that indicates the section of the 5472 * snippet that matched the filter. 5473 * 5474 * <p> 5475 * The following example searches for all contacts that match the query "presi" and requests 5476 * the snippet column as well. 5477 * <pre> 5478 * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon(); 5479 * builder.appendPath("presi"); 5480 * // Defer snippeting to the client side if possible, for performance reasons. 5481 * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1"); 5482 * 5483 * Cursor cursor = getContentResolver().query(builder.build()); 5484 * 5485 * Bundle extras = cursor.getExtras(); 5486 * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { 5487 * // Do our own snippet formatting. 5488 * // For a contact with the email address (president@organization.com), the snippet 5489 * // column will contain the string "president@organization.com". 5490 * } else { 5491 * // The snippet has already been pre-formatted, we can display it as is. 5492 * // For a contact with the email address (president@organization.com), the snippet 5493 * // column will contain the string "[presi]dent@organization.com". 5494 * } 5495 * </pre> 5496 * </p> 5497 */ 5498 public static class SearchSnippets { 5499 5500 /** 5501 * The search snippet constructed by SQLite snippeting functionality. 5502 * <p> 5503 * The snippet may contain (parts of) several data elements belonging to the contact, 5504 * with the matching parts optionally surrounded by special characters that indicate the 5505 * start and end of matching text. 5506 * 5507 * For example, if a contact has an address "123 Main Street", using a filter "mai" would 5508 * return the formatted snippet "123 [Mai]n street". 5509 * 5510 * @see <a href="http://www.sqlite.org/fts3.html#snippet"> 5511 * http://www.sqlite.org/fts3.html#snippet</a> 5512 */ 5513 public static final String SNIPPET = "snippet"; 5514 5515 /** 5516 * Comma-separated parameters for the generation of the snippet: 5517 * <ul> 5518 * <li>The "start match" text. Default is '['</li> 5519 * <li>The "end match" text. Default is ']'</li> 5520 * <li>The "ellipsis" text. Default is "..."</li> 5521 * <li>Maximum number of tokens to include in the snippet. Can be either 5522 * a positive or a negative number: A positive number indicates how many 5523 * tokens can be returned in total. A negative number indicates how many 5524 * tokens can be returned per occurrence of the search terms.</li> 5525 * </ul> 5526 * 5527 * @hide 5528 */ 5529 public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; 5530 5531 /** 5532 * The key to ask the provider to defer the formatting of the snippet to the client if 5533 * possible, for performance reasons. 5534 * A value of 1 indicates true, 0 indicates false. False is the default. 5535 * When a cursor is returned to the client, it should check for an extra with the name 5536 * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client 5537 * should do its own formatting of the snippet. If it doesn't exist, the snippet column 5538 * in the cursor should already contain a formatted snippet. 5539 */ 5540 public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; 5541 } 5542 5543 /** 5544 * Container for definitions of common data types stored in the {@link ContactsContract.Data} 5545 * table. 5546 */ 5547 public static final class CommonDataKinds { 5548 /** 5549 * This utility class cannot be instantiated 5550 */ 5551 private CommonDataKinds() {} 5552 5553 /** 5554 * The {@link Data#RES_PACKAGE} value for common data that should be 5555 * shown using a default style. 5556 * 5557 * @hide RES_PACKAGE is hidden 5558 */ 5559 public static final String PACKAGE_COMMON = "common"; 5560 5561 /** 5562 * The base types that all "Typed" data kinds support. 5563 */ 5564 public interface BaseTypes { 5565 /** 5566 * A custom type. The custom label should be supplied by user. 5567 */ 5568 public static int TYPE_CUSTOM = 0; 5569 } 5570 5571 /** 5572 * Columns common across the specific types. 5573 */ 5574 protected interface CommonColumns extends BaseTypes { 5575 /** 5576 * The data for the contact method. 5577 * <P>Type: TEXT</P> 5578 */ 5579 public static final String DATA = DataColumns.DATA1; 5580 5581 /** 5582 * The type of data, for example Home or Work. 5583 * <P>Type: INTEGER</P> 5584 */ 5585 public static final String TYPE = DataColumns.DATA2; 5586 5587 /** 5588 * The user defined label for the the contact method. 5589 * <P>Type: TEXT</P> 5590 */ 5591 public static final String LABEL = DataColumns.DATA3; 5592 } 5593 5594 /** 5595 * A data kind representing the contact's proper name. You can use all 5596 * columns defined for {@link ContactsContract.Data} as well as the following aliases. 5597 * 5598 * <h2>Column aliases</h2> 5599 * <table class="jd-sumtable"> 5600 * <tr> 5601 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 5602 * </tr> 5603 * <tr> 5604 * <td>String</td> 5605 * <td>{@link #DISPLAY_NAME}</td> 5606 * <td>{@link #DATA1}</td> 5607 * <td></td> 5608 * </tr> 5609 * <tr> 5610 * <td>String</td> 5611 * <td>{@link #GIVEN_NAME}</td> 5612 * <td>{@link #DATA2}</td> 5613 * <td></td> 5614 * </tr> 5615 * <tr> 5616 * <td>String</td> 5617 * <td>{@link #FAMILY_NAME}</td> 5618 * <td>{@link #DATA3}</td> 5619 * <td></td> 5620 * </tr> 5621 * <tr> 5622 * <td>String</td> 5623 * <td>{@link #PREFIX}</td> 5624 * <td>{@link #DATA4}</td> 5625 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> 5626 * </tr> 5627 * <tr> 5628 * <td>String</td> 5629 * <td>{@link #MIDDLE_NAME}</td> 5630 * <td>{@link #DATA5}</td> 5631 * <td></td> 5632 * </tr> 5633 * <tr> 5634 * <td>String</td> 5635 * <td>{@link #SUFFIX}</td> 5636 * <td>{@link #DATA6}</td> 5637 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> 5638 * </tr> 5639 * <tr> 5640 * <td>String</td> 5641 * <td>{@link #PHONETIC_GIVEN_NAME}</td> 5642 * <td>{@link #DATA7}</td> 5643 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> 5644 * </tr> 5645 * <tr> 5646 * <td>String</td> 5647 * <td>{@link #PHONETIC_MIDDLE_NAME}</td> 5648 * <td>{@link #DATA8}</td> 5649 * <td></td> 5650 * </tr> 5651 * <tr> 5652 * <td>String</td> 5653 * <td>{@link #PHONETIC_FAMILY_NAME}</td> 5654 * <td>{@link #DATA9}</td> 5655 * <td></td> 5656 * </tr> 5657 * </table> 5658 */ 5659 public static final class StructuredName implements DataColumnsWithJoins, ContactCounts { 5660 /** 5661 * This utility class cannot be instantiated 5662 */ 5663 private StructuredName() {} 5664 5665 /** MIME type used when storing this in data table. */ 5666 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; 5667 5668 /** 5669 * The name that should be used to display the contact. 5670 * <i>Unstructured component of the name should be consistent with 5671 * its structured representation.</i> 5672 * <p> 5673 * Type: TEXT 5674 */ 5675 public static final String DISPLAY_NAME = DATA1; 5676 5677 /** 5678 * The given name for the contact. 5679 * <P>Type: TEXT</P> 5680 */ 5681 public static final String GIVEN_NAME = DATA2; 5682 5683 /** 5684 * The family name for the contact. 5685 * <P>Type: TEXT</P> 5686 */ 5687 public static final String FAMILY_NAME = DATA3; 5688 5689 /** 5690 * The contact's honorific prefix, e.g. "Sir" 5691 * <P>Type: TEXT</P> 5692 */ 5693 public static final String PREFIX = DATA4; 5694 5695 /** 5696 * The contact's middle name 5697 * <P>Type: TEXT</P> 5698 */ 5699 public static final String MIDDLE_NAME = DATA5; 5700 5701 /** 5702 * The contact's honorific suffix, e.g. "Jr" 5703 */ 5704 public static final String SUFFIX = DATA6; 5705 5706 /** 5707 * The phonetic version of the given name for the contact. 5708 * <P>Type: TEXT</P> 5709 */ 5710 public static final String PHONETIC_GIVEN_NAME = DATA7; 5711 5712 /** 5713 * The phonetic version of the additional name for the contact. 5714 * <P>Type: TEXT</P> 5715 */ 5716 public static final String PHONETIC_MIDDLE_NAME = DATA8; 5717 5718 /** 5719 * The phonetic version of the family name for the contact. 5720 * <P>Type: TEXT</P> 5721 */ 5722 public static final String PHONETIC_FAMILY_NAME = DATA9; 5723 5724 /** 5725 * The style used for combining given/middle/family name into a full name. 5726 * See {@link ContactsContract.FullNameStyle}. 5727 */ 5728 public static final String FULL_NAME_STYLE = DATA10; 5729 5730 /** 5731 * The alphabet used for capturing the phonetic name. 5732 * See ContactsContract.PhoneticNameStyle. 5733 */ 5734 public static final String PHONETIC_NAME_STYLE = DATA11; 5735 } 5736 5737 /** 5738 * <p>A data kind representing the contact's nickname. For example, for 5739 * Bob Parr ("Mr. Incredible"): 5740 * <pre> 5741 * ArrayList<ContentProviderOperation> ops = 5742 * new ArrayList<ContentProviderOperation>(); 5743 * 5744 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 5745 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 5746 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 5747 * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") 5748 * .build()); 5749 * 5750 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 5751 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 5752 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) 5753 * .withValue(Nickname.NAME, "Mr. Incredible") 5754 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) 5755 * .withValue(Nickname.LABEL, "Superhero") 5756 * .build()); 5757 * 5758 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 5759 * </pre> 5760 * </p> 5761 * <p> 5762 * You can use all columns defined for {@link ContactsContract.Data} as well as the 5763 * following aliases. 5764 * </p> 5765 * 5766 * <h2>Column aliases</h2> 5767 * <table class="jd-sumtable"> 5768 * <tr> 5769 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 5770 * </tr> 5771 * <tr> 5772 * <td>String</td> 5773 * <td>{@link #NAME}</td> 5774 * <td>{@link #DATA1}</td> 5775 * <td></td> 5776 * </tr> 5777 * <tr> 5778 * <td>int</td> 5779 * <td>{@link #TYPE}</td> 5780 * <td>{@link #DATA2}</td> 5781 * <td> 5782 * Allowed values are: 5783 * <p> 5784 * <ul> 5785 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 5786 * <li>{@link #TYPE_DEFAULT}</li> 5787 * <li>{@link #TYPE_OTHER_NAME}</li> 5788 * <li>{@link #TYPE_MAIDEN_NAME}</li> 5789 * <li>{@link #TYPE_SHORT_NAME}</li> 5790 * <li>{@link #TYPE_INITIALS}</li> 5791 * </ul> 5792 * </p> 5793 * </td> 5794 * </tr> 5795 * <tr> 5796 * <td>String</td> 5797 * <td>{@link #LABEL}</td> 5798 * <td>{@link #DATA3}</td> 5799 * <td></td> 5800 * </tr> 5801 * </table> 5802 */ 5803 public static final class Nickname implements DataColumnsWithJoins, CommonColumns, 5804 ContactCounts{ 5805 /** 5806 * This utility class cannot be instantiated 5807 */ 5808 private Nickname() {} 5809 5810 /** MIME type used when storing this in data table. */ 5811 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; 5812 5813 public static final int TYPE_DEFAULT = 1; 5814 public static final int TYPE_OTHER_NAME = 2; 5815 public static final int TYPE_MAIDEN_NAME = 3; 5816 /** @deprecated Use TYPE_MAIDEN_NAME instead. */ 5817 @Deprecated 5818 public static final int TYPE_MAINDEN_NAME = 3; 5819 public static final int TYPE_SHORT_NAME = 4; 5820 public static final int TYPE_INITIALS = 5; 5821 5822 /** 5823 * The name itself 5824 */ 5825 public static final String NAME = DATA; 5826 } 5827 5828 /** 5829 * <p> 5830 * A data kind representing a telephone number. 5831 * </p> 5832 * <p> 5833 * You can use all columns defined for {@link ContactsContract.Data} as 5834 * well as the following aliases. 5835 * </p> 5836 * <h2>Column aliases</h2> 5837 * <table class="jd-sumtable"> 5838 * <tr> 5839 * <th>Type</th> 5840 * <th>Alias</th><th colspan='2'>Data column</th> 5841 * </tr> 5842 * <tr> 5843 * <td>String</td> 5844 * <td>{@link #NUMBER}</td> 5845 * <td>{@link #DATA1}</td> 5846 * <td></td> 5847 * </tr> 5848 * <tr> 5849 * <td>int</td> 5850 * <td>{@link #TYPE}</td> 5851 * <td>{@link #DATA2}</td> 5852 * <td>Allowed values are: 5853 * <p> 5854 * <ul> 5855 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 5856 * <li>{@link #TYPE_HOME}</li> 5857 * <li>{@link #TYPE_MOBILE}</li> 5858 * <li>{@link #TYPE_WORK}</li> 5859 * <li>{@link #TYPE_FAX_WORK}</li> 5860 * <li>{@link #TYPE_FAX_HOME}</li> 5861 * <li>{@link #TYPE_PAGER}</li> 5862 * <li>{@link #TYPE_OTHER}</li> 5863 * <li>{@link #TYPE_CALLBACK}</li> 5864 * <li>{@link #TYPE_CAR}</li> 5865 * <li>{@link #TYPE_COMPANY_MAIN}</li> 5866 * <li>{@link #TYPE_ISDN}</li> 5867 * <li>{@link #TYPE_MAIN}</li> 5868 * <li>{@link #TYPE_OTHER_FAX}</li> 5869 * <li>{@link #TYPE_RADIO}</li> 5870 * <li>{@link #TYPE_TELEX}</li> 5871 * <li>{@link #TYPE_TTY_TDD}</li> 5872 * <li>{@link #TYPE_WORK_MOBILE}</li> 5873 * <li>{@link #TYPE_WORK_PAGER}</li> 5874 * <li>{@link #TYPE_ASSISTANT}</li> 5875 * <li>{@link #TYPE_MMS}</li> 5876 * </ul> 5877 * </p> 5878 * </td> 5879 * </tr> 5880 * <tr> 5881 * <td>String</td> 5882 * <td>{@link #LABEL}</td> 5883 * <td>{@link #DATA3}</td> 5884 * <td></td> 5885 * </tr> 5886 * </table> 5887 */ 5888 public static final class Phone implements DataColumnsWithJoins, CommonColumns, 5889 ContactCounts { 5890 /** 5891 * This utility class cannot be instantiated 5892 */ 5893 private Phone() {} 5894 5895 /** MIME type used when storing this in data table. */ 5896 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2"; 5897 5898 /** 5899 * The MIME type of {@link #CONTENT_URI} providing a directory of 5900 * phones. 5901 */ 5902 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; 5903 5904 /** 5905 * The content:// style URI for all data records of the 5906 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 5907 * associated raw contact and aggregate contact data. 5908 */ 5909 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 5910 "phones"); 5911 5912 /** 5913 * URI used for getting all contacts from primary and managed profile. 5914 * 5915 * It supports the same semantics as {@link #CONTENT_URI} and returns the same 5916 * columns. If the device has no corp profile that is linked to the current profile, it 5917 * behaves in the exact same way as {@link #CONTENT_URI}. If there is a corp profile 5918 * linked to the current profile, it will merge corp profile and current profile's 5919 * results and return 5920 * 5921 * @hide 5922 */ 5923 public static final Uri ENTERPRISE_CONTENT_URI = 5924 Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones"); 5925 5926 /** 5927 * The content:// style URL for phone lookup using a filter. The filter returns 5928 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 5929 * to display names as well as phone numbers. The filter argument should be passed 5930 * as an additional path segment after this URI. 5931 */ 5932 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 5933 "filter"); 5934 5935 /** 5936 * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same 5937 * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in 5938 * parameters, otherwise it will throw UnsupportedOperationException. 5939 */ 5940 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( 5941 CONTENT_URI, "filter_enterprise"); 5942 5943 /** 5944 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. 5945 * If "1" or "true", display names are searched. If "0" or "false", display names 5946 * are not searched. Default is "1". 5947 */ 5948 public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; 5949 5950 /** 5951 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. 5952 * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers 5953 * are not searched. Default is "1". 5954 */ 5955 public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; 5956 5957 public static final int TYPE_HOME = 1; 5958 public static final int TYPE_MOBILE = 2; 5959 public static final int TYPE_WORK = 3; 5960 public static final int TYPE_FAX_WORK = 4; 5961 public static final int TYPE_FAX_HOME = 5; 5962 public static final int TYPE_PAGER = 6; 5963 public static final int TYPE_OTHER = 7; 5964 public static final int TYPE_CALLBACK = 8; 5965 public static final int TYPE_CAR = 9; 5966 public static final int TYPE_COMPANY_MAIN = 10; 5967 public static final int TYPE_ISDN = 11; 5968 public static final int TYPE_MAIN = 12; 5969 public static final int TYPE_OTHER_FAX = 13; 5970 public static final int TYPE_RADIO = 14; 5971 public static final int TYPE_TELEX = 15; 5972 public static final int TYPE_TTY_TDD = 16; 5973 public static final int TYPE_WORK_MOBILE = 17; 5974 public static final int TYPE_WORK_PAGER = 18; 5975 public static final int TYPE_ASSISTANT = 19; 5976 public static final int TYPE_MMS = 20; 5977 5978 /** 5979 * The phone number as the user entered it. 5980 * <P>Type: TEXT</P> 5981 */ 5982 public static final String NUMBER = DATA; 5983 5984 /** 5985 * The phone number's E164 representation. This value can be omitted in which 5986 * case the provider will try to automatically infer it. (It'll be left null if the 5987 * provider fails to infer.) 5988 * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise). 5989 * <P>Type: TEXT</P> 5990 */ 5991 public static final String NORMALIZED_NUMBER = DATA4; 5992 5993 /** 5994 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 5995 * @hide 5996 */ 5997 @Deprecated 5998 public static final CharSequence getDisplayLabel(Context context, int type, 5999 CharSequence label, CharSequence[] labelArray) { 6000 return getTypeLabel(context.getResources(), type, label); 6001 } 6002 6003 /** 6004 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 6005 * @hide 6006 */ 6007 @Deprecated 6008 public static final CharSequence getDisplayLabel(Context context, int type, 6009 CharSequence label) { 6010 return getTypeLabel(context.getResources(), type, label); 6011 } 6012 6013 /** 6014 * Return the string resource that best describes the given 6015 * {@link #TYPE}. Will always return a valid resource. 6016 */ 6017 public static final int getTypeLabelResource(int type) { 6018 switch (type) { 6019 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; 6020 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; 6021 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; 6022 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; 6023 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; 6024 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; 6025 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; 6026 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; 6027 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; 6028 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; 6029 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; 6030 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; 6031 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; 6032 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; 6033 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; 6034 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; 6035 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; 6036 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; 6037 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; 6038 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; 6039 default: return com.android.internal.R.string.phoneTypeCustom; 6040 } 6041 } 6042 6043 /** 6044 * Return a {@link CharSequence} that best describes the given type, 6045 * possibly substituting the given {@link #LABEL} value 6046 * for {@link #TYPE_CUSTOM}. 6047 */ 6048 public static final CharSequence getTypeLabel(Resources res, int type, 6049 CharSequence label) { 6050 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { 6051 return label; 6052 } else { 6053 final int labelRes = getTypeLabelResource(type); 6054 return res.getText(labelRes); 6055 } 6056 } 6057 } 6058 6059 /** 6060 * <p> 6061 * A data kind representing an email address. 6062 * </p> 6063 * <p> 6064 * You can use all columns defined for {@link ContactsContract.Data} as 6065 * well as the following aliases. 6066 * </p> 6067 * <h2>Column aliases</h2> 6068 * <table class="jd-sumtable"> 6069 * <tr> 6070 * <th>Type</th> 6071 * <th>Alias</th><th colspan='2'>Data column</th> 6072 * </tr> 6073 * <tr> 6074 * <td>String</td> 6075 * <td>{@link #ADDRESS}</td> 6076 * <td>{@link #DATA1}</td> 6077 * <td>Email address itself.</td> 6078 * </tr> 6079 * <tr> 6080 * <td>int</td> 6081 * <td>{@link #TYPE}</td> 6082 * <td>{@link #DATA2}</td> 6083 * <td>Allowed values are: 6084 * <p> 6085 * <ul> 6086 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6087 * <li>{@link #TYPE_HOME}</li> 6088 * <li>{@link #TYPE_WORK}</li> 6089 * <li>{@link #TYPE_OTHER}</li> 6090 * <li>{@link #TYPE_MOBILE}</li> 6091 * </ul> 6092 * </p> 6093 * </td> 6094 * </tr> 6095 * <tr> 6096 * <td>String</td> 6097 * <td>{@link #LABEL}</td> 6098 * <td>{@link #DATA3}</td> 6099 * <td></td> 6100 * </tr> 6101 * </table> 6102 */ 6103 public static final class Email implements DataColumnsWithJoins, CommonColumns, 6104 ContactCounts { 6105 /** 6106 * This utility class cannot be instantiated 6107 */ 6108 private Email() {} 6109 6110 /** MIME type used when storing this in data table. */ 6111 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2"; 6112 6113 /** 6114 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. 6115 */ 6116 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; 6117 6118 /** 6119 * The content:// style URI for all data records of the 6120 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 6121 * associated raw contact and aggregate contact data. 6122 */ 6123 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 6124 "emails"); 6125 6126 /** 6127 * <p> 6128 * The content:// style URL for looking up data rows by email address. The 6129 * lookup argument, an email address, should be passed as an additional path segment 6130 * after this URI. 6131 * </p> 6132 * <p>Example: 6133 * <pre> 6134 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); 6135 * Cursor c = getContentResolver().query(uri, 6136 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, 6137 * null, null, null); 6138 * </pre> 6139 * </p> 6140 */ 6141 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, 6142 "lookup"); 6143 6144 /** 6145 * <p>URI used for enterprise email lookup.</p> 6146 * 6147 * <p> 6148 * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same 6149 * columns. If the device has no corp profile that is linked to the current profile, it 6150 * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}. If there is a 6151 * corp profile linked to the current profile, it first queries against the personal contact database, 6152 * and if no matching contacts are found there, then queries against the 6153 * corp contacts database. 6154 * </p> 6155 * <p> 6156 * If a result is from the corp profile, it makes the following changes to the data: 6157 * <ul> 6158 * <li> 6159 * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special 6160 * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to 6161 * load pictures from them. 6162 * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not 6163 * use them. 6164 * </li> 6165 * <li> 6166 * Corp contacts will get artificial {@link #CONTACT_ID}s. In order to tell whether 6167 * a contact 6168 * is from the corp profile, use 6169 * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. 6170 * </li> 6171 * <li> 6172 * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. 6173 * </li> 6174 * </ul> 6175 * <p> 6176 * A contact lookup URL built by 6177 * {@link ContactsContract.Contacts#getLookupUri(long, String)} 6178 * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to 6179 * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the 6180 * corp profile. 6181 * </p> 6182 * 6183 * <pre> 6184 * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI, 6185 * Uri.encode(email)); 6186 * </pre> 6187 */ 6188 public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI = 6189 Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise"); 6190 6191 /** 6192 * <p> 6193 * The content:// style URL for email lookup using a filter. The filter returns 6194 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 6195 * to display names as well as email addresses. The filter argument should be passed 6196 * as an additional path segment after this URI. 6197 * </p> 6198 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" 6199 * as well as "Bob Parr (incredible@android.com)". 6200 * <pre> 6201 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); 6202 * Cursor c = getContentResolver().query(uri, 6203 * new String[]{Email.DISPLAY_NAME, Email.DATA}, 6204 * null, null, null); 6205 * </pre> 6206 * </p> 6207 */ 6208 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 6209 "filter"); 6210 6211 /** 6212 * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same 6213 * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in 6214 * parameters, otherwise it will throw UnsupportedOperationException. 6215 */ 6216 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( 6217 CONTENT_URI, "filter_enterprise"); 6218 6219 /** 6220 * The email address. 6221 * <P>Type: TEXT</P> 6222 */ 6223 public static final String ADDRESS = DATA1; 6224 6225 public static final int TYPE_HOME = 1; 6226 public static final int TYPE_WORK = 2; 6227 public static final int TYPE_OTHER = 3; 6228 public static final int TYPE_MOBILE = 4; 6229 6230 /** 6231 * The display name for the email address 6232 * <P>Type: TEXT</P> 6233 */ 6234 public static final String DISPLAY_NAME = DATA4; 6235 6236 /** 6237 * Return the string resource that best describes the given 6238 * {@link #TYPE}. Will always return a valid resource. 6239 */ 6240 public static final int getTypeLabelResource(int type) { 6241 switch (type) { 6242 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; 6243 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; 6244 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; 6245 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; 6246 default: return com.android.internal.R.string.emailTypeCustom; 6247 } 6248 } 6249 6250 /** 6251 * Return a {@link CharSequence} that best describes the given type, 6252 * possibly substituting the given {@link #LABEL} value 6253 * for {@link #TYPE_CUSTOM}. 6254 */ 6255 public static final CharSequence getTypeLabel(Resources res, int type, 6256 CharSequence label) { 6257 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6258 return label; 6259 } else { 6260 final int labelRes = getTypeLabelResource(type); 6261 return res.getText(labelRes); 6262 } 6263 } 6264 } 6265 6266 /** 6267 * <p> 6268 * A data kind representing a postal addresses. 6269 * </p> 6270 * <p> 6271 * You can use all columns defined for {@link ContactsContract.Data} as 6272 * well as the following aliases. 6273 * </p> 6274 * <h2>Column aliases</h2> 6275 * <table class="jd-sumtable"> 6276 * <tr> 6277 * <th>Type</th> 6278 * <th>Alias</th><th colspan='2'>Data column</th> 6279 * </tr> 6280 * <tr> 6281 * <td>String</td> 6282 * <td>{@link #FORMATTED_ADDRESS}</td> 6283 * <td>{@link #DATA1}</td> 6284 * <td></td> 6285 * </tr> 6286 * <tr> 6287 * <td>int</td> 6288 * <td>{@link #TYPE}</td> 6289 * <td>{@link #DATA2}</td> 6290 * <td>Allowed values are: 6291 * <p> 6292 * <ul> 6293 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6294 * <li>{@link #TYPE_HOME}</li> 6295 * <li>{@link #TYPE_WORK}</li> 6296 * <li>{@link #TYPE_OTHER}</li> 6297 * </ul> 6298 * </p> 6299 * </td> 6300 * </tr> 6301 * <tr> 6302 * <td>String</td> 6303 * <td>{@link #LABEL}</td> 6304 * <td>{@link #DATA3}</td> 6305 * <td></td> 6306 * </tr> 6307 * <tr> 6308 * <td>String</td> 6309 * <td>{@link #STREET}</td> 6310 * <td>{@link #DATA4}</td> 6311 * <td></td> 6312 * </tr> 6313 * <tr> 6314 * <td>String</td> 6315 * <td>{@link #POBOX}</td> 6316 * <td>{@link #DATA5}</td> 6317 * <td>Post Office Box number</td> 6318 * </tr> 6319 * <tr> 6320 * <td>String</td> 6321 * <td>{@link #NEIGHBORHOOD}</td> 6322 * <td>{@link #DATA6}</td> 6323 * <td></td> 6324 * </tr> 6325 * <tr> 6326 * <td>String</td> 6327 * <td>{@link #CITY}</td> 6328 * <td>{@link #DATA7}</td> 6329 * <td></td> 6330 * </tr> 6331 * <tr> 6332 * <td>String</td> 6333 * <td>{@link #REGION}</td> 6334 * <td>{@link #DATA8}</td> 6335 * <td></td> 6336 * </tr> 6337 * <tr> 6338 * <td>String</td> 6339 * <td>{@link #POSTCODE}</td> 6340 * <td>{@link #DATA9}</td> 6341 * <td></td> 6342 * </tr> 6343 * <tr> 6344 * <td>String</td> 6345 * <td>{@link #COUNTRY}</td> 6346 * <td>{@link #DATA10}</td> 6347 * <td></td> 6348 * </tr> 6349 * </table> 6350 */ 6351 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns, 6352 ContactCounts { 6353 /** 6354 * This utility class cannot be instantiated 6355 */ 6356 private StructuredPostal() { 6357 } 6358 6359 /** MIME type used when storing this in data table. */ 6360 public static final String CONTENT_ITEM_TYPE = 6361 "vnd.android.cursor.item/postal-address_v2"; 6362 6363 /** 6364 * The MIME type of {@link #CONTENT_URI} providing a directory of 6365 * postal addresses. 6366 */ 6367 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2"; 6368 6369 /** 6370 * The content:// style URI for all data records of the 6371 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. 6372 */ 6373 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 6374 "postals"); 6375 6376 public static final int TYPE_HOME = 1; 6377 public static final int TYPE_WORK = 2; 6378 public static final int TYPE_OTHER = 3; 6379 6380 /** 6381 * The full, unstructured postal address. <i>This field must be 6382 * consistent with any structured data.</i> 6383 * <p> 6384 * Type: TEXT 6385 */ 6386 public static final String FORMATTED_ADDRESS = DATA; 6387 6388 /** 6389 * Can be street, avenue, road, etc. This element also includes the 6390 * house number and room/apartment/flat/floor number. 6391 * <p> 6392 * Type: TEXT 6393 */ 6394 public static final String STREET = DATA4; 6395 6396 /** 6397 * Covers actual P.O. boxes, drawers, locked bags, etc. This is 6398 * usually but not always mutually exclusive with street. 6399 * <p> 6400 * Type: TEXT 6401 */ 6402 public static final String POBOX = DATA5; 6403 6404 /** 6405 * This is used to disambiguate a street address when a city 6406 * contains more than one street with the same name, or to specify a 6407 * small place whose mail is routed through a larger postal town. In 6408 * China it could be a county or a minor city. 6409 * <p> 6410 * Type: TEXT 6411 */ 6412 public static final String NEIGHBORHOOD = DATA6; 6413 6414 /** 6415 * Can be city, village, town, borough, etc. This is the postal town 6416 * and not necessarily the place of residence or place of business. 6417 * <p> 6418 * Type: TEXT 6419 */ 6420 public static final String CITY = DATA7; 6421 6422 /** 6423 * A state, province, county (in Ireland), Land (in Germany), 6424 * departement (in France), etc. 6425 * <p> 6426 * Type: TEXT 6427 */ 6428 public static final String REGION = DATA8; 6429 6430 /** 6431 * Postal code. Usually country-wide, but sometimes specific to the 6432 * city (e.g. "2" in "Dublin 2, Ireland" addresses). 6433 * <p> 6434 * Type: TEXT 6435 */ 6436 public static final String POSTCODE = DATA9; 6437 6438 /** 6439 * The name or code of the country. 6440 * <p> 6441 * Type: TEXT 6442 */ 6443 public static final String COUNTRY = DATA10; 6444 6445 /** 6446 * Return the string resource that best describes the given 6447 * {@link #TYPE}. Will always return a valid resource. 6448 */ 6449 public static final int getTypeLabelResource(int type) { 6450 switch (type) { 6451 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; 6452 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; 6453 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; 6454 default: return com.android.internal.R.string.postalTypeCustom; 6455 } 6456 } 6457 6458 /** 6459 * Return a {@link CharSequence} that best describes the given type, 6460 * possibly substituting the given {@link #LABEL} value 6461 * for {@link #TYPE_CUSTOM}. 6462 */ 6463 public static final CharSequence getTypeLabel(Resources res, int type, 6464 CharSequence label) { 6465 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6466 return label; 6467 } else { 6468 final int labelRes = getTypeLabelResource(type); 6469 return res.getText(labelRes); 6470 } 6471 } 6472 } 6473 6474 /** 6475 * <p> 6476 * A data kind representing an IM address 6477 * </p> 6478 * <p> 6479 * You can use all columns defined for {@link ContactsContract.Data} as 6480 * well as the following aliases. 6481 * </p> 6482 * <h2>Column aliases</h2> 6483 * <table class="jd-sumtable"> 6484 * <tr> 6485 * <th>Type</th> 6486 * <th>Alias</th><th colspan='2'>Data column</th> 6487 * </tr> 6488 * <tr> 6489 * <td>String</td> 6490 * <td>{@link #DATA}</td> 6491 * <td>{@link #DATA1}</td> 6492 * <td></td> 6493 * </tr> 6494 * <tr> 6495 * <td>int</td> 6496 * <td>{@link #TYPE}</td> 6497 * <td>{@link #DATA2}</td> 6498 * <td>Allowed values are: 6499 * <p> 6500 * <ul> 6501 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6502 * <li>{@link #TYPE_HOME}</li> 6503 * <li>{@link #TYPE_WORK}</li> 6504 * <li>{@link #TYPE_OTHER}</li> 6505 * </ul> 6506 * </p> 6507 * </td> 6508 * </tr> 6509 * <tr> 6510 * <td>String</td> 6511 * <td>{@link #LABEL}</td> 6512 * <td>{@link #DATA3}</td> 6513 * <td></td> 6514 * </tr> 6515 * <tr> 6516 * <td>String</td> 6517 * <td>{@link #PROTOCOL}</td> 6518 * <td>{@link #DATA5}</td> 6519 * <td> 6520 * <p> 6521 * Allowed values: 6522 * <ul> 6523 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name 6524 * as {@link #CUSTOM_PROTOCOL}.</li> 6525 * <li>{@link #PROTOCOL_AIM}</li> 6526 * <li>{@link #PROTOCOL_MSN}</li> 6527 * <li>{@link #PROTOCOL_YAHOO}</li> 6528 * <li>{@link #PROTOCOL_SKYPE}</li> 6529 * <li>{@link #PROTOCOL_QQ}</li> 6530 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> 6531 * <li>{@link #PROTOCOL_ICQ}</li> 6532 * <li>{@link #PROTOCOL_JABBER}</li> 6533 * <li>{@link #PROTOCOL_NETMEETING}</li> 6534 * </ul> 6535 * </p> 6536 * </td> 6537 * </tr> 6538 * <tr> 6539 * <td>String</td> 6540 * <td>{@link #CUSTOM_PROTOCOL}</td> 6541 * <td>{@link #DATA6}</td> 6542 * <td></td> 6543 * </tr> 6544 * </table> 6545 */ 6546 public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts { 6547 /** 6548 * This utility class cannot be instantiated 6549 */ 6550 private Im() {} 6551 6552 /** MIME type used when storing this in data table. */ 6553 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; 6554 6555 public static final int TYPE_HOME = 1; 6556 public static final int TYPE_WORK = 2; 6557 public static final int TYPE_OTHER = 3; 6558 6559 /** 6560 * This column should be populated with one of the defined 6561 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this 6562 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} 6563 * should contain the name of the custom protocol. 6564 */ 6565 public static final String PROTOCOL = DATA5; 6566 6567 public static final String CUSTOM_PROTOCOL = DATA6; 6568 6569 /* 6570 * The predefined IM protocol types. 6571 */ 6572 public static final int PROTOCOL_CUSTOM = -1; 6573 public static final int PROTOCOL_AIM = 0; 6574 public static final int PROTOCOL_MSN = 1; 6575 public static final int PROTOCOL_YAHOO = 2; 6576 public static final int PROTOCOL_SKYPE = 3; 6577 public static final int PROTOCOL_QQ = 4; 6578 public static final int PROTOCOL_GOOGLE_TALK = 5; 6579 public static final int PROTOCOL_ICQ = 6; 6580 public static final int PROTOCOL_JABBER = 7; 6581 public static final int PROTOCOL_NETMEETING = 8; 6582 6583 /** 6584 * Return the string resource that best describes the given 6585 * {@link #TYPE}. Will always return a valid resource. 6586 */ 6587 public static final int getTypeLabelResource(int type) { 6588 switch (type) { 6589 case TYPE_HOME: return com.android.internal.R.string.imTypeHome; 6590 case TYPE_WORK: return com.android.internal.R.string.imTypeWork; 6591 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; 6592 default: return com.android.internal.R.string.imTypeCustom; 6593 } 6594 } 6595 6596 /** 6597 * Return a {@link CharSequence} that best describes the given type, 6598 * possibly substituting the given {@link #LABEL} value 6599 * for {@link #TYPE_CUSTOM}. 6600 */ 6601 public static final CharSequence getTypeLabel(Resources res, int type, 6602 CharSequence label) { 6603 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6604 return label; 6605 } else { 6606 final int labelRes = getTypeLabelResource(type); 6607 return res.getText(labelRes); 6608 } 6609 } 6610 6611 /** 6612 * Return the string resource that best describes the given 6613 * {@link #PROTOCOL}. Will always return a valid resource. 6614 */ 6615 public static final int getProtocolLabelResource(int type) { 6616 switch (type) { 6617 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; 6618 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; 6619 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; 6620 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; 6621 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; 6622 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; 6623 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; 6624 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; 6625 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; 6626 default: return com.android.internal.R.string.imProtocolCustom; 6627 } 6628 } 6629 6630 /** 6631 * Return a {@link CharSequence} that best describes the given 6632 * protocol, possibly substituting the given 6633 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. 6634 */ 6635 public static final CharSequence getProtocolLabel(Resources res, int type, 6636 CharSequence label) { 6637 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { 6638 return label; 6639 } else { 6640 final int labelRes = getProtocolLabelResource(type); 6641 return res.getText(labelRes); 6642 } 6643 } 6644 } 6645 6646 /** 6647 * <p> 6648 * A data kind representing an organization. 6649 * </p> 6650 * <p> 6651 * You can use all columns defined for {@link ContactsContract.Data} as 6652 * well as the following aliases. 6653 * </p> 6654 * <h2>Column aliases</h2> 6655 * <table class="jd-sumtable"> 6656 * <tr> 6657 * <th>Type</th> 6658 * <th>Alias</th><th colspan='2'>Data column</th> 6659 * </tr> 6660 * <tr> 6661 * <td>String</td> 6662 * <td>{@link #COMPANY}</td> 6663 * <td>{@link #DATA1}</td> 6664 * <td></td> 6665 * </tr> 6666 * <tr> 6667 * <td>int</td> 6668 * <td>{@link #TYPE}</td> 6669 * <td>{@link #DATA2}</td> 6670 * <td>Allowed values are: 6671 * <p> 6672 * <ul> 6673 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6674 * <li>{@link #TYPE_WORK}</li> 6675 * <li>{@link #TYPE_OTHER}</li> 6676 * </ul> 6677 * </p> 6678 * </td> 6679 * </tr> 6680 * <tr> 6681 * <td>String</td> 6682 * <td>{@link #LABEL}</td> 6683 * <td>{@link #DATA3}</td> 6684 * <td></td> 6685 * </tr> 6686 * <tr> 6687 * <td>String</td> 6688 * <td>{@link #TITLE}</td> 6689 * <td>{@link #DATA4}</td> 6690 * <td></td> 6691 * </tr> 6692 * <tr> 6693 * <td>String</td> 6694 * <td>{@link #DEPARTMENT}</td> 6695 * <td>{@link #DATA5}</td> 6696 * <td></td> 6697 * </tr> 6698 * <tr> 6699 * <td>String</td> 6700 * <td>{@link #JOB_DESCRIPTION}</td> 6701 * <td>{@link #DATA6}</td> 6702 * <td></td> 6703 * </tr> 6704 * <tr> 6705 * <td>String</td> 6706 * <td>{@link #SYMBOL}</td> 6707 * <td>{@link #DATA7}</td> 6708 * <td></td> 6709 * </tr> 6710 * <tr> 6711 * <td>String</td> 6712 * <td>{@link #PHONETIC_NAME}</td> 6713 * <td>{@link #DATA8}</td> 6714 * <td></td> 6715 * </tr> 6716 * <tr> 6717 * <td>String</td> 6718 * <td>{@link #OFFICE_LOCATION}</td> 6719 * <td>{@link #DATA9}</td> 6720 * <td></td> 6721 * </tr> 6722 * <tr> 6723 * <td>String</td> 6724 * <td>PHONETIC_NAME_STYLE</td> 6725 * <td>{@link #DATA10}</td> 6726 * <td></td> 6727 * </tr> 6728 * </table> 6729 */ 6730 public static final class Organization implements DataColumnsWithJoins, CommonColumns, 6731 ContactCounts { 6732 /** 6733 * This utility class cannot be instantiated 6734 */ 6735 private Organization() {} 6736 6737 /** MIME type used when storing this in data table. */ 6738 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; 6739 6740 public static final int TYPE_WORK = 1; 6741 public static final int TYPE_OTHER = 2; 6742 6743 /** 6744 * The company as the user entered it. 6745 * <P>Type: TEXT</P> 6746 */ 6747 public static final String COMPANY = DATA; 6748 6749 /** 6750 * The position title at this company as the user entered it. 6751 * <P>Type: TEXT</P> 6752 */ 6753 public static final String TITLE = DATA4; 6754 6755 /** 6756 * The department at this company as the user entered it. 6757 * <P>Type: TEXT</P> 6758 */ 6759 public static final String DEPARTMENT = DATA5; 6760 6761 /** 6762 * The job description at this company as the user entered it. 6763 * <P>Type: TEXT</P> 6764 */ 6765 public static final String JOB_DESCRIPTION = DATA6; 6766 6767 /** 6768 * The symbol of this company as the user entered it. 6769 * <P>Type: TEXT</P> 6770 */ 6771 public static final String SYMBOL = DATA7; 6772 6773 /** 6774 * The phonetic name of this company as the user entered it. 6775 * <P>Type: TEXT</P> 6776 */ 6777 public static final String PHONETIC_NAME = DATA8; 6778 6779 /** 6780 * The office location of this organization. 6781 * <P>Type: TEXT</P> 6782 */ 6783 public static final String OFFICE_LOCATION = DATA9; 6784 6785 /** 6786 * The alphabet used for capturing the phonetic name. 6787 * See {@link ContactsContract.PhoneticNameStyle}. 6788 */ 6789 public static final String PHONETIC_NAME_STYLE = DATA10; 6790 6791 /** 6792 * Return the string resource that best describes the given 6793 * {@link #TYPE}. Will always return a valid resource. 6794 */ 6795 public static final int getTypeLabelResource(int type) { 6796 switch (type) { 6797 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; 6798 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; 6799 default: return com.android.internal.R.string.orgTypeCustom; 6800 } 6801 } 6802 6803 /** 6804 * Return a {@link CharSequence} that best describes the given type, 6805 * possibly substituting the given {@link #LABEL} value 6806 * for {@link #TYPE_CUSTOM}. 6807 */ 6808 public static final CharSequence getTypeLabel(Resources res, int type, 6809 CharSequence label) { 6810 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6811 return label; 6812 } else { 6813 final int labelRes = getTypeLabelResource(type); 6814 return res.getText(labelRes); 6815 } 6816 } 6817 } 6818 6819 /** 6820 * <p> 6821 * A data kind representing a relation. 6822 * </p> 6823 * <p> 6824 * You can use all columns defined for {@link ContactsContract.Data} as 6825 * well as the following aliases. 6826 * </p> 6827 * <h2>Column aliases</h2> 6828 * <table class="jd-sumtable"> 6829 * <tr> 6830 * <th>Type</th> 6831 * <th>Alias</th><th colspan='2'>Data column</th> 6832 * </tr> 6833 * <tr> 6834 * <td>String</td> 6835 * <td>{@link #NAME}</td> 6836 * <td>{@link #DATA1}</td> 6837 * <td></td> 6838 * </tr> 6839 * <tr> 6840 * <td>int</td> 6841 * <td>{@link #TYPE}</td> 6842 * <td>{@link #DATA2}</td> 6843 * <td>Allowed values are: 6844 * <p> 6845 * <ul> 6846 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6847 * <li>{@link #TYPE_ASSISTANT}</li> 6848 * <li>{@link #TYPE_BROTHER}</li> 6849 * <li>{@link #TYPE_CHILD}</li> 6850 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> 6851 * <li>{@link #TYPE_FATHER}</li> 6852 * <li>{@link #TYPE_FRIEND}</li> 6853 * <li>{@link #TYPE_MANAGER}</li> 6854 * <li>{@link #TYPE_MOTHER}</li> 6855 * <li>{@link #TYPE_PARENT}</li> 6856 * <li>{@link #TYPE_PARTNER}</li> 6857 * <li>{@link #TYPE_REFERRED_BY}</li> 6858 * <li>{@link #TYPE_RELATIVE}</li> 6859 * <li>{@link #TYPE_SISTER}</li> 6860 * <li>{@link #TYPE_SPOUSE}</li> 6861 * </ul> 6862 * </p> 6863 * </td> 6864 * </tr> 6865 * <tr> 6866 * <td>String</td> 6867 * <td>{@link #LABEL}</td> 6868 * <td>{@link #DATA3}</td> 6869 * <td></td> 6870 * </tr> 6871 * </table> 6872 */ 6873 public static final class Relation implements DataColumnsWithJoins, CommonColumns, 6874 ContactCounts { 6875 /** 6876 * This utility class cannot be instantiated 6877 */ 6878 private Relation() {} 6879 6880 /** MIME type used when storing this in data table. */ 6881 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; 6882 6883 public static final int TYPE_ASSISTANT = 1; 6884 public static final int TYPE_BROTHER = 2; 6885 public static final int TYPE_CHILD = 3; 6886 public static final int TYPE_DOMESTIC_PARTNER = 4; 6887 public static final int TYPE_FATHER = 5; 6888 public static final int TYPE_FRIEND = 6; 6889 public static final int TYPE_MANAGER = 7; 6890 public static final int TYPE_MOTHER = 8; 6891 public static final int TYPE_PARENT = 9; 6892 public static final int TYPE_PARTNER = 10; 6893 public static final int TYPE_REFERRED_BY = 11; 6894 public static final int TYPE_RELATIVE = 12; 6895 public static final int TYPE_SISTER = 13; 6896 public static final int TYPE_SPOUSE = 14; 6897 6898 /** 6899 * The name of the relative as the user entered it. 6900 * <P>Type: TEXT</P> 6901 */ 6902 public static final String NAME = DATA; 6903 6904 /** 6905 * Return the string resource that best describes the given 6906 * {@link #TYPE}. Will always return a valid resource. 6907 */ 6908 public static final int getTypeLabelResource(int type) { 6909 switch (type) { 6910 case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; 6911 case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; 6912 case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; 6913 case TYPE_DOMESTIC_PARTNER: 6914 return com.android.internal.R.string.relationTypeDomesticPartner; 6915 case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; 6916 case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; 6917 case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; 6918 case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; 6919 case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; 6920 case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; 6921 case TYPE_REFERRED_BY: 6922 return com.android.internal.R.string.relationTypeReferredBy; 6923 case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; 6924 case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; 6925 case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; 6926 default: return com.android.internal.R.string.orgTypeCustom; 6927 } 6928 } 6929 6930 /** 6931 * Return a {@link CharSequence} that best describes the given type, 6932 * possibly substituting the given {@link #LABEL} value 6933 * for {@link #TYPE_CUSTOM}. 6934 */ 6935 public static final CharSequence getTypeLabel(Resources res, int type, 6936 CharSequence label) { 6937 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6938 return label; 6939 } else { 6940 final int labelRes = getTypeLabelResource(type); 6941 return res.getText(labelRes); 6942 } 6943 } 6944 } 6945 6946 /** 6947 * <p> 6948 * A data kind representing an event. 6949 * </p> 6950 * <p> 6951 * You can use all columns defined for {@link ContactsContract.Data} as 6952 * well as the following aliases. 6953 * </p> 6954 * <h2>Column aliases</h2> 6955 * <table class="jd-sumtable"> 6956 * <tr> 6957 * <th>Type</th> 6958 * <th>Alias</th><th colspan='2'>Data column</th> 6959 * </tr> 6960 * <tr> 6961 * <td>String</td> 6962 * <td>{@link #START_DATE}</td> 6963 * <td>{@link #DATA1}</td> 6964 * <td></td> 6965 * </tr> 6966 * <tr> 6967 * <td>int</td> 6968 * <td>{@link #TYPE}</td> 6969 * <td>{@link #DATA2}</td> 6970 * <td>Allowed values are: 6971 * <p> 6972 * <ul> 6973 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6974 * <li>{@link #TYPE_ANNIVERSARY}</li> 6975 * <li>{@link #TYPE_OTHER}</li> 6976 * <li>{@link #TYPE_BIRTHDAY}</li> 6977 * </ul> 6978 * </p> 6979 * </td> 6980 * </tr> 6981 * <tr> 6982 * <td>String</td> 6983 * <td>{@link #LABEL}</td> 6984 * <td>{@link #DATA3}</td> 6985 * <td></td> 6986 * </tr> 6987 * </table> 6988 */ 6989 public static final class Event implements DataColumnsWithJoins, CommonColumns, 6990 ContactCounts { 6991 /** 6992 * This utility class cannot be instantiated 6993 */ 6994 private Event() {} 6995 6996 /** MIME type used when storing this in data table. */ 6997 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event"; 6998 6999 public static final int TYPE_ANNIVERSARY = 1; 7000 public static final int TYPE_OTHER = 2; 7001 public static final int TYPE_BIRTHDAY = 3; 7002 7003 /** 7004 * The event start date as the user entered it. 7005 * <P>Type: TEXT</P> 7006 */ 7007 public static final String START_DATE = DATA; 7008 7009 /** 7010 * Return the string resource that best describes the given 7011 * {@link #TYPE}. Will always return a valid resource. 7012 */ 7013 public static int getTypeResource(Integer type) { 7014 if (type == null) { 7015 return com.android.internal.R.string.eventTypeOther; 7016 } 7017 switch (type) { 7018 case TYPE_ANNIVERSARY: 7019 return com.android.internal.R.string.eventTypeAnniversary; 7020 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; 7021 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; 7022 default: return com.android.internal.R.string.eventTypeCustom; 7023 } 7024 } 7025 7026 /** 7027 * Return a {@link CharSequence} that best describes the given type, 7028 * possibly substituting the given {@link #LABEL} value 7029 * for {@link #TYPE_CUSTOM}. 7030 */ 7031 public static final CharSequence getTypeLabel(Resources res, int type, 7032 CharSequence label) { 7033 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 7034 return label; 7035 } else { 7036 final int labelRes = getTypeResource(type); 7037 return res.getText(labelRes); 7038 } 7039 } 7040 } 7041 7042 /** 7043 * <p> 7044 * A data kind representing a photo for the contact. 7045 * </p> 7046 * <p> 7047 * Some sync adapters will choose to download photos in a separate 7048 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} 7049 * through {@link ContactsContract.Data#SYNC4} to store temporary 7050 * data, e.g. the image URL or ID, state of download, server-side version 7051 * of the image. It is allowed for the {@link #PHOTO} to be null. 7052 * </p> 7053 * <p> 7054 * You can use all columns defined for {@link ContactsContract.Data} as 7055 * well as the following aliases. 7056 * </p> 7057 * <h2>Column aliases</h2> 7058 * <table class="jd-sumtable"> 7059 * <tr> 7060 * <th>Type</th> 7061 * <th>Alias</th><th colspan='2'>Data column</th> 7062 * </tr> 7063 * <tr> 7064 * <td>NUMBER</td> 7065 * <td>{@link #PHOTO_FILE_ID}</td> 7066 * <td>{@link #DATA14}</td> 7067 * <td>ID of the hi-res photo file.</td> 7068 * </tr> 7069 * <tr> 7070 * <td>BLOB</td> 7071 * <td>{@link #PHOTO}</td> 7072 * <td>{@link #DATA15}</td> 7073 * <td>By convention, binary data is stored in DATA15. The thumbnail of the 7074 * photo is stored in this column.</td> 7075 * </tr> 7076 * </table> 7077 */ 7078 public static final class Photo implements DataColumnsWithJoins, ContactCounts { 7079 /** 7080 * This utility class cannot be instantiated 7081 */ 7082 private Photo() {} 7083 7084 /** MIME type used when storing this in data table. */ 7085 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; 7086 7087 /** 7088 * Photo file ID for the display photo of the raw contact. 7089 * See {@link ContactsContract.DisplayPhoto}. 7090 * <p> 7091 * Type: NUMBER 7092 */ 7093 public static final String PHOTO_FILE_ID = DATA14; 7094 7095 /** 7096 * Thumbnail photo of the raw contact. This is the raw bytes of an image 7097 * that could be inflated using {@link android.graphics.BitmapFactory}. 7098 * <p> 7099 * Type: BLOB 7100 */ 7101 public static final String PHOTO = DATA15; 7102 } 7103 7104 /** 7105 * <p> 7106 * Notes about the contact. 7107 * </p> 7108 * <p> 7109 * You can use all columns defined for {@link ContactsContract.Data} as 7110 * well as the following aliases. 7111 * </p> 7112 * <h2>Column aliases</h2> 7113 * <table class="jd-sumtable"> 7114 * <tr> 7115 * <th>Type</th> 7116 * <th>Alias</th><th colspan='2'>Data column</th> 7117 * </tr> 7118 * <tr> 7119 * <td>String</td> 7120 * <td>{@link #NOTE}</td> 7121 * <td>{@link #DATA1}</td> 7122 * <td></td> 7123 * </tr> 7124 * </table> 7125 */ 7126 public static final class Note implements DataColumnsWithJoins, ContactCounts { 7127 /** 7128 * This utility class cannot be instantiated 7129 */ 7130 private Note() {} 7131 7132 /** MIME type used when storing this in data table. */ 7133 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; 7134 7135 /** 7136 * The note text. 7137 * <P>Type: TEXT</P> 7138 */ 7139 public static final String NOTE = DATA1; 7140 } 7141 7142 /** 7143 * <p> 7144 * Group Membership. 7145 * </p> 7146 * <p> 7147 * You can use all columns defined for {@link ContactsContract.Data} as 7148 * well as the following aliases. 7149 * </p> 7150 * <h2>Column aliases</h2> 7151 * <table class="jd-sumtable"> 7152 * <tr> 7153 * <th>Type</th> 7154 * <th>Alias</th><th colspan='2'>Data column</th> 7155 * </tr> 7156 * <tr> 7157 * <td>long</td> 7158 * <td>{@link #GROUP_ROW_ID}</td> 7159 * <td>{@link #DATA1}</td> 7160 * <td></td> 7161 * </tr> 7162 * <tr> 7163 * <td>String</td> 7164 * <td>{@link #GROUP_SOURCE_ID}</td> 7165 * <td>none</td> 7166 * <td> 7167 * <p> 7168 * The sourceid of the group that this group membership refers to. 7169 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when 7170 * inserting a row. 7171 * </p> 7172 * <p> 7173 * If this field is specified, the provider will first try to 7174 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group 7175 * is found, it will use the corresponding row id. If the group is not 7176 * found, it will create one. 7177 * </td> 7178 * </tr> 7179 * </table> 7180 */ 7181 public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts { 7182 /** 7183 * This utility class cannot be instantiated 7184 */ 7185 private GroupMembership() {} 7186 7187 /** MIME type used when storing this in data table. */ 7188 public static final String CONTENT_ITEM_TYPE = 7189 "vnd.android.cursor.item/group_membership"; 7190 7191 /** 7192 * The row id of the group that this group membership refers to. Exactly one of 7193 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. 7194 * <P>Type: INTEGER</P> 7195 */ 7196 public static final String GROUP_ROW_ID = DATA1; 7197 7198 /** 7199 * The sourceid of the group that this group membership refers to. Exactly one of 7200 * this or {@link #GROUP_ROW_ID} must be set when inserting a row. 7201 * <P>Type: TEXT</P> 7202 */ 7203 public static final String GROUP_SOURCE_ID = "group_sourceid"; 7204 } 7205 7206 /** 7207 * <p> 7208 * A data kind representing a website related to the contact. 7209 * </p> 7210 * <p> 7211 * You can use all columns defined for {@link ContactsContract.Data} as 7212 * well as the following aliases. 7213 * </p> 7214 * <h2>Column aliases</h2> 7215 * <table class="jd-sumtable"> 7216 * <tr> 7217 * <th>Type</th> 7218 * <th>Alias</th><th colspan='2'>Data column</th> 7219 * </tr> 7220 * <tr> 7221 * <td>String</td> 7222 * <td>{@link #URL}</td> 7223 * <td>{@link #DATA1}</td> 7224 * <td></td> 7225 * </tr> 7226 * <tr> 7227 * <td>int</td> 7228 * <td>{@link #TYPE}</td> 7229 * <td>{@link #DATA2}</td> 7230 * <td>Allowed values are: 7231 * <p> 7232 * <ul> 7233 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 7234 * <li>{@link #TYPE_HOMEPAGE}</li> 7235 * <li>{@link #TYPE_BLOG}</li> 7236 * <li>{@link #TYPE_PROFILE}</li> 7237 * <li>{@link #TYPE_HOME}</li> 7238 * <li>{@link #TYPE_WORK}</li> 7239 * <li>{@link #TYPE_FTP}</li> 7240 * <li>{@link #TYPE_OTHER}</li> 7241 * </ul> 7242 * </p> 7243 * </td> 7244 * </tr> 7245 * <tr> 7246 * <td>String</td> 7247 * <td>{@link #LABEL}</td> 7248 * <td>{@link #DATA3}</td> 7249 * <td></td> 7250 * </tr> 7251 * </table> 7252 */ 7253 public static final class Website implements DataColumnsWithJoins, CommonColumns, 7254 ContactCounts { 7255 /** 7256 * This utility class cannot be instantiated 7257 */ 7258 private Website() {} 7259 7260 /** MIME type used when storing this in data table. */ 7261 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; 7262 7263 public static final int TYPE_HOMEPAGE = 1; 7264 public static final int TYPE_BLOG = 2; 7265 public static final int TYPE_PROFILE = 3; 7266 public static final int TYPE_HOME = 4; 7267 public static final int TYPE_WORK = 5; 7268 public static final int TYPE_FTP = 6; 7269 public static final int TYPE_OTHER = 7; 7270 7271 /** 7272 * The website URL string. 7273 * <P>Type: TEXT</P> 7274 */ 7275 public static final String URL = DATA; 7276 } 7277 7278 /** 7279 * <p> 7280 * A data kind representing a SIP address for the contact. 7281 * </p> 7282 * <p> 7283 * You can use all columns defined for {@link ContactsContract.Data} as 7284 * well as the following aliases. 7285 * </p> 7286 * <h2>Column aliases</h2> 7287 * <table class="jd-sumtable"> 7288 * <tr> 7289 * <th>Type</th> 7290 * <th>Alias</th><th colspan='2'>Data column</th> 7291 * </tr> 7292 * <tr> 7293 * <td>String</td> 7294 * <td>{@link #SIP_ADDRESS}</td> 7295 * <td>{@link #DATA1}</td> 7296 * <td></td> 7297 * </tr> 7298 * <tr> 7299 * <td>int</td> 7300 * <td>{@link #TYPE}</td> 7301 * <td>{@link #DATA2}</td> 7302 * <td>Allowed values are: 7303 * <p> 7304 * <ul> 7305 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 7306 * <li>{@link #TYPE_HOME}</li> 7307 * <li>{@link #TYPE_WORK}</li> 7308 * <li>{@link #TYPE_OTHER}</li> 7309 * </ul> 7310 * </p> 7311 * </td> 7312 * </tr> 7313 * <tr> 7314 * <td>String</td> 7315 * <td>{@link #LABEL}</td> 7316 * <td>{@link #DATA3}</td> 7317 * <td></td> 7318 * </tr> 7319 * </table> 7320 */ 7321 public static final class SipAddress implements DataColumnsWithJoins, CommonColumns, 7322 ContactCounts { 7323 /** 7324 * This utility class cannot be instantiated 7325 */ 7326 private SipAddress() {} 7327 7328 /** MIME type used when storing this in data table. */ 7329 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; 7330 7331 public static final int TYPE_HOME = 1; 7332 public static final int TYPE_WORK = 2; 7333 public static final int TYPE_OTHER = 3; 7334 7335 /** 7336 * The SIP address. 7337 * <P>Type: TEXT</P> 7338 */ 7339 public static final String SIP_ADDRESS = DATA1; 7340 // ...and TYPE and LABEL come from the CommonColumns interface. 7341 7342 /** 7343 * Return the string resource that best describes the given 7344 * {@link #TYPE}. Will always return a valid resource. 7345 */ 7346 public static final int getTypeLabelResource(int type) { 7347 switch (type) { 7348 case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; 7349 case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; 7350 case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; 7351 default: return com.android.internal.R.string.sipAddressTypeCustom; 7352 } 7353 } 7354 7355 /** 7356 * Return a {@link CharSequence} that best describes the given type, 7357 * possibly substituting the given {@link #LABEL} value 7358 * for {@link #TYPE_CUSTOM}. 7359 */ 7360 public static final CharSequence getTypeLabel(Resources res, int type, 7361 CharSequence label) { 7362 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 7363 return label; 7364 } else { 7365 final int labelRes = getTypeLabelResource(type); 7366 return res.getText(labelRes); 7367 } 7368 } 7369 } 7370 7371 /** 7372 * A data kind representing an Identity related to the contact. 7373 * <p> 7374 * This can be used as a signal by the aggregator to combine raw contacts into 7375 * contacts, e.g. if two contacts have Identity rows with 7376 * the same NAMESPACE and IDENTITY values the aggregator can know that they refer 7377 * to the same person. 7378 * </p> 7379 */ 7380 public static final class Identity implements DataColumnsWithJoins, ContactCounts { 7381 /** 7382 * This utility class cannot be instantiated 7383 */ 7384 private Identity() {} 7385 7386 /** MIME type used when storing this in data table. */ 7387 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; 7388 7389 /** 7390 * The identity string. 7391 * <P>Type: TEXT</P> 7392 */ 7393 public static final String IDENTITY = DataColumns.DATA1; 7394 7395 /** 7396 * The namespace of the identity string, e.g. "com.google" 7397 * <P>Type: TEXT</P> 7398 */ 7399 public static final String NAMESPACE = DataColumns.DATA2; 7400 } 7401 7402 /** 7403 * <p> 7404 * Convenient functionalities for "callable" data. Note that, this is NOT a separate data 7405 * kind. 7406 * </p> 7407 * <p> 7408 * This URI allows the ContactsProvider to return a unified result for "callable" data 7409 * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the 7410 * current examples for "callable", but may be expanded to the other types. 7411 * </p> 7412 * <p> 7413 * Each returned row may have a different MIMETYPE and thus different interpretation for 7414 * each column. For example the meaning for {@link Phone}'s type is different than 7415 * {@link SipAddress}'s. 7416 * </p> 7417 */ 7418 public static final class Callable implements DataColumnsWithJoins, CommonColumns, 7419 ContactCounts { 7420 /** 7421 * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only 7422 * phone numbers. 7423 */ 7424 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 7425 "callables"); 7426 /** 7427 * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable 7428 * data. 7429 */ 7430 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 7431 "filter"); 7432 7433 /** 7434 * Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter 7435 * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in 7436 * parameters, otherwise it will throw UnsupportedOperationException. 7437 */ 7438 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( 7439 CONTENT_URI, "filter_enterprise"); 7440 } 7441 7442 /** 7443 * A special class of data items, used to refer to types of data that can be used to attempt 7444 * to start communicating with a person ({@link Phone} and {@link Email}). Note that this 7445 * is NOT a separate data kind. 7446 * 7447 * This URI allows the ContactsProvider to return a unified result for data items that users 7448 * can use to initiate communications with another contact. {@link Phone} and {@link Email} 7449 * are the current data types in this category. 7450 */ 7451 public static final class Contactables implements DataColumnsWithJoins, CommonColumns, 7452 ContactCounts { 7453 /** 7454 * The content:// style URI for these data items, which requests a directory of data 7455 * rows matching the selection criteria. 7456 */ 7457 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 7458 "contactables"); 7459 7460 /** 7461 * The content:// style URI for these data items, which allows for a query parameter to 7462 * be appended onto the end to filter for data items matching the query. 7463 */ 7464 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( 7465 Contactables.CONTENT_URI, "filter"); 7466 7467 /** 7468 * A boolean parameter for {@link Data#CONTENT_URI}. 7469 * This specifies whether or not the returned data items should be filtered to show 7470 * data items belonging to visible contacts only. 7471 */ 7472 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; 7473 } 7474 } 7475 7476 /** 7477 * @see Groups 7478 */ 7479 protected interface GroupsColumns { 7480 /** 7481 * The data set within the account that this group belongs to. This allows 7482 * multiple sync adapters for the same account type to distinguish between 7483 * each others' group data. 7484 * 7485 * This is empty by default, and is completely optional. It only needs to 7486 * be populated if multiple sync adapters are entering distinct group data 7487 * for the same account type and account name. 7488 * <P>Type: TEXT</P> 7489 */ 7490 public static final String DATA_SET = "data_set"; 7491 7492 /** 7493 * A concatenation of the account type and data set (delimited by a forward 7494 * slash) - if the data set is empty, this will be the same as the account 7495 * type. For applications that need to be aware of the data set, this can 7496 * be used instead of account type to distinguish sets of data. This is 7497 * never intended to be used for specifying accounts. 7498 * @hide 7499 */ 7500 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; 7501 7502 /** 7503 * The display title of this group. 7504 * <p> 7505 * Type: TEXT 7506 */ 7507 public static final String TITLE = "title"; 7508 7509 /** 7510 * The package name to use when creating {@link Resources} objects for 7511 * this group. This value is only designed for use when building user 7512 * interfaces, and should not be used to infer the owner. 7513 */ 7514 public static final String RES_PACKAGE = "res_package"; 7515 7516 /** 7517 * The display title of this group to load as a resource from 7518 * {@link #RES_PACKAGE}, which may be localized. 7519 * <P>Type: TEXT</P> 7520 */ 7521 public static final String TITLE_RES = "title_res"; 7522 7523 /** 7524 * Notes about the group. 7525 * <p> 7526 * Type: TEXT 7527 */ 7528 public static final String NOTES = "notes"; 7529 7530 /** 7531 * The ID of this group if it is a System Group, i.e. a group that has a special meaning 7532 * to the sync adapter, null otherwise. 7533 * <P>Type: TEXT</P> 7534 */ 7535 public static final String SYSTEM_ID = "system_id"; 7536 7537 /** 7538 * The total number of {@link Contacts} that have 7539 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only 7540 * present when querying {@link Groups#CONTENT_SUMMARY_URI}. 7541 * <p> 7542 * Type: INTEGER 7543 */ 7544 public static final String SUMMARY_COUNT = "summ_count"; 7545 7546 /** 7547 * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. 7548 * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. 7549 * 7550 * @hide 7551 */ 7552 public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = 7553 "return_group_count_per_account"; 7554 7555 /** 7556 * The total number of groups of the account that a group belongs to. 7557 * This column is available only when the parameter 7558 * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in 7559 * {@link Groups#CONTENT_SUMMARY_URI}. 7560 * 7561 * For example, when the account "A" has two groups "group1" and "group2", and the account 7562 * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for 7563 * "group3" returns "1" for this column. 7564 * 7565 * Note: This counts only non-favorites, non-auto-add, and not deleted groups. 7566 * 7567 * Type: INTEGER 7568 * @hide 7569 */ 7570 public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; 7571 7572 /** 7573 * The total number of {@link Contacts} that have both 7574 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. 7575 * Read-only value that is only present when querying 7576 * {@link Groups#CONTENT_SUMMARY_URI}. 7577 * <p> 7578 * Type: INTEGER 7579 */ 7580 public static final String SUMMARY_WITH_PHONES = "summ_phones"; 7581 7582 /** 7583 * Flag indicating if the contacts belonging to this group should be 7584 * visible in any user interface. 7585 * <p> 7586 * Type: INTEGER (boolean) 7587 */ 7588 public static final String GROUP_VISIBLE = "group_visible"; 7589 7590 /** 7591 * The "deleted" flag: "0" by default, "1" if the row has been marked 7592 * for deletion. When {@link android.content.ContentResolver#delete} is 7593 * called on a group, it is marked for deletion. The sync adaptor 7594 * deletes the group on the server and then calls ContactResolver.delete 7595 * once more, this time setting the the 7596 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to 7597 * finalize the data removal. 7598 * <P>Type: INTEGER</P> 7599 */ 7600 public static final String DELETED = "deleted"; 7601 7602 /** 7603 * Whether this group should be synced if the SYNC_EVERYTHING settings 7604 * is false for this group's account. 7605 * <p> 7606 * Type: INTEGER (boolean) 7607 */ 7608 public static final String SHOULD_SYNC = "should_sync"; 7609 7610 /** 7611 * Any newly created contacts will automatically be added to groups that have this 7612 * flag set to true. 7613 * <p> 7614 * Type: INTEGER (boolean) 7615 */ 7616 public static final String AUTO_ADD = "auto_add"; 7617 7618 /** 7619 * When a contacts is marked as a favorites it will be automatically added 7620 * to the groups that have this flag set, and when it is removed from favorites 7621 * it will be removed from these groups. 7622 * <p> 7623 * Type: INTEGER (boolean) 7624 */ 7625 public static final String FAVORITES = "favorites"; 7626 7627 /** 7628 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or 7629 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. 7630 * <P>Type: INTEGER</P> 7631 */ 7632 public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; 7633 } 7634 7635 /** 7636 * Constants for the groups table. Only per-account groups are supported. 7637 * <h2>Columns</h2> 7638 * <table class="jd-sumtable"> 7639 * <tr> 7640 * <th colspan='4'>Groups</th> 7641 * </tr> 7642 * <tr> 7643 * <td>long</td> 7644 * <td>{@link #_ID}</td> 7645 * <td>read-only</td> 7646 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. 7647 * In other words, it would be a really bad idea to delete and reinsert a 7648 * group. A sync adapter should always do an update instead.</td> 7649 * </tr> 7650 # <tr> 7651 * <td>String</td> 7652 * <td>{@link #DATA_SET}</td> 7653 * <td>read/write-once</td> 7654 * <td> 7655 * <p> 7656 * The data set within the account that this group belongs to. This allows 7657 * multiple sync adapters for the same account type to distinguish between 7658 * each others' group data. The combination of {@link #ACCOUNT_TYPE}, 7659 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data 7660 * that is associated with a single sync adapter. 7661 * </p> 7662 * <p> 7663 * This is empty by default, and is completely optional. It only needs to 7664 * be populated if multiple sync adapters are entering distinct data for 7665 * the same account type and account name. 7666 * </p> 7667 * <p> 7668 * It should be set at the time the group is inserted and never changed 7669 * afterwards. 7670 * </p> 7671 * </td> 7672 * </tr> 7673 * <tr> 7674 * <td>String</td> 7675 * <td>{@link #TITLE}</td> 7676 * <td>read/write</td> 7677 * <td>The display title of this group.</td> 7678 * </tr> 7679 * <tr> 7680 * <td>String</td> 7681 * <td>{@link #NOTES}</td> 7682 * <td>read/write</td> 7683 * <td>Notes about the group.</td> 7684 * </tr> 7685 * <tr> 7686 * <td>String</td> 7687 * <td>{@link #SYSTEM_ID}</td> 7688 * <td>read/write</td> 7689 * <td>The ID of this group if it is a System Group, i.e. a group that has a 7690 * special meaning to the sync adapter, null otherwise.</td> 7691 * </tr> 7692 * <tr> 7693 * <td>int</td> 7694 * <td>{@link #SUMMARY_COUNT}</td> 7695 * <td>read-only</td> 7696 * <td>The total number of {@link Contacts} that have 7697 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value 7698 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> 7699 * </tr> 7700 * <tr> 7701 * <td>int</td> 7702 * <td>{@link #SUMMARY_WITH_PHONES}</td> 7703 * <td>read-only</td> 7704 * <td>The total number of {@link Contacts} that have both 7705 * {@link CommonDataKinds.GroupMembership} in this group, and also have 7706 * phone numbers. Read-only value that is only present when querying 7707 * {@link Groups#CONTENT_SUMMARY_URI}.</td> 7708 * </tr> 7709 * <tr> 7710 * <td>int</td> 7711 * <td>{@link #GROUP_VISIBLE}</td> 7712 * <td>read-only</td> 7713 * <td>Flag indicating if the contacts belonging to this group should be 7714 * visible in any user interface. Allowed values: 0 and 1.</td> 7715 * </tr> 7716 * <tr> 7717 * <td>int</td> 7718 * <td>{@link #DELETED}</td> 7719 * <td>read/write</td> 7720 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked 7721 * for deletion. When {@link android.content.ContentResolver#delete} is 7722 * called on a group, it is marked for deletion. The sync adaptor deletes 7723 * the group on the server and then calls ContactResolver.delete once more, 7724 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} 7725 * query parameter to finalize the data removal.</td> 7726 * </tr> 7727 * <tr> 7728 * <td>int</td> 7729 * <td>{@link #SHOULD_SYNC}</td> 7730 * <td>read/write</td> 7731 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings 7732 * is false for this group's account.</td> 7733 * </tr> 7734 * </table> 7735 */ 7736 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { 7737 /** 7738 * This utility class cannot be instantiated 7739 */ 7740 private Groups() { 7741 } 7742 7743 /** 7744 * The content:// style URI for this table 7745 */ 7746 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); 7747 7748 /** 7749 * The content:// style URI for this table joined with details data from 7750 * {@link ContactsContract.Data}. 7751 */ 7752 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, 7753 "groups_summary"); 7754 7755 /** 7756 * The MIME type of a directory of groups. 7757 */ 7758 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; 7759 7760 /** 7761 * The MIME type of a single group. 7762 */ 7763 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; 7764 7765 public static EntityIterator newEntityIterator(Cursor cursor) { 7766 return new EntityIteratorImpl(cursor); 7767 } 7768 7769 private static class EntityIteratorImpl extends CursorEntityIterator { 7770 public EntityIteratorImpl(Cursor cursor) { 7771 super(cursor); 7772 } 7773 7774 @Override 7775 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { 7776 // we expect the cursor is already at the row we need to read from 7777 final ContentValues values = new ContentValues(); 7778 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); 7779 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); 7780 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); 7781 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); 7782 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); 7783 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); 7784 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); 7785 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); 7786 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); 7787 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); 7788 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); 7789 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); 7790 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); 7791 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); 7792 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); 7793 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); 7794 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); 7795 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); 7796 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); 7797 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); 7798 cursor.moveToNext(); 7799 return new Entity(values); 7800 } 7801 } 7802 } 7803 7804 /** 7805 * <p> 7806 * Constants for the contact aggregation exceptions table, which contains 7807 * aggregation rules overriding those used by automatic aggregation. This 7808 * type only supports query and update. Neither insert nor delete are 7809 * supported. 7810 * </p> 7811 * <h2>Columns</h2> 7812 * <table class="jd-sumtable"> 7813 * <tr> 7814 * <th colspan='4'>AggregationExceptions</th> 7815 * </tr> 7816 * <tr> 7817 * <td>int</td> 7818 * <td>{@link #TYPE}</td> 7819 * <td>read/write</td> 7820 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, 7821 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> 7822 * </tr> 7823 * <tr> 7824 * <td>long</td> 7825 * <td>{@link #RAW_CONTACT_ID1}</td> 7826 * <td>read/write</td> 7827 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that 7828 * the rule applies to.</td> 7829 * </tr> 7830 * <tr> 7831 * <td>long</td> 7832 * <td>{@link #RAW_CONTACT_ID2}</td> 7833 * <td>read/write</td> 7834 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact 7835 * that the rule applies to.</td> 7836 * </tr> 7837 * </table> 7838 */ 7839 public static final class AggregationExceptions implements BaseColumns { 7840 /** 7841 * This utility class cannot be instantiated 7842 */ 7843 private AggregationExceptions() {} 7844 7845 /** 7846 * The content:// style URI for this table 7847 */ 7848 public static final Uri CONTENT_URI = 7849 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); 7850 7851 /** 7852 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 7853 */ 7854 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; 7855 7856 /** 7857 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception 7858 */ 7859 public static final String CONTENT_ITEM_TYPE = 7860 "vnd.android.cursor.item/aggregation_exception"; 7861 7862 /** 7863 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or 7864 * {@link #TYPE_AUTOMATIC}. 7865 * 7866 * <P>Type: INTEGER</P> 7867 */ 7868 public static final String TYPE = "type"; 7869 7870 /** 7871 * Allows the provider to automatically decide whether the specified raw contacts should 7872 * be included in the same aggregate contact or not. 7873 */ 7874 public static final int TYPE_AUTOMATIC = 0; 7875 7876 /** 7877 * Makes sure that the specified raw contacts are included in the same 7878 * aggregate contact. 7879 */ 7880 public static final int TYPE_KEEP_TOGETHER = 1; 7881 7882 /** 7883 * Makes sure that the specified raw contacts are NOT included in the same 7884 * aggregate contact. 7885 */ 7886 public static final int TYPE_KEEP_SEPARATE = 2; 7887 7888 /** 7889 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. 7890 */ 7891 public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; 7892 7893 /** 7894 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule 7895 * applies to. 7896 */ 7897 public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; 7898 } 7899 7900 /** 7901 * @see Settings 7902 */ 7903 protected interface SettingsColumns { 7904 /** 7905 * The name of the account instance to which this row belongs. 7906 * <P>Type: TEXT</P> 7907 */ 7908 public static final String ACCOUNT_NAME = "account_name"; 7909 7910 /** 7911 * The type of account to which this row belongs, which when paired with 7912 * {@link #ACCOUNT_NAME} identifies a specific account. 7913 * <P>Type: TEXT</P> 7914 */ 7915 public static final String ACCOUNT_TYPE = "account_type"; 7916 7917 /** 7918 * The data set within the account that this row belongs to. This allows 7919 * multiple sync adapters for the same account type to distinguish between 7920 * each others' data. 7921 * 7922 * This is empty by default, and is completely optional. It only needs to 7923 * be populated if multiple sync adapters are entering distinct data for 7924 * the same account type and account name. 7925 * <P>Type: TEXT</P> 7926 */ 7927 public static final String DATA_SET = "data_set"; 7928 7929 /** 7930 * Depending on the mode defined by the sync-adapter, this flag controls 7931 * the top-level sync behavior for this data source. 7932 * <p> 7933 * Type: INTEGER (boolean) 7934 */ 7935 public static final String SHOULD_SYNC = "should_sync"; 7936 7937 /** 7938 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} 7939 * entries should be visible in any user interface. 7940 * <p> 7941 * Type: INTEGER (boolean) 7942 */ 7943 public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; 7944 7945 /** 7946 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any 7947 * {@link Groups#SHOULD_SYNC} under this account have been marked as 7948 * unsynced. 7949 */ 7950 public static final String ANY_UNSYNCED = "any_unsynced"; 7951 7952 /** 7953 * Read-only count of {@link Contacts} from a specific source that have 7954 * no {@link CommonDataKinds.GroupMembership} entries. 7955 * <p> 7956 * Type: INTEGER 7957 */ 7958 public static final String UNGROUPED_COUNT = "summ_count"; 7959 7960 /** 7961 * Read-only count of {@link Contacts} from a specific source that have 7962 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. 7963 * <p> 7964 * Type: INTEGER 7965 */ 7966 public static final String UNGROUPED_WITH_PHONES = "summ_phones"; 7967 } 7968 7969 /** 7970 * <p> 7971 * Contacts-specific settings for various {@link Account}'s. 7972 * </p> 7973 * <h2>Columns</h2> 7974 * <table class="jd-sumtable"> 7975 * <tr> 7976 * <th colspan='4'>Settings</th> 7977 * </tr> 7978 * <tr> 7979 * <td>String</td> 7980 * <td>{@link #ACCOUNT_NAME}</td> 7981 * <td>read/write-once</td> 7982 * <td>The name of the account instance to which this row belongs.</td> 7983 * </tr> 7984 * <tr> 7985 * <td>String</td> 7986 * <td>{@link #ACCOUNT_TYPE}</td> 7987 * <td>read/write-once</td> 7988 * <td>The type of account to which this row belongs, which when paired with 7989 * {@link #ACCOUNT_NAME} identifies a specific account.</td> 7990 * </tr> 7991 * <tr> 7992 * <td>int</td> 7993 * <td>{@link #SHOULD_SYNC}</td> 7994 * <td>read/write</td> 7995 * <td>Depending on the mode defined by the sync-adapter, this flag controls 7996 * the top-level sync behavior for this data source.</td> 7997 * </tr> 7998 * <tr> 7999 * <td>int</td> 8000 * <td>{@link #UNGROUPED_VISIBLE}</td> 8001 * <td>read/write</td> 8002 * <td>Flag indicating if contacts without any 8003 * {@link CommonDataKinds.GroupMembership} entries should be visible in any 8004 * user interface.</td> 8005 * </tr> 8006 * <tr> 8007 * <td>int</td> 8008 * <td>{@link #ANY_UNSYNCED}</td> 8009 * <td>read-only</td> 8010 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any 8011 * {@link Groups#SHOULD_SYNC} under this account have been marked as 8012 * unsynced.</td> 8013 * </tr> 8014 * <tr> 8015 * <td>int</td> 8016 * <td>{@link #UNGROUPED_COUNT}</td> 8017 * <td>read-only</td> 8018 * <td>Read-only count of {@link Contacts} from a specific source that have 8019 * no {@link CommonDataKinds.GroupMembership} entries.</td> 8020 * </tr> 8021 * <tr> 8022 * <td>int</td> 8023 * <td>{@link #UNGROUPED_WITH_PHONES}</td> 8024 * <td>read-only</td> 8025 * <td>Read-only count of {@link Contacts} from a specific source that have 8026 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone 8027 * numbers.</td> 8028 * </tr> 8029 * </table> 8030 */ 8031 public static final class Settings implements SettingsColumns { 8032 /** 8033 * This utility class cannot be instantiated 8034 */ 8035 private Settings() { 8036 } 8037 8038 /** 8039 * The content:// style URI for this table 8040 */ 8041 public static final Uri CONTENT_URI = 8042 Uri.withAppendedPath(AUTHORITY_URI, "settings"); 8043 8044 /** 8045 * The MIME-type of {@link #CONTENT_URI} providing a directory of 8046 * settings. 8047 */ 8048 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; 8049 8050 /** 8051 * The MIME-type of {@link #CONTENT_URI} providing a single setting. 8052 */ 8053 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; 8054 } 8055 8056 /** 8057 * API for inquiring about the general status of the provider. 8058 */ 8059 public static final class ProviderStatus { 8060 8061 /** 8062 * Not instantiable. 8063 */ 8064 private ProviderStatus() { 8065 } 8066 8067 /** 8068 * The content:// style URI for this table. Requests to this URI can be 8069 * performed on the UI thread because they are always unblocking. 8070 */ 8071 public static final Uri CONTENT_URI = 8072 Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); 8073 8074 /** 8075 * The MIME-type of {@link #CONTENT_URI} providing a directory of 8076 * settings. 8077 */ 8078 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; 8079 8080 /** 8081 * An integer representing the current status of the provider. 8082 */ 8083 public static final String STATUS = "status"; 8084 8085 /** 8086 * Default status of the provider. 8087 */ 8088 public static final int STATUS_NORMAL = 0; 8089 8090 /** 8091 * The provider won't respond to queries. It is in the middle of a long running task, such 8092 * as a database upgrade or locale change. 8093 */ 8094 public static final int STATUS_BUSY = 1; 8095 8096 /** 8097 * The status that indicates that there are no accounts and no contacts 8098 * on the device. 8099 */ 8100 public static final int STATUS_EMPTY = 2; 8101 } 8102 8103 /** 8104 * <p> 8105 * API allowing applications to send usage information for each {@link Data} row to the 8106 * Contacts Provider. Applications can also clear all usage information. 8107 * </p> 8108 * <p> 8109 * With the feedback, Contacts Provider may return more contextually appropriate results for 8110 * Data listing, typically supplied with 8111 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, 8112 * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, 8113 * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit 8114 * from better ranked (sorted) lists in applications that show auto-complete list. 8115 * </p> 8116 * <p> 8117 * There is no guarantee for how this feedback is used, or even whether it is used at all. 8118 * The ranking algorithm will make best efforts to use the feedback data, but the exact 8119 * implementation, the storage data structures as well as the resulting sort order is device 8120 * and version specific and can change over time. 8121 * </p> 8122 * <p> 8123 * When updating usage information, users of this API need to use 8124 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed 8125 * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as 8126 * its last path. They also need to append a query parameter to the Uri, to specify the type of 8127 * the communication, which enables the Contacts Provider to differentiate between kinds of 8128 * interactions using the same contact data field (for example a phone number can be used to 8129 * make phone calls or send SMS). 8130 * </p> 8131 * <p> 8132 * Selection and selectionArgs are ignored and must be set to null. To get data ids, 8133 * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} 8134 * toward {@link Data#CONTENT_URI}. 8135 * </p> 8136 * <p> 8137 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive 8138 * integer when successful, and returns 0 if no contact with that id was found. 8139 * </p> 8140 * <p> 8141 * Example: 8142 * <pre> 8143 * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() 8144 * .appendPath(TextUtils.join(",", dataIds)) 8145 * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, 8146 * DataUsageFeedback.USAGE_TYPE_CALL) 8147 * .build(); 8148 * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; 8149 * </pre> 8150 * </p> 8151 * <p> 8152 * Applications can also clear all usage information with: 8153 * <pre> 8154 * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; 8155 * </pre> 8156 * </p> 8157 */ 8158 public static final class DataUsageFeedback { 8159 8160 /** 8161 * The content:// style URI for sending usage feedback. 8162 * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. 8163 */ 8164 public static final Uri FEEDBACK_URI = 8165 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); 8166 8167 /** 8168 * The content:// style URI for deleting all usage information. 8169 * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. 8170 * The {@code where} and {@code selectionArgs} parameters are ignored. 8171 */ 8172 public static final Uri DELETE_USAGE_URI = 8173 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); 8174 8175 /** 8176 * <p> 8177 * Name for query parameter specifying the type of data usage. 8178 * </p> 8179 */ 8180 public static final String USAGE_TYPE = "type"; 8181 8182 /** 8183 * <p> 8184 * Type of usage for voice interaction, which includes phone call, voice chat, and 8185 * video chat. 8186 * </p> 8187 */ 8188 public static final String USAGE_TYPE_CALL = "call"; 8189 8190 /** 8191 * <p> 8192 * Type of usage for text interaction involving longer messages, which includes email. 8193 * </p> 8194 */ 8195 public static final String USAGE_TYPE_LONG_TEXT = "long_text"; 8196 8197 /** 8198 * <p> 8199 * Type of usage for text interaction involving shorter messages, which includes SMS, 8200 * text chat with email addresses. 8201 * </p> 8202 */ 8203 public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; 8204 } 8205 8206 /** 8207 * <p> 8208 * Contact-specific information about whether or not a contact has been pinned by the user 8209 * at a particular position within the system contact application's user interface. 8210 * </p> 8211 * 8212 * <p> 8213 * This pinning information can be used by individual applications to customize how 8214 * they order particular pinned contacts. For example, a Dialer application could 8215 * use pinned information to order user-pinned contacts in a top row of favorites. 8216 * </p> 8217 * 8218 * <p> 8219 * It is possible for two or more contacts to occupy the same pinned position (due 8220 * to aggregation and sync), so this pinning information should be used on a best-effort 8221 * basis to order contacts in-application rather than an absolute guide on where a contact 8222 * should be positioned. Contacts returned by the ContactsProvider will not be ordered based 8223 * on this information, so it is up to the client application to reorder these contacts within 8224 * their own UI adhering to (or ignoring as appropriate) information stored in the pinned 8225 * column. 8226 * </p> 8227 * 8228 * <p> 8229 * By default, unpinned contacts will have a pinned position of 8230 * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive 8231 * integers that are greater than 1. 8232 * </p> 8233 */ 8234 public static final class PinnedPositions { 8235 /** 8236 * The method to invoke in order to undemote a formerly demoted contact. The contact id of 8237 * the contact must be provided as an argument. If the contact was not previously demoted, 8238 * nothing will be done. 8239 * @hide 8240 */ 8241 public static final String UNDEMOTE_METHOD = "undemote"; 8242 8243 /** 8244 * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing 8245 * will be done. 8246 * 8247 * @param contentResolver to perform the undemote operation on. 8248 * @param contactId the id of the contact to undemote. 8249 */ 8250 public static void undemote(ContentResolver contentResolver, long contactId) { 8251 contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD, 8252 String.valueOf(contactId), null); 8253 } 8254 8255 /** 8256 * Pins a contact at a provided position, or unpins a contact. 8257 * 8258 * @param contentResolver to perform the pinning operation on. 8259 * @param pinnedPosition the position to pin the contact at. To unpin a contact, use 8260 * {@link PinnedPositions#UNPINNED}. 8261 */ 8262 public static void pin( 8263 ContentResolver contentResolver, long contactId, int pinnedPosition) { 8264 final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); 8265 final ContentValues values = new ContentValues(); 8266 values.put(Contacts.PINNED, pinnedPosition); 8267 contentResolver.update(uri, values, null, null); 8268 } 8269 8270 /** 8271 * Default value for the pinned position of an unpinned contact. 8272 */ 8273 public static final int UNPINNED = 0; 8274 8275 /** 8276 * Value of pinned position for a contact that a user has indicated should be considered 8277 * of the lowest priority. It is up to the client application to determine how to present 8278 * such a contact - for example all the way at the bottom of a contact list, or simply 8279 * just hidden from view. 8280 */ 8281 public static final int DEMOTED = -1; 8282 } 8283 8284 /** 8285 * Helper methods to display QuickContact dialogs that display all the information belonging to 8286 * a specific {@link Contacts} entry. 8287 */ 8288 public static final class QuickContact { 8289 /** 8290 * Action used to launch the system contacts application and bring up a QuickContact dialog 8291 * for the provided {@link Contacts} entry. 8292 */ 8293 public static final String ACTION_QUICK_CONTACT = 8294 "android.provider.action.QUICK_CONTACT"; 8295 8296 /** 8297 * Extra used to specify pivot dialog location in screen coordinates. 8298 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. 8299 * @hide 8300 */ 8301 @Deprecated 8302 public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT"; 8303 8304 /** 8305 * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts 8306 * will respect this extra's value. 8307 * 8308 * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. 8309 */ 8310 public static final String EXTRA_MODE = "android.provider.extra.MODE"; 8311 8312 /** 8313 * Extra used to specify which mimetype should be prioritized in the QuickContacts UI. 8314 * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can 8315 * cause phone numbers to be displayed more prominently in QuickContacts. 8316 */ 8317 public static final String EXTRA_PRIORITIZED_MIMETYPE 8318 = "android.provider.extra.PRIORITIZED_MIMETYPE"; 8319 8320 /** 8321 * Extra used to indicate a list of specific MIME-types to exclude and not display in the 8322 * QuickContacts dialog. Stored as a {@link String} array. 8323 */ 8324 public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; 8325 8326 /** 8327 * Small QuickContact mode, usually presented with minimal actions. 8328 */ 8329 public static final int MODE_SMALL = 1; 8330 8331 /** 8332 * Medium QuickContact mode, includes actions and light summary describing 8333 * the {@link Contacts} entry being shown. This may include social 8334 * status and presence details. 8335 */ 8336 public static final int MODE_MEDIUM = 2; 8337 8338 /** 8339 * Large QuickContact mode, includes actions and larger, card-like summary 8340 * of the {@link Contacts} entry being shown. This may include detailed 8341 * information, such as a photo. 8342 */ 8343 public static final int MODE_LARGE = 3; 8344 8345 /** @hide */ 8346 public static final int MODE_DEFAULT = MODE_LARGE; 8347 8348 /** 8349 * Constructs the QuickContacts intent with a view's rect. 8350 * @hide 8351 */ 8352 public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, 8353 int mode, String[] excludeMimes) { 8354 // Find location and bounds of target view, adjusting based on the 8355 // assumed local density. 8356 final float appScale = context.getResources().getCompatibilityInfo().applicationScale; 8357 final int[] pos = new int[2]; 8358 target.getLocationOnScreen(pos); 8359 8360 final Rect rect = new Rect(); 8361 rect.left = (int) (pos[0] * appScale + 0.5f); 8362 rect.top = (int) (pos[1] * appScale + 0.5f); 8363 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); 8364 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); 8365 8366 return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); 8367 } 8368 8369 /** 8370 * Constructs the QuickContacts intent. 8371 * @hide 8372 */ 8373 public static Intent composeQuickContactsIntent(Context context, Rect target, 8374 Uri lookupUri, int mode, String[] excludeMimes) { 8375 // When launching from an Activiy, we don't want to start a new task, but otherwise 8376 // we *must* start a new task. (Otherwise startActivity() would crash.) 8377 Context actualContext = context; 8378 while ((actualContext instanceof ContextWrapper) 8379 && !(actualContext instanceof Activity)) { 8380 actualContext = ((ContextWrapper) actualContext).getBaseContext(); 8381 } 8382 final int intentFlags = ((actualContext instanceof Activity) 8383 ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) 8384 // Workaround for b/16898764. Declaring singleTop in manifest doesn't work. 8385 | Intent.FLAG_ACTIVITY_SINGLE_TOP; 8386 8387 // Launch pivot dialog through intent for now 8388 final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); 8389 8390 // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync. 8391 intent.setData(lookupUri); 8392 intent.setSourceBounds(target); 8393 intent.putExtra(EXTRA_MODE, mode); 8394 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); 8395 return intent; 8396 } 8397 8398 /** 8399 * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager 8400 * to strip off anything not necessary. 8401 * 8402 * @hide 8403 */ 8404 public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId, 8405 boolean isContactIdIgnored, long directoryId, Intent originalIntent) { 8406 final Intent intent = new Intent(ACTION_QUICK_CONTACT); 8407 // Rebuild the URI from a lookup key and a contact ID. 8408 Uri uri = null; 8409 if (!TextUtils.isEmpty(lookupKey)) { 8410 uri = isContactIdIgnored 8411 ? Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey) 8412 : Contacts.getLookupUri(contactId, lookupKey); 8413 } 8414 if (uri != null && directoryId != Directory.DEFAULT) { 8415 uri = uri.buildUpon().appendQueryParameter( 8416 ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build(); 8417 } 8418 intent.setData(uri); 8419 8420 // Copy flags and always set NEW_TASK because it won't have a parent activity. 8421 intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); 8422 8423 // Copy extras. 8424 intent.setSourceBounds(originalIntent.getSourceBounds()); 8425 intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT)); 8426 intent.putExtra(EXTRA_EXCLUDE_MIMES, 8427 originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES)); 8428 return intent; 8429 } 8430 8431 8432 /** 8433 * Trigger a dialog that lists the various methods of interacting with 8434 * the requested {@link Contacts} entry. This may be based on available 8435 * {@link ContactsContract.Data} rows under that contact, and may also 8436 * include social status and presence details. 8437 * 8438 * @param context The parent {@link Context} that may be used as the 8439 * parent for this dialog. 8440 * @param target Specific {@link View} from your layout that this dialog 8441 * should be centered around. In particular, if the dialog 8442 * has a "callout" arrow, it will be pointed and centered 8443 * around this {@link View}. 8444 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 8445 * {@link Uri} that describes a specific contact to feature 8446 * in this dialog. 8447 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 8448 * {@link #MODE_LARGE}, indicating the desired dialog size, 8449 * when supported. 8450 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 8451 * to exclude when showing this dialog. For example, when 8452 * already viewing the contact details card, this can be used 8453 * to omit the details entry from the dialog. 8454 */ 8455 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, 8456 String[] excludeMimes) { 8457 // Trigger with obtained rectangle 8458 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, 8459 excludeMimes); 8460 ContactsInternal.startQuickContactWithErrorToast(context, intent); 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 Rect} that this dialog should be 8472 * centered around, in screen coordinates. In particular, if 8473 * the dialog has a "callout" arrow, it will be pointed and 8474 * centered around this {@link Rect}. If you are running at a 8475 * non-native density, you need to manually adjust using 8476 * {@link DisplayMetrics#density} before calling. 8477 * @param lookupUri A 8478 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 8479 * {@link Uri} that describes a specific contact to feature 8480 * in this dialog. 8481 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 8482 * {@link #MODE_LARGE}, indicating the desired dialog size, 8483 * when supported. 8484 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 8485 * to exclude when showing this dialog. For example, when 8486 * already viewing the contact details card, this can be used 8487 * to omit the details entry from the dialog. 8488 */ 8489 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, 8490 String[] excludeMimes) { 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 View} from your layout that this dialog 8505 * should be centered around. In particular, if the dialog 8506 * has a "callout" arrow, it will be pointed and centered 8507 * around this {@link View}. 8508 * @param lookupUri A 8509 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 8510 * {@link Uri} that describes a specific contact to feature 8511 * in this dialog. 8512 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 8513 * to exclude when showing this dialog. For example, when 8514 * already viewing the contact details card, this can be used 8515 * to omit the details entry from the dialog. 8516 * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. 8517 * For example, passing the value 8518 * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be 8519 * displayed more prominently in QuickContacts. 8520 */ 8521 public static void showQuickContact(Context context, View target, Uri lookupUri, 8522 String[] excludeMimes, String prioritizedMimeType) { 8523 // Use MODE_LARGE instead of accepting mode as a parameter. The different mode 8524 // values defined in ContactsContract only affect very old implementations 8525 // of QuickContacts. 8526 Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, 8527 excludeMimes); 8528 intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); 8529 ContactsInternal.startQuickContactWithErrorToast(context, intent); 8530 } 8531 8532 /** 8533 * Trigger a dialog that lists the various methods of interacting with 8534 * the requested {@link Contacts} entry. This may be based on available 8535 * {@link ContactsContract.Data} rows under that contact, and may also 8536 * include social status and presence details. 8537 * 8538 * @param context The parent {@link Context} that may be used as the 8539 * parent for this dialog. 8540 * @param target Specific {@link Rect} that this dialog should be 8541 * centered around, in screen coordinates. In particular, if 8542 * the dialog has a "callout" arrow, it will be pointed and 8543 * centered around this {@link Rect}. If you are running at a 8544 * non-native density, you need to manually adjust using 8545 * {@link DisplayMetrics#density} before calling. 8546 * @param lookupUri A 8547 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 8548 * {@link Uri} that describes a specific contact to feature 8549 * in this dialog. 8550 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 8551 * to exclude when showing this dialog. For example, when 8552 * already viewing the contact details card, this can be used 8553 * to omit the details entry from the dialog. 8554 * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. 8555 * For example, passing the value 8556 * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be 8557 * displayed more prominently in QuickContacts. 8558 */ 8559 public static void showQuickContact(Context context, Rect target, Uri lookupUri, 8560 String[] excludeMimes, String prioritizedMimeType) { 8561 // Use MODE_LARGE instead of accepting mode as a parameter. The different mode 8562 // values defined in ContactsContract only affect very old implementations 8563 // of QuickContacts. 8564 Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, 8565 excludeMimes); 8566 intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); 8567 ContactsInternal.startQuickContactWithErrorToast(context, intent); 8568 } 8569 } 8570 8571 /** 8572 * Helper class for accessing full-size photos by photo file ID. 8573 * <p> 8574 * Usage example: 8575 * <dl> 8576 * <dt>Retrieving a full-size photo by photo file ID (see 8577 * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) 8578 * </dt> 8579 * <dd> 8580 * <pre> 8581 * public InputStream openDisplayPhoto(long photoFileId) { 8582 * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); 8583 * try { 8584 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( 8585 * displayPhotoUri, "r"); 8586 * return fd.createInputStream(); 8587 * } catch (IOException e) { 8588 * return null; 8589 * } 8590 * } 8591 * </pre> 8592 * </dd> 8593 * </dl> 8594 * </p> 8595 */ 8596 public static final class DisplayPhoto { 8597 /** 8598 * no public constructor since this is a utility class 8599 */ 8600 private DisplayPhoto() {} 8601 8602 /** 8603 * The content:// style URI for this class, which allows access to full-size photos, 8604 * given a key. 8605 */ 8606 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); 8607 8608 /** 8609 * This URI allows the caller to query for the maximum dimensions of a display photo 8610 * or thumbnail. Requests to this URI can be performed on the UI thread because 8611 * they are always unblocking. 8612 */ 8613 public static final Uri CONTENT_MAX_DIMENSIONS_URI = 8614 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); 8615 8616 /** 8617 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will 8618 * contain this column, populated with the maximum height and width (in pixels) 8619 * that will be stored for a display photo. Larger photos will be down-sized to 8620 * fit within a square of this many pixels. 8621 */ 8622 public static final String DISPLAY_MAX_DIM = "display_max_dim"; 8623 8624 /** 8625 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will 8626 * contain this column, populated with the height and width (in pixels) for photo 8627 * thumbnails. 8628 */ 8629 public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; 8630 } 8631 8632 /** 8633 * Contains helper classes used to create or manage {@link android.content.Intent Intents} 8634 * that involve contacts. 8635 */ 8636 public static final class Intents { 8637 /** 8638 * This is the intent that is fired when a search suggestion is clicked on. 8639 */ 8640 public static final String SEARCH_SUGGESTION_CLICKED = 8641 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; 8642 8643 /** 8644 * This is the intent that is fired when a search suggestion for dialing a number 8645 * is clicked on. 8646 */ 8647 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = 8648 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; 8649 8650 /** 8651 * This is the intent that is fired when a search suggestion for creating a contact 8652 * is clicked on. 8653 */ 8654 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = 8655 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; 8656 8657 /** 8658 * This is the intent that is fired when the contacts database is created. <p> The 8659 * READ_CONTACT permission is required to receive these broadcasts. 8660 */ 8661 public static final String CONTACTS_DATABASE_CREATED = 8662 "android.provider.Contacts.DATABASE_CREATED"; 8663 8664 /** 8665 * Starts an Activity that lets the user pick a contact to attach an image to. 8666 * After picking the contact it launches the image cropper in face detection mode. 8667 */ 8668 public static final String ATTACH_IMAGE = 8669 "com.android.contacts.action.ATTACH_IMAGE"; 8670 8671 /** 8672 * This is the intent that is fired when the user clicks the "invite to the network" button 8673 * on a contact. Only sent to an activity which is explicitly registered by a contact 8674 * provider which supports the "invite to the network" feature. 8675 * <p> 8676 * {@link Intent#getData()} contains the lookup URI for the contact. 8677 */ 8678 public static final String INVITE_CONTACT = 8679 "com.android.contacts.action.INVITE_CONTACT"; 8680 8681 /** 8682 * Takes as input a data URI with a mailto: or tel: scheme. If a single 8683 * contact exists with the given data it will be shown. If no contact 8684 * exists, a dialog will ask the user if they want to create a new 8685 * contact with the provided details filled in. If multiple contacts 8686 * share the data the user will be prompted to pick which contact they 8687 * want to view. 8688 * <p> 8689 * For <code>mailto:</code> URIs, the scheme specific portion must be a 8690 * raw email address, such as one built using 8691 * {@link Uri#fromParts(String, String, String)}. 8692 * <p> 8693 * For <code>tel:</code> URIs, the scheme specific portion is compared 8694 * to existing numbers using the standard caller ID lookup algorithm. 8695 * The number must be properly encoded, for example using 8696 * {@link Uri#fromParts(String, String, String)}. 8697 * <p> 8698 * Any extras from the {@link Insert} class will be passed along to the 8699 * create activity if there are no contacts to show. 8700 * <p> 8701 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip 8702 * prompting the user when the contact doesn't exist. 8703 */ 8704 public static final String SHOW_OR_CREATE_CONTACT = 8705 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; 8706 8707 /** 8708 * Activity Action: Initiate a message to someone by voice. The message could be text, 8709 * audio, video or image(photo). This action supports messaging with a specific contact 8710 * regardless of the underlying messaging protocol used. 8711 * <p> 8712 * The action could be originated from the Voice Assistant as a voice interaction. In such 8713 * case, a receiving activity that supports {@link android.content.Intent#CATEGORY_VOICE} 8714 * could check return value of {@link android.app.Activity#isVoiceInteractionRoot} before 8715 * proceeding. By doing this check the activity verifies that the action indeed was 8716 * initiated by Voice Assistant and could send a message right away, without any further 8717 * input from the user. This allows for a smooth user experience when sending a message by 8718 * voice. Note: this activity must also support the {@link 8719 * android.content.Intent#CATEGORY_DEFAULT} so it can be found by {@link 8720 * android.service.voice.VoiceInteractionSession#startVoiceActivity}. 8721 * <p> 8722 * When the action was not initiated by Voice Assistant or when the receiving activity does 8723 * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity should confirm 8724 * with the user before sending the message (because in this case it is unknown which app 8725 * sent the intent, it could be malicious). 8726 * <p> 8727 * To allow the Voice Assistant to help users with contacts disambiguation, the messaging 8728 * app may choose to integrate with the Contacts Provider. The following convention should 8729 * be met when creating Data table for such integration: 8730 * <ul> 8731 * <li>Column {@link DataColumns#DATA1} should store the unique contact ID as understood by 8732 * the app. This value will be used in the {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID}.</li> 8733 * <li>Optionally, column {@link DataColumns#DATA3} could store a human readable label for 8734 * the ID. For example it could be phone number or human readable username/user_id like 8735 * "a_super_cool_user_name". This label may be shown below the Contact Name by the Voice 8736 * Assistant as the user completes the voice action. If DATA3 is empty, the ID in DATA1 may 8737 * be shown instead.</li> 8738 * <li><em>Note: Do not use DATA3 to store the Contact Name. The Voice Assistant will 8739 * already get the Contact Name from the RawContact’s display_name.</em></li> 8740 * <li><em>Note: Some apps may choose to use phone number as the unique contact ID in DATA1. 8741 * If this applies to you and you’d like phone number to be shown below the Contact Name by 8742 * the Voice Assistant, then you may choose to leave DATA3 empty.</em></li> 8743 * </ul> 8744 * <p> 8745 * Input: {@link android.content.Intent#getType} is the MIME type of the data being sent. 8746 * The intent sender will always put the concrete mime type in the intent type, like 8747 * "text/plain" or "audio/wav" for example. If the MIME type is "text/plain", message to 8748 * sent will be provided via {@link android.content.Intent#EXTRA_TEXT} as a styled 8749 * CharSequence. Otherwise, the message content will be supplied through {@link 8750 * android.content.Intent#setClipData(ClipData)} as a content provider URI(s). In the latter 8751 * case, EXTRA_TEXT could still be supplied optionally; for example, for audio messages 8752 * ClipData will contain URI of a recording and EXTRA_TEXT could contain the text 8753 * transcription of this recording. 8754 * <p> 8755 * The message can have n recipients. The n-th recipient of the message will be provided as 8756 * n-th elements of {@link #EXTRA_RECIPIENT_CONTACT_URI}, {@link 8757 * #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and {@link #EXTRA_RECIPIENT_CONTACT_NAME} (as a 8758 * consequence, EXTRA_RECIPIENT_CONTACT_URI, EXTRA_RECIPIENT_CONTACT_CHAT_ID and 8759 * EXTRA_RECIPIENT_CONTACT_NAME should all be of length n). If neither of these 3 elements 8760 * is provided (e.g. all 3 are null) for the recipient or if the information provided is 8761 * ambiguous then the activity should prompt the user for the recipient to send the message 8762 * to. 8763 * <p> 8764 * Output: nothing 8765 * 8766 * @see #EXTRA_RECIPIENT_CONTACT_URI 8767 * @see #EXTRA_RECIPIENT_CONTACT_CHAT_ID 8768 * @see #EXTRA_RECIPIENT_CONTACT_NAME 8769 */ 8770 public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS = 8771 "android.provider.action.VOICE_SEND_MESSAGE_TO_CONTACTS"; 8772 8773 /** 8774 * This extra specifies a content provider uri(s) for the contact(s) (if the contacts were 8775 * located in the Contacts Provider), used with {@link 8776 * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this 8777 * extra is a {@code String[]}. The number of elements in the array should be equal to 8778 * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and 8779 * {@link #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular 8780 * recipient is absent, it will be set to null. 8781 * <p> 8782 * <em>Note: one contact may have multiple accounts (e.g. Chat IDs) on a specific messaging 8783 * platform, so this may be ambiguous. E.g., one contact “John Smith” could have two 8784 * accounts on the same messaging app.</em> 8785 * <p> 8786 * <em>Example value: {"content://com.android.contacts/contacts/16"}</em> 8787 */ 8788 public static final String EXTRA_RECIPIENT_CONTACT_URI = 8789 "android.provider.extra.RECIPIENT_CONTACT_URI"; 8790 8791 /** 8792 * This extra specifies a messaging app’s unique ID(s) for the contact(s), used with {@link 8793 * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this 8794 * extra is a {@code String[]}. The number of elements in the array should be equal to 8795 * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link 8796 * #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular 8797 * recipient is absent, it will be set to null. 8798 * <p> 8799 * The value of the elements comes from the {@link DataColumns#DATA1} column in Contacts 8800 * Provider, and should be the unambiguous contact endpoint. This value is app-specific, it 8801 * could be a phone number or some proprietary ID. 8802 */ 8803 public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID = 8804 "android.provider.extra.RECIPIENT_CONTACT_CHAT_ID"; 8805 8806 /** 8807 * This extra specifies the contact name (full name from the Contacts Provider), used with 8808 * {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient. The value of this 8809 * extra is a {@code String[]}. The number of elements in the array should be equal to 8810 * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link 8811 * #EXTRA_RECIPIENT_CONTACT_CHAT_ID}). When the value of the element for the particular 8812 * recipient is absent, it will be set to null. 8813 * <p> 8814 * The value of the elements comes from RawContact's display_name column. 8815 * <p> 8816 * <em>Example value: {"Jane Doe"}</em> 8817 */ 8818 public static final String EXTRA_RECIPIENT_CONTACT_NAME = 8819 "android.provider.extra.RECIPIENT_CONTACT_NAME"; 8820 8821 /** 8822 * Starts an Activity that lets the user select the multiple phones from a 8823 * list of phone numbers which come from the contacts or 8824 * {@link #EXTRA_PHONE_URIS}. 8825 * <p> 8826 * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} 8827 * could belong to the contacts or not, and will be selected by default. 8828 * <p> 8829 * The user's selection will be returned from 8830 * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} 8831 * if the resultCode is 8832 * {@link android.app.Activity#RESULT_OK}, the array of picked phone 8833 * numbers are in the Intent's 8834 * {@link #EXTRA_PHONE_URIS}; otherwise, the 8835 * {@link android.app.Activity#RESULT_CANCELED} is returned if the user 8836 * left the Activity without changing the selection. 8837 * 8838 * @hide 8839 */ 8840 public static final String ACTION_GET_MULTIPLE_PHONES = 8841 "com.android.contacts.action.GET_MULTIPLE_PHONES"; 8842 8843 /** 8844 * A broadcast action which is sent when any change has been made to the profile, such 8845 * as the profile name or the picture. A receiver must have 8846 * the android.permission.READ_PROFILE permission. 8847 * 8848 * @hide 8849 */ 8850 public static final String ACTION_PROFILE_CHANGED = 8851 "android.provider.Contacts.PROFILE_CHANGED"; 8852 8853 /** 8854 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new 8855 * contact if no matching contact found. Otherwise, default behavior is 8856 * to prompt user with dialog before creating. 8857 * <p> 8858 * Type: BOOLEAN 8859 */ 8860 public static final String EXTRA_FORCE_CREATE = 8861 "com.android.contacts.action.FORCE_CREATE"; 8862 8863 /** 8864 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact 8865 * description to be shown when prompting user about creating a new 8866 * contact. 8867 * <p> 8868 * Type: STRING 8869 */ 8870 public static final String EXTRA_CREATE_DESCRIPTION = 8871 "com.android.contacts.action.CREATE_DESCRIPTION"; 8872 8873 /** 8874 * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. 8875 * <p> 8876 * The phone numbers want to be picked by default should be passed in as 8877 * input value. These phone numbers could belong to the contacts or not. 8878 * <p> 8879 * The phone numbers which were picked by the user are returned as output 8880 * value. 8881 * <p> 8882 * Type: array of URIs, the tel URI is used for the phone numbers which don't 8883 * belong to any contact, the content URI is used for phone id in contacts. 8884 * 8885 * @hide 8886 */ 8887 public static final String EXTRA_PHONE_URIS = 8888 "com.android.contacts.extra.PHONE_URIS"; 8889 8890 /** 8891 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 8892 * dialog location using screen coordinates. When not specified, the 8893 * dialog will be centered. 8894 * 8895 * @hide 8896 */ 8897 @Deprecated 8898 public static final String EXTRA_TARGET_RECT = "target_rect"; 8899 8900 /** 8901 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 8902 * desired dialog style, usually a variation on size. One of 8903 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. 8904 * 8905 * @hide 8906 */ 8907 @Deprecated 8908 public static final String EXTRA_MODE = "mode"; 8909 8910 /** 8911 * Value for {@link #EXTRA_MODE} to show a small-sized dialog. 8912 * 8913 * @hide 8914 */ 8915 @Deprecated 8916 public static final int MODE_SMALL = 1; 8917 8918 /** 8919 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. 8920 * 8921 * @hide 8922 */ 8923 @Deprecated 8924 public static final int MODE_MEDIUM = 2; 8925 8926 /** 8927 * Value for {@link #EXTRA_MODE} to show a large-sized dialog. 8928 * 8929 * @hide 8930 */ 8931 @Deprecated 8932 public static final int MODE_LARGE = 3; 8933 8934 /** 8935 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate 8936 * a list of specific MIME-types to exclude and not display. Stored as a 8937 * {@link String} array. 8938 * 8939 * @hide 8940 */ 8941 @Deprecated 8942 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; 8943 8944 /** 8945 * Convenience class that contains string constants used 8946 * to create contact {@link android.content.Intent Intents}. 8947 */ 8948 public static final class Insert { 8949 /** The action code to use when adding a contact */ 8950 public static final String ACTION = Intent.ACTION_INSERT; 8951 8952 /** 8953 * If present, forces a bypass of quick insert mode. 8954 */ 8955 public static final String FULL_MODE = "full_mode"; 8956 8957 /** 8958 * The extra field for the contact name. 8959 * <P>Type: String</P> 8960 */ 8961 public static final String NAME = "name"; 8962 8963 // TODO add structured name values here. 8964 8965 /** 8966 * The extra field for the contact phonetic name. 8967 * <P>Type: String</P> 8968 */ 8969 public static final String PHONETIC_NAME = "phonetic_name"; 8970 8971 /** 8972 * The extra field for the contact company. 8973 * <P>Type: String</P> 8974 */ 8975 public static final String COMPANY = "company"; 8976 8977 /** 8978 * The extra field for the contact job title. 8979 * <P>Type: String</P> 8980 */ 8981 public static final String JOB_TITLE = "job_title"; 8982 8983 /** 8984 * The extra field for the contact notes. 8985 * <P>Type: String</P> 8986 */ 8987 public static final String NOTES = "notes"; 8988 8989 /** 8990 * The extra field for the contact phone number. 8991 * <P>Type: String</P> 8992 */ 8993 public static final String PHONE = "phone"; 8994 8995 /** 8996 * The extra field for the contact phone number type. 8997 * <P>Type: Either an integer value from 8998 * {@link CommonDataKinds.Phone}, 8999 * or a string specifying a custom label.</P> 9000 */ 9001 public static final String PHONE_TYPE = "phone_type"; 9002 9003 /** 9004 * The extra field for the phone isprimary flag. 9005 * <P>Type: boolean</P> 9006 */ 9007 public static final String PHONE_ISPRIMARY = "phone_isprimary"; 9008 9009 /** 9010 * The extra field for an optional second contact phone number. 9011 * <P>Type: String</P> 9012 */ 9013 public static final String SECONDARY_PHONE = "secondary_phone"; 9014 9015 /** 9016 * The extra field for an optional second contact phone number type. 9017 * <P>Type: Either an integer value from 9018 * {@link CommonDataKinds.Phone}, 9019 * or a string specifying a custom label.</P> 9020 */ 9021 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; 9022 9023 /** 9024 * The extra field for an optional third contact phone number. 9025 * <P>Type: String</P> 9026 */ 9027 public static final String TERTIARY_PHONE = "tertiary_phone"; 9028 9029 /** 9030 * The extra field for an optional third contact phone number type. 9031 * <P>Type: Either an integer value from 9032 * {@link CommonDataKinds.Phone}, 9033 * or a string specifying a custom label.</P> 9034 */ 9035 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; 9036 9037 /** 9038 * The extra field for the contact email address. 9039 * <P>Type: String</P> 9040 */ 9041 public static final String EMAIL = "email"; 9042 9043 /** 9044 * The extra field for the contact email type. 9045 * <P>Type: Either an integer value from 9046 * {@link CommonDataKinds.Email} 9047 * or a string specifying a custom label.</P> 9048 */ 9049 public static final String EMAIL_TYPE = "email_type"; 9050 9051 /** 9052 * The extra field for the email isprimary flag. 9053 * <P>Type: boolean</P> 9054 */ 9055 public static final String EMAIL_ISPRIMARY = "email_isprimary"; 9056 9057 /** 9058 * The extra field for an optional second contact email address. 9059 * <P>Type: String</P> 9060 */ 9061 public static final String SECONDARY_EMAIL = "secondary_email"; 9062 9063 /** 9064 * The extra field for an optional second contact email type. 9065 * <P>Type: Either an integer value from 9066 * {@link CommonDataKinds.Email} 9067 * or a string specifying a custom label.</P> 9068 */ 9069 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; 9070 9071 /** 9072 * The extra field for an optional third contact email address. 9073 * <P>Type: String</P> 9074 */ 9075 public static final String TERTIARY_EMAIL = "tertiary_email"; 9076 9077 /** 9078 * The extra field for an optional third contact email type. 9079 * <P>Type: Either an integer value from 9080 * {@link CommonDataKinds.Email} 9081 * or a string specifying a custom label.</P> 9082 */ 9083 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; 9084 9085 /** 9086 * The extra field for the contact postal address. 9087 * <P>Type: String</P> 9088 */ 9089 public static final String POSTAL = "postal"; 9090 9091 /** 9092 * The extra field for the contact postal address type. 9093 * <P>Type: Either an integer value from 9094 * {@link CommonDataKinds.StructuredPostal} 9095 * or a string specifying a custom label.</P> 9096 */ 9097 public static final String POSTAL_TYPE = "postal_type"; 9098 9099 /** 9100 * The extra field for the postal isprimary flag. 9101 * <P>Type: boolean</P> 9102 */ 9103 public static final String POSTAL_ISPRIMARY = "postal_isprimary"; 9104 9105 /** 9106 * The extra field for an IM handle. 9107 * <P>Type: String</P> 9108 */ 9109 public static final String IM_HANDLE = "im_handle"; 9110 9111 /** 9112 * The extra field for the IM protocol 9113 */ 9114 public static final String IM_PROTOCOL = "im_protocol"; 9115 9116 /** 9117 * The extra field for the IM isprimary flag. 9118 * <P>Type: boolean</P> 9119 */ 9120 public static final String IM_ISPRIMARY = "im_isprimary"; 9121 9122 /** 9123 * The extra field that allows the client to supply multiple rows of 9124 * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} 9125 * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of 9126 * {@link ContentValues}, one per data row. Supplying this extra is 9127 * similar to inserting multiple rows into the {@link Data} table, 9128 * except the user gets a chance to see and edit them before saving. 9129 * Each ContentValues object must have a value for {@link Data#MIMETYPE}. 9130 * If supplied values are not visible in the editor UI, they will be 9131 * dropped. Duplicate data will dropped. Some fields 9132 * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically 9133 * adjusted to comply with the constraints of the specific account type. 9134 * For example, an Exchange contact can only have one phone numbers of type Home, 9135 * so the contact editor may choose a different type for this phone number to 9136 * avoid dropping the valueable part of the row, which is the phone number. 9137 * <p> 9138 * Example: 9139 * <pre> 9140 * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); 9141 * 9142 * ContentValues row1 = new ContentValues(); 9143 * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); 9144 * row1.put(Organization.COMPANY, "Android"); 9145 * data.add(row1); 9146 * 9147 * ContentValues row2 = new ContentValues(); 9148 * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); 9149 * row2.put(Email.TYPE, Email.TYPE_CUSTOM); 9150 * row2.put(Email.LABEL, "Green Bot"); 9151 * row2.put(Email.ADDRESS, "android@android.com"); 9152 * data.add(row2); 9153 * 9154 * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); 9155 * intent.putParcelableArrayListExtra(Insert.DATA, data); 9156 * 9157 * startActivity(intent); 9158 * </pre> 9159 */ 9160 public static final String DATA = "data"; 9161 9162 /** 9163 * Used to specify the account in which to create the new contact. 9164 * <p> 9165 * If this value is not provided, the user is presented with a disambiguation 9166 * dialog to chose an account 9167 * <p> 9168 * Type: {@link Account} 9169 */ 9170 public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT"; 9171 9172 /** 9173 * Used to specify the data set within the account in which to create the 9174 * new contact. 9175 * <p> 9176 * This value is optional - if it is not specified, the contact will be 9177 * created in the base account, with no data set. 9178 * <p> 9179 * Type: String 9180 */ 9181 public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET"; 9182 } 9183 } 9184 9185 /** 9186 * @hide 9187 */ 9188 @SystemApi 9189 protected interface MetadataSyncColumns { 9190 9191 /** 9192 * The raw contact backup id. 9193 * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the 9194 * persistent unique id for each raw contact within its source system. 9195 */ 9196 public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id"; 9197 9198 /** 9199 * The account type to which the raw_contact of this item is associated. See 9200 * {@link RawContacts#ACCOUNT_TYPE} 9201 */ 9202 public static final String ACCOUNT_TYPE = "account_type"; 9203 9204 /** 9205 * The account name to which the raw_contact of this item is associated. See 9206 * {@link RawContacts#ACCOUNT_NAME} 9207 */ 9208 public static final String ACCOUNT_NAME = "account_name"; 9209 9210 /** 9211 * The data set within the account that the raw_contact of this row belongs to. This allows 9212 * multiple sync adapters for the same account type to distinguish between 9213 * each others' data. 9214 * {@link RawContacts#DATA_SET} 9215 */ 9216 public static final String DATA_SET = "data_set"; 9217 9218 /** 9219 * A text column contains the Json string got from People API. The Json string contains 9220 * all the metadata related to the raw contact, i.e., all the data fields and 9221 * aggregation exceptions. 9222 * 9223 * Here is an example of the Json string got from the actual schema. 9224 * <pre> 9225 * { 9226 * "unique_contact_id": { 9227 * "account_type": "CUSTOM_ACCOUNT", 9228 * "custom_account_type": "facebook", 9229 * "account_name": "android-test", 9230 * "contact_id": "1111111", 9231 * "data_set": "FOCUS" 9232 * }, 9233 * "contact_prefs": { 9234 * "send_to_voicemail": true, 9235 * "starred": false, 9236 * "pinned": 2 9237 * }, 9238 * "aggregation_data": [ 9239 * { 9240 * "type": "TOGETHER", 9241 * "contact_ids": [ 9242 * { 9243 * "account_type": "GOOGLE_ACCOUNT", 9244 * "account_name": "android-test2", 9245 * "contact_id": "2222222", 9246 * "data_set": "GOOGLE_PLUS" 9247 * }, 9248 * { 9249 * "account_type": "GOOGLE_ACCOUNT", 9250 * "account_name": "android-test3", 9251 * "contact_id": "3333333", 9252 * "data_set": "CUSTOM", 9253 * "custom_data_set": "custom type" 9254 * } 9255 * ] 9256 * } 9257 * ], 9258 * "field_data": [ 9259 * { 9260 * "field_data_id": "1001", 9261 * "field_data_prefs": { 9262 * "is_primary": true, 9263 * "is_super_primary": true 9264 * }, 9265 * "usage_stats": [ 9266 * { 9267 * "usage_type": "CALL", 9268 * "last_time_used": 10000001, 9269 * "usage_count": 10 9270 * } 9271 * ] 9272 * } 9273 * ] 9274 * } 9275 * </pre> 9276 */ 9277 public static final String DATA = "data"; 9278 9279 /** 9280 * The "deleted" flag: "0" by default, "1" if the row has been marked 9281 * for deletion. When {@link android.content.ContentResolver#delete} is 9282 * called on a raw contact, updating MetadataSync table to set the flag of the raw contact 9283 * as "1", then metadata sync adapter deletes the raw contact metadata on the server. 9284 * <P>Type: INTEGER</P> 9285 */ 9286 public static final String DELETED = "deleted"; 9287 } 9288 9289 /** 9290 * Constants for the metadata sync table. This table is used to cache the metadata_sync data 9291 * from server before it is merged into other CP2 tables. 9292 * 9293 * @hide 9294 */ 9295 @SystemApi 9296 public static final class MetadataSync implements BaseColumns, MetadataSyncColumns { 9297 9298 /** The authority for the contacts metadata */ 9299 public static final String METADATA_AUTHORITY = "com.android.contacts.metadata"; 9300 9301 /** A content:// style uri to the authority for the contacts metadata */ 9302 public static final Uri METADATA_AUTHORITY_URI = Uri.parse( 9303 "content://" + METADATA_AUTHORITY); 9304 9305 /** 9306 * This utility class cannot be instantiated 9307 */ 9308 private MetadataSync() { 9309 } 9310 9311 /** 9312 * The content:// style URI for this table. 9313 */ 9314 public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI, 9315 "metadata_sync"); 9316 9317 /** 9318 * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata 9319 */ 9320 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata"; 9321 9322 /** 9323 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata. 9324 */ 9325 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata"; 9326 } 9327 9328 /** 9329 * @hide 9330 */ 9331 @SystemApi 9332 protected interface MetadataSyncStateColumns { 9333 9334 /** 9335 * A reference to the name of the account to which this state belongs 9336 * <P>Type: STRING</P> 9337 */ 9338 public static final String ACCOUNT_TYPE = "account_type"; 9339 9340 /** 9341 * A reference to the type of the account to which this state belongs 9342 * <P>Type: STRING</P> 9343 */ 9344 public static final String ACCOUNT_NAME = "account_name"; 9345 9346 /** 9347 * A reference to the data set within the account to which this state belongs 9348 * <P>Type: STRING</P> 9349 */ 9350 public static final String DATA_SET = "data_set"; 9351 9352 /** 9353 * The sync state associated with this account. 9354 * <P>Type: Blob</P> 9355 */ 9356 public static final String STATE = "state"; 9357 } 9358 9359 /** 9360 * Constants for the metadata_sync_state table. This table is used to store the metadata 9361 * sync state for a set of accounts. 9362 * 9363 * @hide 9364 */ 9365 @SystemApi 9366 public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns { 9367 9368 /** 9369 * This utility class cannot be instantiated 9370 */ 9371 private MetadataSyncState() { 9372 } 9373 9374 /** 9375 * The content:// style URI for this table. 9376 */ 9377 public static final Uri CONTENT_URI = 9378 Uri.withAppendedPath(MetadataSync.METADATA_AUTHORITY_URI, "metadata_sync_state"); 9379 9380 /** 9381 * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata sync 9382 * states. 9383 */ 9384 public static final String CONTENT_TYPE = 9385 "vnd.android.cursor.dir/contact_metadata_sync_state"; 9386 9387 /** 9388 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata sync 9389 * state. 9390 */ 9391 public static final String CONTENT_ITEM_TYPE = 9392 "vnd.android.cursor.item/contact_metadata_sync_state"; 9393 } 9394} 9395