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