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