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