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