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