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