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