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