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