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