ContactsContract.java revision 0b0b8a8dae45e6f35d05da9c0d70c62cdf23fb20
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 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. 2941 * 2942 * @hide 2943 */ 2944 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; 2945 } 2946 2947 /** 2948 * Additional data mixed in with {@link StatusColumns} to link 2949 * back to specific {@link ContactsContract.Data#_ID} entries. 2950 * 2951 * @see StatusUpdates 2952 */ 2953 protected interface PresenceColumns { 2954 2955 /** 2956 * Reference to the {@link Data#_ID} entry that owns this presence. 2957 * <P>Type: INTEGER</P> 2958 */ 2959 public static final String DATA_ID = "presence_data_id"; 2960 2961 /** 2962 * See {@link CommonDataKinds.Im} for a list of defined protocol constants. 2963 * <p>Type: NUMBER</p> 2964 */ 2965 public static final String PROTOCOL = "protocol"; 2966 2967 /** 2968 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 2969 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 2970 * omitted if {@link #PROTOCOL} value is not 2971 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. 2972 * 2973 * <p>Type: NUMBER</p> 2974 */ 2975 public static final String CUSTOM_PROTOCOL = "custom_protocol"; 2976 2977 /** 2978 * The IM handle the presence item is for. The handle is scoped to 2979 * {@link #PROTOCOL}. 2980 * <P>Type: TEXT</P> 2981 */ 2982 public static final String IM_HANDLE = "im_handle"; 2983 2984 /** 2985 * The IM account for the local user that the presence data came from. 2986 * <P>Type: TEXT</P> 2987 */ 2988 public static final String IM_ACCOUNT = "im_account"; 2989 } 2990 2991 /** 2992 * <p> 2993 * A status update is linked to a {@link ContactsContract.Data} row and captures 2994 * the user's latest status update via the corresponding source, e.g. 2995 * "Having lunch" via "Google Talk". 2996 * </p> 2997 * <p> 2998 * There are two ways a status update can be inserted: by explicitly linking 2999 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row 3000 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 3001 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use 3002 * either. 3003 * </p> 3004 * <p> 3005 * You cannot use {@link ContentResolver#update} to change a status, but 3006 * {@link ContentResolver#insert} will replace the latests status if it already 3007 * exists. 3008 * </p> 3009 * <p> 3010 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses 3011 * for multiple contacts at once. 3012 * </p> 3013 * 3014 * <h3>Columns</h3> 3015 * <table class="jd-sumtable"> 3016 * <tr> 3017 * <th colspan='4'>StatusUpdates</th> 3018 * </tr> 3019 * <tr> 3020 * <td>long</td> 3021 * <td>{@link #DATA_ID}</td> 3022 * <td>read/write</td> 3023 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this 3024 * field is <i>not</i> specified, the provider will attempt to find a data row 3025 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 3026 * {@link #IM_HANDLE} columns. 3027 * </td> 3028 * </tr> 3029 * <tr> 3030 * <td>long</td> 3031 * <td>{@link #PROTOCOL}</td> 3032 * <td>read/write</td> 3033 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> 3034 * </tr> 3035 * <tr> 3036 * <td>String</td> 3037 * <td>{@link #CUSTOM_PROTOCOL}</td> 3038 * <td>read/write</td> 3039 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 3040 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 3041 * omitted if {@link #PROTOCOL} value is not 3042 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> 3043 * </tr> 3044 * <tr> 3045 * <td>String</td> 3046 * <td>{@link #IM_HANDLE}</td> 3047 * <td>read/write</td> 3048 * <td> The IM handle the presence item is for. The handle is scoped to 3049 * {@link #PROTOCOL}.</td> 3050 * </tr> 3051 * <tr> 3052 * <td>String</td> 3053 * <td>{@link #IM_ACCOUNT}</td> 3054 * <td>read/write</td> 3055 * <td>The IM account for the local user that the presence data came from.</td> 3056 * </tr> 3057 * <tr> 3058 * <td>int</td> 3059 * <td>{@link #PRESENCE}</td> 3060 * <td>read/write</td> 3061 * <td>Contact IM presence status. The allowed values are: 3062 * <p> 3063 * <ul> 3064 * <li>{@link #OFFLINE}</li> 3065 * <li>{@link #INVISIBLE}</li> 3066 * <li>{@link #AWAY}</li> 3067 * <li>{@link #IDLE}</li> 3068 * <li>{@link #DO_NOT_DISTURB}</li> 3069 * <li>{@link #AVAILABLE}</li> 3070 * </ul> 3071 * </p> 3072 * <p> 3073 * Since presence status is inherently volatile, the content provider 3074 * may choose not to store this field in long-term storage. 3075 * </p> 3076 * </td> 3077 * </tr> 3078 * <tr> 3079 * <td>String</td> 3080 * <td>{@link #STATUS}</td> 3081 * <td>read/write</td> 3082 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> 3083 * </tr> 3084 * <tr> 3085 * <td>long</td> 3086 * <td>{@link #STATUS_TIMESTAMP}</td> 3087 * <td>read/write</td> 3088 * <td>The absolute time in milliseconds when the status was 3089 * entered by the user. If this value is not provided, the provider will follow 3090 * this logic: if there was no prior status update, the value will be left as null. 3091 * If there was a prior status update, the provider will default this field 3092 * to the current time.</td> 3093 * </tr> 3094 * <tr> 3095 * <td>String</td> 3096 * <td>{@link #STATUS_RES_PACKAGE}</td> 3097 * <td>read/write</td> 3098 * <td> The package containing resources for this status: label and icon.</td> 3099 * </tr> 3100 * <tr> 3101 * <td>long</td> 3102 * <td>{@link #STATUS_LABEL}</td> 3103 * <td>read/write</td> 3104 * <td>The resource ID of the label describing the source of contact status, 3105 * e.g. "Google Talk". This resource is scoped by the 3106 * {@link #STATUS_RES_PACKAGE}.</td> 3107 * </tr> 3108 * <tr> 3109 * <td>long</td> 3110 * <td>{@link #STATUS_ICON}</td> 3111 * <td>read/write</td> 3112 * <td>The resource ID of the icon for the source of contact status. This 3113 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 3114 * </tr> 3115 * </table> 3116 */ 3117 public static class StatusUpdates implements StatusColumns, PresenceColumns { 3118 3119 /** 3120 * This utility class cannot be instantiated 3121 */ 3122 private StatusUpdates() {} 3123 3124 /** 3125 * The content:// style URI for this table 3126 */ 3127 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); 3128 3129 /** 3130 * Gets the resource ID for the proper presence icon. 3131 * 3132 * @param status the status to get the icon for 3133 * @return the resource ID for the proper presence icon 3134 */ 3135 public static final int getPresenceIconResourceId(int status) { 3136 switch (status) { 3137 case AVAILABLE: 3138 return android.R.drawable.presence_online; 3139 case IDLE: 3140 case AWAY: 3141 return android.R.drawable.presence_away; 3142 case DO_NOT_DISTURB: 3143 return android.R.drawable.presence_busy; 3144 case INVISIBLE: 3145 return android.R.drawable.presence_invisible; 3146 case OFFLINE: 3147 default: 3148 return android.R.drawable.presence_offline; 3149 } 3150 } 3151 3152 /** 3153 * Returns the precedence of the status code the higher number being the higher precedence. 3154 * 3155 * @param status The status code. 3156 * @return An integer representing the precedence, 0 being the lowest. 3157 */ 3158 public static final int getPresencePrecedence(int status) { 3159 // Keep this function here incase we want to enforce a different precedence than the 3160 // natural order of the status constants. 3161 return status; 3162 } 3163 3164 /** 3165 * The MIME type of {@link #CONTENT_URI} providing a directory of 3166 * status update details. 3167 */ 3168 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; 3169 3170 /** 3171 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 3172 * status update detail. 3173 */ 3174 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; 3175 } 3176 3177 /** 3178 * @deprecated This old name was never meant to be made public. Do not use. 3179 */ 3180 @Deprecated 3181 public static final class Presence extends StatusUpdates { 3182 3183 } 3184 3185 /** 3186 * Additional columns returned by the {@link Contacts#CONTENT_FILTER_URI} providing the 3187 * explanation of why the filter matched the contact. Specifically, they contain the 3188 * data type and element that was used for matching. 3189 * <p> 3190 * This is temporary API, it will need to change when we move to FTS. 3191 * 3192 * @hide 3193 */ 3194 public static class SearchSnippetColumns { 3195 3196 /** 3197 * The ID of the data row that was matched by the filter. 3198 * 3199 * @hide 3200 */ 3201 public static final String SNIPPET_DATA_ID = "snippet_data_id"; 3202 3203 /** 3204 * The type of data that was matched by the filter. 3205 * 3206 * @hide 3207 */ 3208 public static final String SNIPPET_MIMETYPE = "snippet_mimetype"; 3209 3210 /** 3211 * The {@link Data#DATA1} field of the data row that was matched by the filter. 3212 * 3213 * @hide 3214 */ 3215 public static final String SNIPPET_DATA1 = "snippet_data1"; 3216 3217 /** 3218 * The {@link Data#DATA2} field of the data row that was matched by the filter. 3219 * 3220 * @hide 3221 */ 3222 public static final String SNIPPET_DATA2 = "snippet_data2"; 3223 3224 /** 3225 * The {@link Data#DATA3} field of the data row that was matched by the filter. 3226 * 3227 * @hide 3228 */ 3229 public static final String SNIPPET_DATA3 = "snippet_data3"; 3230 3231 /** 3232 * The {@link Data#DATA4} field of the data row that was matched by the filter. 3233 * 3234 * @hide 3235 */ 3236 public static final String SNIPPET_DATA4 = "snippet_data4"; 3237 3238 } 3239 3240 /** 3241 * Container for definitions of common data types stored in the {@link ContactsContract.Data} 3242 * table. 3243 */ 3244 public static final class CommonDataKinds { 3245 /** 3246 * This utility class cannot be instantiated 3247 */ 3248 private CommonDataKinds() {} 3249 3250 /** 3251 * The {@link Data#RES_PACKAGE} value for common data that should be 3252 * shown using a default style. 3253 * 3254 * @hide RES_PACKAGE is hidden 3255 */ 3256 public static final String PACKAGE_COMMON = "common"; 3257 3258 /** 3259 * The base types that all "Typed" data kinds support. 3260 */ 3261 public interface BaseTypes { 3262 /** 3263 * A custom type. The custom label should be supplied by user. 3264 */ 3265 public static int TYPE_CUSTOM = 0; 3266 } 3267 3268 /** 3269 * Columns common across the specific types. 3270 */ 3271 protected interface CommonColumns extends BaseTypes { 3272 /** 3273 * The data for the contact method. 3274 * <P>Type: TEXT</P> 3275 */ 3276 public static final String DATA = DataColumns.DATA1; 3277 3278 /** 3279 * The type of data, for example Home or Work. 3280 * <P>Type: INTEGER</P> 3281 */ 3282 public static final String TYPE = DataColumns.DATA2; 3283 3284 /** 3285 * The user defined label for the the contact method. 3286 * <P>Type: TEXT</P> 3287 */ 3288 public static final String LABEL = DataColumns.DATA3; 3289 } 3290 3291 /** 3292 * A data kind representing the contact's proper name. You can use all 3293 * columns defined for {@link ContactsContract.Data} as well as the following aliases. 3294 * 3295 * <h2>Column aliases</h2> 3296 * <table class="jd-sumtable"> 3297 * <tr> 3298 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 3299 * </tr> 3300 * <tr> 3301 * <td>String</td> 3302 * <td>{@link #DISPLAY_NAME}</td> 3303 * <td>{@link #DATA1}</td> 3304 * <td></td> 3305 * </tr> 3306 * <tr> 3307 * <td>String</td> 3308 * <td>{@link #GIVEN_NAME}</td> 3309 * <td>{@link #DATA2}</td> 3310 * <td></td> 3311 * </tr> 3312 * <tr> 3313 * <td>String</td> 3314 * <td>{@link #FAMILY_NAME}</td> 3315 * <td>{@link #DATA3}</td> 3316 * <td></td> 3317 * </tr> 3318 * <tr> 3319 * <td>String</td> 3320 * <td>{@link #PREFIX}</td> 3321 * <td>{@link #DATA4}</td> 3322 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> 3323 * </tr> 3324 * <tr> 3325 * <td>String</td> 3326 * <td>{@link #MIDDLE_NAME}</td> 3327 * <td>{@link #DATA5}</td> 3328 * <td></td> 3329 * </tr> 3330 * <tr> 3331 * <td>String</td> 3332 * <td>{@link #SUFFIX}</td> 3333 * <td>{@link #DATA6}</td> 3334 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> 3335 * </tr> 3336 * <tr> 3337 * <td>String</td> 3338 * <td>{@link #PHONETIC_GIVEN_NAME}</td> 3339 * <td>{@link #DATA7}</td> 3340 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> 3341 * </tr> 3342 * <tr> 3343 * <td>String</td> 3344 * <td>{@link #PHONETIC_MIDDLE_NAME}</td> 3345 * <td>{@link #DATA8}</td> 3346 * <td></td> 3347 * </tr> 3348 * <tr> 3349 * <td>String</td> 3350 * <td>{@link #PHONETIC_FAMILY_NAME}</td> 3351 * <td>{@link #DATA9}</td> 3352 * <td></td> 3353 * </tr> 3354 * </table> 3355 */ 3356 public static final class StructuredName implements DataColumnsWithJoins { 3357 /** 3358 * This utility class cannot be instantiated 3359 */ 3360 private StructuredName() {} 3361 3362 /** MIME type used when storing this in data table. */ 3363 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; 3364 3365 /** 3366 * The name that should be used to display the contact. 3367 * <i>Unstructured component of the name should be consistent with 3368 * its structured representation.</i> 3369 * <p> 3370 * Type: TEXT 3371 */ 3372 public static final String DISPLAY_NAME = DATA1; 3373 3374 /** 3375 * The given name for the contact. 3376 * <P>Type: TEXT</P> 3377 */ 3378 public static final String GIVEN_NAME = DATA2; 3379 3380 /** 3381 * The family name for the contact. 3382 * <P>Type: TEXT</P> 3383 */ 3384 public static final String FAMILY_NAME = DATA3; 3385 3386 /** 3387 * The contact's honorific prefix, e.g. "Sir" 3388 * <P>Type: TEXT</P> 3389 */ 3390 public static final String PREFIX = DATA4; 3391 3392 /** 3393 * The contact's middle name 3394 * <P>Type: TEXT</P> 3395 */ 3396 public static final String MIDDLE_NAME = DATA5; 3397 3398 /** 3399 * The contact's honorific suffix, e.g. "Jr" 3400 */ 3401 public static final String SUFFIX = DATA6; 3402 3403 /** 3404 * The phonetic version of the given name for the contact. 3405 * <P>Type: TEXT</P> 3406 */ 3407 public static final String PHONETIC_GIVEN_NAME = DATA7; 3408 3409 /** 3410 * The phonetic version of the additional name for the contact. 3411 * <P>Type: TEXT</P> 3412 */ 3413 public static final String PHONETIC_MIDDLE_NAME = DATA8; 3414 3415 /** 3416 * The phonetic version of the family name for the contact. 3417 * <P>Type: TEXT</P> 3418 */ 3419 public static final String PHONETIC_FAMILY_NAME = DATA9; 3420 3421 /** 3422 * The style used for combining given/middle/family name into a full name. 3423 * See {@link ContactsContract.FullNameStyle}. 3424 * 3425 * @hide 3426 */ 3427 public static final String FULL_NAME_STYLE = DATA10; 3428 3429 /** 3430 * The alphabet used for capturing the phonetic name. 3431 * See ContactsContract.PhoneticNameStyle. 3432 * @hide 3433 */ 3434 public static final String PHONETIC_NAME_STYLE = DATA11; 3435 } 3436 3437 /** 3438 * <p>A data kind representing the contact's nickname. For example, for 3439 * Bob Parr ("Mr. Incredible"): 3440 * <pre> 3441 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 3442 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 3443 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 3444 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 3445 * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") 3446 * .build()); 3447 * 3448 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 3449 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 3450 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) 3451 * .withValue(Nickname.NAME, "Mr. Incredible") 3452 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) 3453 * .withValue(Nickname.LABEL, "Superhero") 3454 * .build()); 3455 * 3456 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 3457 * </pre> 3458 * </p> 3459 * <p> 3460 * You can use all columns defined for {@link ContactsContract.Data} as well as the 3461 * following aliases. 3462 * </p> 3463 * 3464 * <h2>Column aliases</h2> 3465 * <table class="jd-sumtable"> 3466 * <tr> 3467 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 3468 * </tr> 3469 * <tr> 3470 * <td>String</td> 3471 * <td>{@link #NAME}</td> 3472 * <td>{@link #DATA1}</td> 3473 * <td></td> 3474 * </tr> 3475 * <tr> 3476 * <td>int</td> 3477 * <td>{@link #TYPE}</td> 3478 * <td>{@link #DATA2}</td> 3479 * <td> 3480 * Allowed values are: 3481 * <p> 3482 * <ul> 3483 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3484 * <li>{@link #TYPE_DEFAULT}</li> 3485 * <li>{@link #TYPE_OTHER_NAME}</li> 3486 * <li>{@link #TYPE_MAINDEN_NAME}</li> 3487 * <li>{@link #TYPE_SHORT_NAME}</li> 3488 * <li>{@link #TYPE_INITIALS}</li> 3489 * </ul> 3490 * </p> 3491 * </td> 3492 * </tr> 3493 * <tr> 3494 * <td>String</td> 3495 * <td>{@link #LABEL}</td> 3496 * <td>{@link #DATA3}</td> 3497 * <td></td> 3498 * </tr> 3499 * </table> 3500 */ 3501 public static final class Nickname implements DataColumnsWithJoins, CommonColumns { 3502 /** 3503 * This utility class cannot be instantiated 3504 */ 3505 private Nickname() {} 3506 3507 /** MIME type used when storing this in data table. */ 3508 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; 3509 3510 public static final int TYPE_DEFAULT = 1; 3511 public static final int TYPE_OTHER_NAME = 2; 3512 public static final int TYPE_MAINDEN_NAME = 3; 3513 public static final int TYPE_SHORT_NAME = 4; 3514 public static final int TYPE_INITIALS = 5; 3515 3516 /** 3517 * The name itself 3518 */ 3519 public static final String NAME = DATA; 3520 } 3521 3522 /** 3523 * <p> 3524 * A data kind representing a telephone number. 3525 * </p> 3526 * <p> 3527 * You can use all columns defined for {@link ContactsContract.Data} as 3528 * well as the following aliases. 3529 * </p> 3530 * <h2>Column aliases</h2> 3531 * <table class="jd-sumtable"> 3532 * <tr> 3533 * <th>Type</th> 3534 * <th>Alias</th><th colspan='2'>Data column</th> 3535 * </tr> 3536 * <tr> 3537 * <td>String</td> 3538 * <td>{@link #NUMBER}</td> 3539 * <td>{@link #DATA1}</td> 3540 * <td></td> 3541 * </tr> 3542 * <tr> 3543 * <td>int</td> 3544 * <td>{@link #TYPE}</td> 3545 * <td>{@link #DATA2}</td> 3546 * <td>Allowed values are: 3547 * <p> 3548 * <ul> 3549 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3550 * <li>{@link #TYPE_HOME}</li> 3551 * <li>{@link #TYPE_MOBILE}</li> 3552 * <li>{@link #TYPE_WORK}</li> 3553 * <li>{@link #TYPE_FAX_WORK}</li> 3554 * <li>{@link #TYPE_FAX_HOME}</li> 3555 * <li>{@link #TYPE_PAGER}</li> 3556 * <li>{@link #TYPE_OTHER}</li> 3557 * <li>{@link #TYPE_CALLBACK}</li> 3558 * <li>{@link #TYPE_CAR}</li> 3559 * <li>{@link #TYPE_COMPANY_MAIN}</li> 3560 * <li>{@link #TYPE_ISDN}</li> 3561 * <li>{@link #TYPE_MAIN}</li> 3562 * <li>{@link #TYPE_OTHER_FAX}</li> 3563 * <li>{@link #TYPE_RADIO}</li> 3564 * <li>{@link #TYPE_TELEX}</li> 3565 * <li>{@link #TYPE_TTY_TDD}</li> 3566 * <li>{@link #TYPE_WORK_MOBILE}</li> 3567 * <li>{@link #TYPE_WORK_PAGER}</li> 3568 * <li>{@link #TYPE_ASSISTANT}</li> 3569 * <li>{@link #TYPE_MMS}</li> 3570 * </ul> 3571 * </p> 3572 * </td> 3573 * </tr> 3574 * <tr> 3575 * <td>String</td> 3576 * <td>{@link #LABEL}</td> 3577 * <td>{@link #DATA3}</td> 3578 * <td></td> 3579 * </tr> 3580 * </table> 3581 */ 3582 public static final class Phone implements DataColumnsWithJoins, CommonColumns { 3583 /** 3584 * This utility class cannot be instantiated 3585 */ 3586 private Phone() {} 3587 3588 /** MIME type used when storing this in data table. */ 3589 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2"; 3590 3591 /** 3592 * The MIME type of {@link #CONTENT_URI} providing a directory of 3593 * phones. 3594 */ 3595 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; 3596 3597 /** 3598 * The content:// style URI for all data records of the 3599 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 3600 * associated raw contact and aggregate contact data. 3601 */ 3602 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 3603 "phones"); 3604 3605 /** 3606 * The content:// style URL for phone lookup using a filter. The filter returns 3607 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 3608 * to display names as well as phone numbers. The filter argument should be passed 3609 * as an additional path segment after this URI. 3610 */ 3611 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 3612 "filter"); 3613 3614 public static final int TYPE_HOME = 1; 3615 public static final int TYPE_MOBILE = 2; 3616 public static final int TYPE_WORK = 3; 3617 public static final int TYPE_FAX_WORK = 4; 3618 public static final int TYPE_FAX_HOME = 5; 3619 public static final int TYPE_PAGER = 6; 3620 public static final int TYPE_OTHER = 7; 3621 public static final int TYPE_CALLBACK = 8; 3622 public static final int TYPE_CAR = 9; 3623 public static final int TYPE_COMPANY_MAIN = 10; 3624 public static final int TYPE_ISDN = 11; 3625 public static final int TYPE_MAIN = 12; 3626 public static final int TYPE_OTHER_FAX = 13; 3627 public static final int TYPE_RADIO = 14; 3628 public static final int TYPE_TELEX = 15; 3629 public static final int TYPE_TTY_TDD = 16; 3630 public static final int TYPE_WORK_MOBILE = 17; 3631 public static final int TYPE_WORK_PAGER = 18; 3632 public static final int TYPE_ASSISTANT = 19; 3633 public static final int TYPE_MMS = 20; 3634 3635 /** 3636 * The phone number as the user entered it. 3637 * <P>Type: TEXT</P> 3638 */ 3639 public static final String NUMBER = DATA; 3640 3641 /** 3642 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 3643 * @hide 3644 */ 3645 @Deprecated 3646 public static final CharSequence getDisplayLabel(Context context, int type, 3647 CharSequence label, CharSequence[] labelArray) { 3648 return getTypeLabel(context.getResources(), type, label); 3649 } 3650 3651 /** 3652 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 3653 * @hide 3654 */ 3655 @Deprecated 3656 public static final CharSequence getDisplayLabel(Context context, int type, 3657 CharSequence label) { 3658 return getTypeLabel(context.getResources(), type, label); 3659 } 3660 3661 /** 3662 * Return the string resource that best describes the given 3663 * {@link #TYPE}. Will always return a valid resource. 3664 */ 3665 public static final int getTypeLabelResource(int type) { 3666 switch (type) { 3667 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; 3668 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; 3669 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; 3670 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; 3671 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; 3672 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; 3673 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; 3674 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; 3675 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; 3676 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; 3677 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; 3678 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; 3679 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; 3680 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; 3681 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; 3682 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; 3683 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; 3684 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; 3685 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; 3686 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; 3687 default: return com.android.internal.R.string.phoneTypeCustom; 3688 } 3689 } 3690 3691 /** 3692 * Return a {@link CharSequence} that best describes the given type, 3693 * possibly substituting the given {@link #LABEL} value 3694 * for {@link #TYPE_CUSTOM}. 3695 */ 3696 public static final CharSequence getTypeLabel(Resources res, int type, 3697 CharSequence label) { 3698 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { 3699 return label; 3700 } else { 3701 final int labelRes = getTypeLabelResource(type); 3702 return res.getText(labelRes); 3703 } 3704 } 3705 } 3706 3707 /** 3708 * <p> 3709 * A data kind representing an email address. 3710 * </p> 3711 * <p> 3712 * You can use all columns defined for {@link ContactsContract.Data} as 3713 * well as the following aliases. 3714 * </p> 3715 * <h2>Column aliases</h2> 3716 * <table class="jd-sumtable"> 3717 * <tr> 3718 * <th>Type</th> 3719 * <th>Alias</th><th colspan='2'>Data column</th> 3720 * </tr> 3721 * <tr> 3722 * <td>String</td> 3723 * <td>{@link #DATA}</td> 3724 * <td>{@link #DATA1}</td> 3725 * <td>Email address itself.</td> 3726 * </tr> 3727 * <tr> 3728 * <td>int</td> 3729 * <td>{@link #TYPE}</td> 3730 * <td>{@link #DATA2}</td> 3731 * <td>Allowed values are: 3732 * <p> 3733 * <ul> 3734 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3735 * <li>{@link #TYPE_HOME}</li> 3736 * <li>{@link #TYPE_WORK}</li> 3737 * <li>{@link #TYPE_OTHER}</li> 3738 * <li>{@link #TYPE_MOBILE}</li> 3739 * </ul> 3740 * </p> 3741 * </td> 3742 * </tr> 3743 * <tr> 3744 * <td>String</td> 3745 * <td>{@link #LABEL}</td> 3746 * <td>{@link #DATA3}</td> 3747 * <td></td> 3748 * </tr> 3749 * </table> 3750 */ 3751 public static final class Email implements DataColumnsWithJoins, CommonColumns { 3752 /** 3753 * This utility class cannot be instantiated 3754 */ 3755 private Email() {} 3756 3757 /** MIME type used when storing this in data table. */ 3758 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2"; 3759 3760 /** 3761 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. 3762 */ 3763 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; 3764 3765 /** 3766 * The content:// style URI for all data records of the 3767 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 3768 * associated raw contact and aggregate contact data. 3769 */ 3770 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 3771 "emails"); 3772 3773 /** 3774 * <p> 3775 * The content:// style URL for looking up data rows by email address. The 3776 * lookup argument, an email address, should be passed as an additional path segment 3777 * after this URI. 3778 * </p> 3779 * <p>Example: 3780 * <pre> 3781 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); 3782 * Cursor c = getContentResolver().query(uri, 3783 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, 3784 * null, null, null); 3785 * </pre> 3786 * </p> 3787 */ 3788 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, 3789 "lookup"); 3790 3791 /** 3792 * <p> 3793 * The content:// style URL for email lookup using a filter. The filter returns 3794 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 3795 * to display names as well as email addresses. The filter argument should be passed 3796 * as an additional path segment after this URI. 3797 * </p> 3798 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" 3799 * as well as "Bob Parr (incredible@android.com)". 3800 * <pre> 3801 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); 3802 * Cursor c = getContentResolver().query(uri, 3803 * new String[]{Email.DISPLAY_NAME, Email.DATA}, 3804 * null, null, null); 3805 * </pre> 3806 * </p> 3807 */ 3808 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 3809 "filter"); 3810 3811 /** 3812 * The email address. 3813 * <P>Type: TEXT</P> 3814 * @hide TODO: Unhide in a separate CL 3815 */ 3816 public static final String ADDRESS = DATA1; 3817 3818 public static final int TYPE_HOME = 1; 3819 public static final int TYPE_WORK = 2; 3820 public static final int TYPE_OTHER = 3; 3821 public static final int TYPE_MOBILE = 4; 3822 3823 /** 3824 * The display name for the email address 3825 * <P>Type: TEXT</P> 3826 */ 3827 public static final String DISPLAY_NAME = DATA4; 3828 3829 /** 3830 * Return the string resource that best describes the given 3831 * {@link #TYPE}. Will always return a valid resource. 3832 */ 3833 public static final int getTypeLabelResource(int type) { 3834 switch (type) { 3835 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; 3836 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; 3837 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; 3838 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; 3839 default: return com.android.internal.R.string.emailTypeCustom; 3840 } 3841 } 3842 3843 /** 3844 * Return a {@link CharSequence} that best describes the given type, 3845 * possibly substituting the given {@link #LABEL} value 3846 * for {@link #TYPE_CUSTOM}. 3847 */ 3848 public static final CharSequence getTypeLabel(Resources res, int type, 3849 CharSequence label) { 3850 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 3851 return label; 3852 } else { 3853 final int labelRes = getTypeLabelResource(type); 3854 return res.getText(labelRes); 3855 } 3856 } 3857 } 3858 3859 /** 3860 * <p> 3861 * A data kind representing a postal addresses. 3862 * </p> 3863 * <p> 3864 * You can use all columns defined for {@link ContactsContract.Data} as 3865 * well as the following aliases. 3866 * </p> 3867 * <h2>Column aliases</h2> 3868 * <table class="jd-sumtable"> 3869 * <tr> 3870 * <th>Type</th> 3871 * <th>Alias</th><th colspan='2'>Data column</th> 3872 * </tr> 3873 * <tr> 3874 * <td>String</td> 3875 * <td>{@link #FORMATTED_ADDRESS}</td> 3876 * <td>{@link #DATA1}</td> 3877 * <td></td> 3878 * </tr> 3879 * <tr> 3880 * <td>int</td> 3881 * <td>{@link #TYPE}</td> 3882 * <td>{@link #DATA2}</td> 3883 * <td>Allowed values are: 3884 * <p> 3885 * <ul> 3886 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3887 * <li>{@link #TYPE_HOME}</li> 3888 * <li>{@link #TYPE_WORK}</li> 3889 * <li>{@link #TYPE_OTHER}</li> 3890 * </ul> 3891 * </p> 3892 * </td> 3893 * </tr> 3894 * <tr> 3895 * <td>String</td> 3896 * <td>{@link #LABEL}</td> 3897 * <td>{@link #DATA3}</td> 3898 * <td></td> 3899 * </tr> 3900 * <tr> 3901 * <td>String</td> 3902 * <td>{@link #STREET}</td> 3903 * <td>{@link #DATA4}</td> 3904 * <td></td> 3905 * </tr> 3906 * <tr> 3907 * <td>String</td> 3908 * <td>{@link #POBOX}</td> 3909 * <td>{@link #DATA5}</td> 3910 * <td>Post Office Box number</td> 3911 * </tr> 3912 * <tr> 3913 * <td>String</td> 3914 * <td>{@link #NEIGHBORHOOD}</td> 3915 * <td>{@link #DATA6}</td> 3916 * <td></td> 3917 * </tr> 3918 * <tr> 3919 * <td>String</td> 3920 * <td>{@link #CITY}</td> 3921 * <td>{@link #DATA7}</td> 3922 * <td></td> 3923 * </tr> 3924 * <tr> 3925 * <td>String</td> 3926 * <td>{@link #REGION}</td> 3927 * <td>{@link #DATA8}</td> 3928 * <td></td> 3929 * </tr> 3930 * <tr> 3931 * <td>String</td> 3932 * <td>{@link #POSTCODE}</td> 3933 * <td>{@link #DATA9}</td> 3934 * <td></td> 3935 * </tr> 3936 * <tr> 3937 * <td>String</td> 3938 * <td>{@link #COUNTRY}</td> 3939 * <td>{@link #DATA10}</td> 3940 * <td></td> 3941 * </tr> 3942 * </table> 3943 */ 3944 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns { 3945 /** 3946 * This utility class cannot be instantiated 3947 */ 3948 private StructuredPostal() { 3949 } 3950 3951 /** MIME type used when storing this in data table. */ 3952 public static final String CONTENT_ITEM_TYPE = 3953 "vnd.android.cursor.item/postal-address_v2"; 3954 3955 /** 3956 * The MIME type of {@link #CONTENT_URI} providing a directory of 3957 * postal addresses. 3958 */ 3959 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2"; 3960 3961 /** 3962 * The content:// style URI for all data records of the 3963 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. 3964 */ 3965 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 3966 "postals"); 3967 3968 public static final int TYPE_HOME = 1; 3969 public static final int TYPE_WORK = 2; 3970 public static final int TYPE_OTHER = 3; 3971 3972 /** 3973 * The full, unstructured postal address. <i>This field must be 3974 * consistent with any structured data.</i> 3975 * <p> 3976 * Type: TEXT 3977 */ 3978 public static final String FORMATTED_ADDRESS = DATA; 3979 3980 /** 3981 * Can be street, avenue, road, etc. This element also includes the 3982 * house number and room/apartment/flat/floor number. 3983 * <p> 3984 * Type: TEXT 3985 */ 3986 public static final String STREET = DATA4; 3987 3988 /** 3989 * Covers actual P.O. boxes, drawers, locked bags, etc. This is 3990 * usually but not always mutually exclusive with street. 3991 * <p> 3992 * Type: TEXT 3993 */ 3994 public static final String POBOX = DATA5; 3995 3996 /** 3997 * This is used to disambiguate a street address when a city 3998 * contains more than one street with the same name, or to specify a 3999 * small place whose mail is routed through a larger postal town. In 4000 * China it could be a county or a minor city. 4001 * <p> 4002 * Type: TEXT 4003 */ 4004 public static final String NEIGHBORHOOD = DATA6; 4005 4006 /** 4007 * Can be city, village, town, borough, etc. This is the postal town 4008 * and not necessarily the place of residence or place of business. 4009 * <p> 4010 * Type: TEXT 4011 */ 4012 public static final String CITY = DATA7; 4013 4014 /** 4015 * A state, province, county (in Ireland), Land (in Germany), 4016 * departement (in France), etc. 4017 * <p> 4018 * Type: TEXT 4019 */ 4020 public static final String REGION = DATA8; 4021 4022 /** 4023 * Postal code. Usually country-wide, but sometimes specific to the 4024 * city (e.g. "2" in "Dublin 2, Ireland" addresses). 4025 * <p> 4026 * Type: TEXT 4027 */ 4028 public static final String POSTCODE = DATA9; 4029 4030 /** 4031 * The name or code of the country. 4032 * <p> 4033 * Type: TEXT 4034 */ 4035 public static final String COUNTRY = DATA10; 4036 4037 /** 4038 * Return the string resource that best describes the given 4039 * {@link #TYPE}. Will always return a valid resource. 4040 */ 4041 public static final int getTypeLabelResource(int type) { 4042 switch (type) { 4043 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; 4044 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; 4045 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; 4046 default: return com.android.internal.R.string.postalTypeCustom; 4047 } 4048 } 4049 4050 /** 4051 * Return a {@link CharSequence} that best describes the given type, 4052 * possibly substituting the given {@link #LABEL} value 4053 * for {@link #TYPE_CUSTOM}. 4054 */ 4055 public static final CharSequence getTypeLabel(Resources res, int type, 4056 CharSequence label) { 4057 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 4058 return label; 4059 } else { 4060 final int labelRes = getTypeLabelResource(type); 4061 return res.getText(labelRes); 4062 } 4063 } 4064 } 4065 4066 /** 4067 * <p> 4068 * A data kind representing an IM address 4069 * </p> 4070 * <p> 4071 * You can use all columns defined for {@link ContactsContract.Data} as 4072 * well as the following aliases. 4073 * </p> 4074 * <h2>Column aliases</h2> 4075 * <table class="jd-sumtable"> 4076 * <tr> 4077 * <th>Type</th> 4078 * <th>Alias</th><th colspan='2'>Data column</th> 4079 * </tr> 4080 * <tr> 4081 * <td>String</td> 4082 * <td>{@link #DATA}</td> 4083 * <td>{@link #DATA1}</td> 4084 * <td></td> 4085 * </tr> 4086 * <tr> 4087 * <td>int</td> 4088 * <td>{@link #TYPE}</td> 4089 * <td>{@link #DATA2}</td> 4090 * <td>Allowed values are: 4091 * <p> 4092 * <ul> 4093 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4094 * <li>{@link #TYPE_HOME}</li> 4095 * <li>{@link #TYPE_WORK}</li> 4096 * <li>{@link #TYPE_OTHER}</li> 4097 * </ul> 4098 * </p> 4099 * </td> 4100 * </tr> 4101 * <tr> 4102 * <td>String</td> 4103 * <td>{@link #LABEL}</td> 4104 * <td>{@link #DATA3}</td> 4105 * <td></td> 4106 * </tr> 4107 * <tr> 4108 * <td>String</td> 4109 * <td>{@link #PROTOCOL}</td> 4110 * <td>{@link #DATA5}</td> 4111 * <td> 4112 * <p> 4113 * Allowed values: 4114 * <ul> 4115 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name 4116 * as {@link #CUSTOM_PROTOCOL}.</li> 4117 * <li>{@link #PROTOCOL_AIM}</li> 4118 * <li>{@link #PROTOCOL_MSN}</li> 4119 * <li>{@link #PROTOCOL_YAHOO}</li> 4120 * <li>{@link #PROTOCOL_SKYPE}</li> 4121 * <li>{@link #PROTOCOL_QQ}</li> 4122 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> 4123 * <li>{@link #PROTOCOL_ICQ}</li> 4124 * <li>{@link #PROTOCOL_JABBER}</li> 4125 * <li>{@link #PROTOCOL_NETMEETING}</li> 4126 * </ul> 4127 * </p> 4128 * </td> 4129 * </tr> 4130 * <tr> 4131 * <td>String</td> 4132 * <td>{@link #CUSTOM_PROTOCOL}</td> 4133 * <td>{@link #DATA6}</td> 4134 * <td></td> 4135 * </tr> 4136 * </table> 4137 */ 4138 public static final class Im implements DataColumnsWithJoins, CommonColumns { 4139 /** 4140 * This utility class cannot be instantiated 4141 */ 4142 private Im() {} 4143 4144 /** MIME type used when storing this in data table. */ 4145 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; 4146 4147 public static final int TYPE_HOME = 1; 4148 public static final int TYPE_WORK = 2; 4149 public static final int TYPE_OTHER = 3; 4150 4151 /** 4152 * This column should be populated with one of the defined 4153 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this 4154 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} 4155 * should contain the name of the custom protocol. 4156 */ 4157 public static final String PROTOCOL = DATA5; 4158 4159 public static final String CUSTOM_PROTOCOL = DATA6; 4160 4161 /* 4162 * The predefined IM protocol types. 4163 */ 4164 public static final int PROTOCOL_CUSTOM = -1; 4165 public static final int PROTOCOL_AIM = 0; 4166 public static final int PROTOCOL_MSN = 1; 4167 public static final int PROTOCOL_YAHOO = 2; 4168 public static final int PROTOCOL_SKYPE = 3; 4169 public static final int PROTOCOL_QQ = 4; 4170 public static final int PROTOCOL_GOOGLE_TALK = 5; 4171 public static final int PROTOCOL_ICQ = 6; 4172 public static final int PROTOCOL_JABBER = 7; 4173 public static final int PROTOCOL_NETMEETING = 8; 4174 4175 /** 4176 * Return the string resource that best describes the given 4177 * {@link #TYPE}. Will always return a valid resource. 4178 */ 4179 public static final int getTypeLabelResource(int type) { 4180 switch (type) { 4181 case TYPE_HOME: return com.android.internal.R.string.imTypeHome; 4182 case TYPE_WORK: return com.android.internal.R.string.imTypeWork; 4183 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; 4184 default: return com.android.internal.R.string.imTypeCustom; 4185 } 4186 } 4187 4188 /** 4189 * Return a {@link CharSequence} that best describes the given type, 4190 * possibly substituting the given {@link #LABEL} value 4191 * for {@link #TYPE_CUSTOM}. 4192 */ 4193 public static final CharSequence getTypeLabel(Resources res, int type, 4194 CharSequence label) { 4195 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 4196 return label; 4197 } else { 4198 final int labelRes = getTypeLabelResource(type); 4199 return res.getText(labelRes); 4200 } 4201 } 4202 4203 /** 4204 * Return the string resource that best describes the given 4205 * {@link #PROTOCOL}. Will always return a valid resource. 4206 */ 4207 public static final int getProtocolLabelResource(int type) { 4208 switch (type) { 4209 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; 4210 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; 4211 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; 4212 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; 4213 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; 4214 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; 4215 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; 4216 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; 4217 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; 4218 default: return com.android.internal.R.string.imProtocolCustom; 4219 } 4220 } 4221 4222 /** 4223 * Return a {@link CharSequence} that best describes the given 4224 * protocol, possibly substituting the given 4225 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. 4226 */ 4227 public static final CharSequence getProtocolLabel(Resources res, int type, 4228 CharSequence label) { 4229 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { 4230 return label; 4231 } else { 4232 final int labelRes = getProtocolLabelResource(type); 4233 return res.getText(labelRes); 4234 } 4235 } 4236 } 4237 4238 /** 4239 * <p> 4240 * A data kind representing an organization. 4241 * </p> 4242 * <p> 4243 * You can use all columns defined for {@link ContactsContract.Data} as 4244 * well as the following aliases. 4245 * </p> 4246 * <h2>Column aliases</h2> 4247 * <table class="jd-sumtable"> 4248 * <tr> 4249 * <th>Type</th> 4250 * <th>Alias</th><th colspan='2'>Data column</th> 4251 * </tr> 4252 * <tr> 4253 * <td>String</td> 4254 * <td>{@link #COMPANY}</td> 4255 * <td>{@link #DATA1}</td> 4256 * <td></td> 4257 * </tr> 4258 * <tr> 4259 * <td>int</td> 4260 * <td>{@link #TYPE}</td> 4261 * <td>{@link #DATA2}</td> 4262 * <td>Allowed values are: 4263 * <p> 4264 * <ul> 4265 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4266 * <li>{@link #TYPE_WORK}</li> 4267 * <li>{@link #TYPE_OTHER}</li> 4268 * </ul> 4269 * </p> 4270 * </td> 4271 * </tr> 4272 * <tr> 4273 * <td>String</td> 4274 * <td>{@link #LABEL}</td> 4275 * <td>{@link #DATA3}</td> 4276 * <td></td> 4277 * </tr> 4278 * <tr> 4279 * <td>String</td> 4280 * <td>{@link #TITLE}</td> 4281 * <td>{@link #DATA4}</td> 4282 * <td></td> 4283 * </tr> 4284 * <tr> 4285 * <td>String</td> 4286 * <td>{@link #DEPARTMENT}</td> 4287 * <td>{@link #DATA5}</td> 4288 * <td></td> 4289 * </tr> 4290 * <tr> 4291 * <td>String</td> 4292 * <td>{@link #JOB_DESCRIPTION}</td> 4293 * <td>{@link #DATA6}</td> 4294 * <td></td> 4295 * </tr> 4296 * <tr> 4297 * <td>String</td> 4298 * <td>{@link #SYMBOL}</td> 4299 * <td>{@link #DATA7}</td> 4300 * <td></td> 4301 * </tr> 4302 * <tr> 4303 * <td>String</td> 4304 * <td>{@link #PHONETIC_NAME}</td> 4305 * <td>{@link #DATA8}</td> 4306 * <td></td> 4307 * </tr> 4308 * <tr> 4309 * <td>String</td> 4310 * <td>{@link #OFFICE_LOCATION}</td> 4311 * <td>{@link #DATA9}</td> 4312 * <td></td> 4313 * </tr> 4314 * <tr> 4315 * <td>String</td> 4316 * <td>PHONETIC_NAME_STYLE</td> 4317 * <td>{@link #DATA10}</td> 4318 * <td></td> 4319 * </tr> 4320 * </table> 4321 */ 4322 public static final class Organization implements DataColumnsWithJoins, CommonColumns { 4323 /** 4324 * This utility class cannot be instantiated 4325 */ 4326 private Organization() {} 4327 4328 /** MIME type used when storing this in data table. */ 4329 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; 4330 4331 public static final int TYPE_WORK = 1; 4332 public static final int TYPE_OTHER = 2; 4333 4334 /** 4335 * The company as the user entered it. 4336 * <P>Type: TEXT</P> 4337 */ 4338 public static final String COMPANY = DATA; 4339 4340 /** 4341 * The position title at this company as the user entered it. 4342 * <P>Type: TEXT</P> 4343 */ 4344 public static final String TITLE = DATA4; 4345 4346 /** 4347 * The department at this company as the user entered it. 4348 * <P>Type: TEXT</P> 4349 */ 4350 public static final String DEPARTMENT = DATA5; 4351 4352 /** 4353 * The job description at this company as the user entered it. 4354 * <P>Type: TEXT</P> 4355 */ 4356 public static final String JOB_DESCRIPTION = DATA6; 4357 4358 /** 4359 * The symbol of this company as the user entered it. 4360 * <P>Type: TEXT</P> 4361 */ 4362 public static final String SYMBOL = DATA7; 4363 4364 /** 4365 * The phonetic name of this company as the user entered it. 4366 * <P>Type: TEXT</P> 4367 */ 4368 public static final String PHONETIC_NAME = DATA8; 4369 4370 /** 4371 * The office location of this organization. 4372 * <P>Type: TEXT</P> 4373 */ 4374 public static final String OFFICE_LOCATION = DATA9; 4375 4376 /** 4377 * The alphabet used for capturing the phonetic name. 4378 * See {@link ContactsContract.PhoneticNameStyle}. 4379 * @hide 4380 */ 4381 public static final String PHONETIC_NAME_STYLE = DATA10; 4382 4383 /** 4384 * Return the string resource that best describes the given 4385 * {@link #TYPE}. Will always return a valid resource. 4386 */ 4387 public static final int getTypeLabelResource(int type) { 4388 switch (type) { 4389 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; 4390 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; 4391 default: return com.android.internal.R.string.orgTypeCustom; 4392 } 4393 } 4394 4395 /** 4396 * Return a {@link CharSequence} that best describes the given type, 4397 * possibly substituting the given {@link #LABEL} value 4398 * for {@link #TYPE_CUSTOM}. 4399 */ 4400 public static final CharSequence getTypeLabel(Resources res, int type, 4401 CharSequence label) { 4402 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 4403 return label; 4404 } else { 4405 final int labelRes = getTypeLabelResource(type); 4406 return res.getText(labelRes); 4407 } 4408 } 4409 } 4410 4411 /** 4412 * <p> 4413 * A data kind representing a relation. 4414 * </p> 4415 * <p> 4416 * You can use all columns defined for {@link ContactsContract.Data} as 4417 * well as the following aliases. 4418 * </p> 4419 * <h2>Column aliases</h2> 4420 * <table class="jd-sumtable"> 4421 * <tr> 4422 * <th>Type</th> 4423 * <th>Alias</th><th colspan='2'>Data column</th> 4424 * </tr> 4425 * <tr> 4426 * <td>String</td> 4427 * <td>{@link #NAME}</td> 4428 * <td>{@link #DATA1}</td> 4429 * <td></td> 4430 * </tr> 4431 * <tr> 4432 * <td>int</td> 4433 * <td>{@link #TYPE}</td> 4434 * <td>{@link #DATA2}</td> 4435 * <td>Allowed values are: 4436 * <p> 4437 * <ul> 4438 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4439 * <li>{@link #TYPE_ASSISTANT}</li> 4440 * <li>{@link #TYPE_BROTHER}</li> 4441 * <li>{@link #TYPE_CHILD}</li> 4442 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> 4443 * <li>{@link #TYPE_FATHER}</li> 4444 * <li>{@link #TYPE_FRIEND}</li> 4445 * <li>{@link #TYPE_MANAGER}</li> 4446 * <li>{@link #TYPE_MOTHER}</li> 4447 * <li>{@link #TYPE_PARENT}</li> 4448 * <li>{@link #TYPE_PARTNER}</li> 4449 * <li>{@link #TYPE_REFERRED_BY}</li> 4450 * <li>{@link #TYPE_RELATIVE}</li> 4451 * <li>{@link #TYPE_SISTER}</li> 4452 * <li>{@link #TYPE_SPOUSE}</li> 4453 * </ul> 4454 * </p> 4455 * </td> 4456 * </tr> 4457 * <tr> 4458 * <td>String</td> 4459 * <td>{@link #LABEL}</td> 4460 * <td>{@link #DATA3}</td> 4461 * <td></td> 4462 * </tr> 4463 * </table> 4464 */ 4465 public static final class Relation implements DataColumnsWithJoins, CommonColumns { 4466 /** 4467 * This utility class cannot be instantiated 4468 */ 4469 private Relation() {} 4470 4471 /** MIME type used when storing this in data table. */ 4472 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; 4473 4474 public static final int TYPE_ASSISTANT = 1; 4475 public static final int TYPE_BROTHER = 2; 4476 public static final int TYPE_CHILD = 3; 4477 public static final int TYPE_DOMESTIC_PARTNER = 4; 4478 public static final int TYPE_FATHER = 5; 4479 public static final int TYPE_FRIEND = 6; 4480 public static final int TYPE_MANAGER = 7; 4481 public static final int TYPE_MOTHER = 8; 4482 public static final int TYPE_PARENT = 9; 4483 public static final int TYPE_PARTNER = 10; 4484 public static final int TYPE_REFERRED_BY = 11; 4485 public static final int TYPE_RELATIVE = 12; 4486 public static final int TYPE_SISTER = 13; 4487 public static final int TYPE_SPOUSE = 14; 4488 4489 /** 4490 * The name of the relative as the user entered it. 4491 * <P>Type: TEXT</P> 4492 */ 4493 public static final String NAME = DATA; 4494 } 4495 4496 /** 4497 * <p> 4498 * A data kind representing an event. 4499 * </p> 4500 * <p> 4501 * You can use all columns defined for {@link ContactsContract.Data} as 4502 * well as the following aliases. 4503 * </p> 4504 * <h2>Column aliases</h2> 4505 * <table class="jd-sumtable"> 4506 * <tr> 4507 * <th>Type</th> 4508 * <th>Alias</th><th colspan='2'>Data column</th> 4509 * </tr> 4510 * <tr> 4511 * <td>String</td> 4512 * <td>{@link #START_DATE}</td> 4513 * <td>{@link #DATA1}</td> 4514 * <td></td> 4515 * </tr> 4516 * <tr> 4517 * <td>int</td> 4518 * <td>{@link #TYPE}</td> 4519 * <td>{@link #DATA2}</td> 4520 * <td>Allowed values are: 4521 * <p> 4522 * <ul> 4523 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4524 * <li>{@link #TYPE_ANNIVERSARY}</li> 4525 * <li>{@link #TYPE_OTHER}</li> 4526 * <li>{@link #TYPE_BIRTHDAY}</li> 4527 * </ul> 4528 * </p> 4529 * </td> 4530 * </tr> 4531 * <tr> 4532 * <td>String</td> 4533 * <td>{@link #LABEL}</td> 4534 * <td>{@link #DATA3}</td> 4535 * <td></td> 4536 * </tr> 4537 * </table> 4538 */ 4539 public static final class Event implements DataColumnsWithJoins, CommonColumns { 4540 /** 4541 * This utility class cannot be instantiated 4542 */ 4543 private Event() {} 4544 4545 /** MIME type used when storing this in data table. */ 4546 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event"; 4547 4548 public static final int TYPE_ANNIVERSARY = 1; 4549 public static final int TYPE_OTHER = 2; 4550 public static final int TYPE_BIRTHDAY = 3; 4551 4552 /** 4553 * The event start date as the user entered it. 4554 * <P>Type: TEXT</P> 4555 */ 4556 public static final String START_DATE = DATA; 4557 4558 /** 4559 * Return the string resource that best describes the given 4560 * {@link #TYPE}. Will always return a valid resource. 4561 */ 4562 public static int getTypeResource(Integer type) { 4563 if (type == null) { 4564 return com.android.internal.R.string.eventTypeOther; 4565 } 4566 switch (type) { 4567 case TYPE_ANNIVERSARY: 4568 return com.android.internal.R.string.eventTypeAnniversary; 4569 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; 4570 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; 4571 default: return com.android.internal.R.string.eventTypeOther; 4572 } 4573 } 4574 } 4575 4576 /** 4577 * <p> 4578 * A data kind representing an photo for the contact. 4579 * </p> 4580 * <p> 4581 * Some sync adapters will choose to download photos in a separate 4582 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} 4583 * through {@link ContactsContract.Data#SYNC4} to store temporary 4584 * data, e.g. the image URL or ID, state of download, server-side version 4585 * of the image. It is allowed for the {@link #PHOTO} to be null. 4586 * </p> 4587 * <p> 4588 * You can use all columns defined for {@link ContactsContract.Data} as 4589 * well as the following aliases. 4590 * </p> 4591 * <h2>Column aliases</h2> 4592 * <table class="jd-sumtable"> 4593 * <tr> 4594 * <th>Type</th> 4595 * <th>Alias</th><th colspan='2'>Data column</th> 4596 * </tr> 4597 * <tr> 4598 * <td>BLOB</td> 4599 * <td>{@link #PHOTO}</td> 4600 * <td>{@link #DATA15}</td> 4601 * <td>By convention, binary data is stored in DATA15.</td> 4602 * </tr> 4603 * </table> 4604 */ 4605 public static final class Photo implements DataColumnsWithJoins { 4606 /** 4607 * This utility class cannot be instantiated 4608 */ 4609 private Photo() {} 4610 4611 /** MIME type used when storing this in data table. */ 4612 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; 4613 4614 /** 4615 * Thumbnail photo of the raw contact. This is the raw bytes of an image 4616 * that could be inflated using {@link android.graphics.BitmapFactory}. 4617 * <p> 4618 * Type: BLOB 4619 */ 4620 public static final String PHOTO = DATA15; 4621 } 4622 4623 /** 4624 * <p> 4625 * Notes about the contact. 4626 * </p> 4627 * <p> 4628 * You can use all columns defined for {@link ContactsContract.Data} as 4629 * well as the following aliases. 4630 * </p> 4631 * <h2>Column aliases</h2> 4632 * <table class="jd-sumtable"> 4633 * <tr> 4634 * <th>Type</th> 4635 * <th>Alias</th><th colspan='2'>Data column</th> 4636 * </tr> 4637 * <tr> 4638 * <td>String</td> 4639 * <td>{@link #NOTE}</td> 4640 * <td>{@link #DATA1}</td> 4641 * <td></td> 4642 * </tr> 4643 * </table> 4644 */ 4645 public static final class Note implements DataColumnsWithJoins { 4646 /** 4647 * This utility class cannot be instantiated 4648 */ 4649 private Note() {} 4650 4651 /** MIME type used when storing this in data table. */ 4652 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; 4653 4654 /** 4655 * The note text. 4656 * <P>Type: TEXT</P> 4657 */ 4658 public static final String NOTE = DATA1; 4659 } 4660 4661 /** 4662 * <p> 4663 * Group Membership. 4664 * </p> 4665 * <p> 4666 * You can use all columns defined for {@link ContactsContract.Data} as 4667 * well as the following aliases. 4668 * </p> 4669 * <h2>Column aliases</h2> 4670 * <table class="jd-sumtable"> 4671 * <tr> 4672 * <th>Type</th> 4673 * <th>Alias</th><th colspan='2'>Data column</th> 4674 * </tr> 4675 * <tr> 4676 * <td>long</td> 4677 * <td>{@link #GROUP_ROW_ID}</td> 4678 * <td>{@link #DATA1}</td> 4679 * <td></td> 4680 * </tr> 4681 * <tr> 4682 * <td>String</td> 4683 * <td>{@link #GROUP_SOURCE_ID}</td> 4684 * <td>none</td> 4685 * <td> 4686 * <p> 4687 * The sourceid of the group that this group membership refers to. 4688 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when 4689 * inserting a row. 4690 * </p> 4691 * <p> 4692 * If this field is specified, the provider will first try to 4693 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group 4694 * is found, it will use the corresponding row id. If the group is not 4695 * found, it will create one. 4696 * </td> 4697 * </tr> 4698 * </table> 4699 */ 4700 public static final class GroupMembership implements DataColumnsWithJoins { 4701 /** 4702 * This utility class cannot be instantiated 4703 */ 4704 private GroupMembership() {} 4705 4706 /** MIME type used when storing this in data table. */ 4707 public static final String CONTENT_ITEM_TYPE = 4708 "vnd.android.cursor.item/group_membership"; 4709 4710 /** 4711 * The row id of the group that this group membership refers to. Exactly one of 4712 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. 4713 * <P>Type: INTEGER</P> 4714 */ 4715 public static final String GROUP_ROW_ID = DATA1; 4716 4717 /** 4718 * The sourceid of the group that this group membership refers to. Exactly one of 4719 * this or {@link #GROUP_ROW_ID} must be set when inserting a row. 4720 * <P>Type: TEXT</P> 4721 */ 4722 public static final String GROUP_SOURCE_ID = "group_sourceid"; 4723 } 4724 4725 /** 4726 * <p> 4727 * A data kind representing a website related to the contact. 4728 * </p> 4729 * <p> 4730 * You can use all columns defined for {@link ContactsContract.Data} as 4731 * well as the following aliases. 4732 * </p> 4733 * <h2>Column aliases</h2> 4734 * <table class="jd-sumtable"> 4735 * <tr> 4736 * <th>Type</th> 4737 * <th>Alias</th><th colspan='2'>Data column</th> 4738 * </tr> 4739 * <tr> 4740 * <td>String</td> 4741 * <td>{@link #URL}</td> 4742 * <td>{@link #DATA1}</td> 4743 * <td></td> 4744 * </tr> 4745 * <tr> 4746 * <td>int</td> 4747 * <td>{@link #TYPE}</td> 4748 * <td>{@link #DATA2}</td> 4749 * <td>Allowed values are: 4750 * <p> 4751 * <ul> 4752 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4753 * <li>{@link #TYPE_HOMEPAGE}</li> 4754 * <li>{@link #TYPE_BLOG}</li> 4755 * <li>{@link #TYPE_PROFILE}</li> 4756 * <li>{@link #TYPE_HOME}</li> 4757 * <li>{@link #TYPE_WORK}</li> 4758 * <li>{@link #TYPE_FTP}</li> 4759 * <li>{@link #TYPE_OTHER}</li> 4760 * </ul> 4761 * </p> 4762 * </td> 4763 * </tr> 4764 * <tr> 4765 * <td>String</td> 4766 * <td>{@link #LABEL}</td> 4767 * <td>{@link #DATA3}</td> 4768 * <td></td> 4769 * </tr> 4770 * </table> 4771 */ 4772 public static final class Website implements DataColumnsWithJoins, CommonColumns { 4773 /** 4774 * This utility class cannot be instantiated 4775 */ 4776 private Website() {} 4777 4778 /** MIME type used when storing this in data table. */ 4779 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; 4780 4781 public static final int TYPE_HOMEPAGE = 1; 4782 public static final int TYPE_BLOG = 2; 4783 public static final int TYPE_PROFILE = 3; 4784 public static final int TYPE_HOME = 4; 4785 public static final int TYPE_WORK = 5; 4786 public static final int TYPE_FTP = 6; 4787 public static final int TYPE_OTHER = 7; 4788 4789 /** 4790 * The website URL string. 4791 * <P>Type: TEXT</P> 4792 */ 4793 public static final String URL = DATA; 4794 } 4795 } 4796 4797 /** 4798 * @see Groups 4799 */ 4800 protected interface GroupsColumns { 4801 /** 4802 * The display title of this group. 4803 * <p> 4804 * Type: TEXT 4805 */ 4806 public static final String TITLE = "title"; 4807 4808 /** 4809 * The package name to use when creating {@link Resources} objects for 4810 * this group. This value is only designed for use when building user 4811 * interfaces, and should not be used to infer the owner. 4812 * 4813 * @hide 4814 */ 4815 public static final String RES_PACKAGE = "res_package"; 4816 4817 /** 4818 * The display title of this group to load as a resource from 4819 * {@link #RES_PACKAGE}, which may be localized. 4820 * <P>Type: TEXT</P> 4821 * 4822 * @hide 4823 */ 4824 public static final String TITLE_RES = "title_res"; 4825 4826 /** 4827 * Notes about the group. 4828 * <p> 4829 * Type: TEXT 4830 */ 4831 public static final String NOTES = "notes"; 4832 4833 /** 4834 * The ID of this group if it is a System Group, i.e. a group that has a special meaning 4835 * to the sync adapter, null otherwise. 4836 * <P>Type: TEXT</P> 4837 */ 4838 public static final String SYSTEM_ID = "system_id"; 4839 4840 /** 4841 * The total number of {@link Contacts} that have 4842 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only 4843 * present when querying {@link Groups#CONTENT_SUMMARY_URI}. 4844 * <p> 4845 * Type: INTEGER 4846 */ 4847 public static final String SUMMARY_COUNT = "summ_count"; 4848 4849 /** 4850 * The total number of {@link Contacts} that have both 4851 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. 4852 * Read-only value that is only present when querying 4853 * {@link Groups#CONTENT_SUMMARY_URI}. 4854 * <p> 4855 * Type: INTEGER 4856 */ 4857 public static final String SUMMARY_WITH_PHONES = "summ_phones"; 4858 4859 /** 4860 * Flag indicating if the contacts belonging to this group should be 4861 * visible in any user interface. 4862 * <p> 4863 * Type: INTEGER (boolean) 4864 */ 4865 public static final String GROUP_VISIBLE = "group_visible"; 4866 4867 /** 4868 * The "deleted" flag: "0" by default, "1" if the row has been marked 4869 * for deletion. When {@link android.content.ContentResolver#delete} is 4870 * called on a group, it is marked for deletion. The sync adaptor 4871 * deletes the group on the server and then calls ContactResolver.delete 4872 * once more, this time setting the the 4873 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to 4874 * finalize the data removal. 4875 * <P>Type: INTEGER</P> 4876 */ 4877 public static final String DELETED = "deleted"; 4878 4879 /** 4880 * Whether this group should be synced if the SYNC_EVERYTHING settings 4881 * is false for this group's account. 4882 * <p> 4883 * Type: INTEGER (boolean) 4884 */ 4885 public static final String SHOULD_SYNC = "should_sync"; 4886 } 4887 4888 /** 4889 * Constants for the groups table. Only per-account groups are supported. 4890 * <h2>Columns</h2> 4891 * <table class="jd-sumtable"> 4892 * <tr> 4893 * <th colspan='4'>Groups</th> 4894 * </tr> 4895 * <tr> 4896 * <td>long</td> 4897 * <td>{@link #_ID}</td> 4898 * <td>read-only</td> 4899 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. 4900 * In other words, it would be a really bad idea to delete and reinsert a 4901 * group. A sync adapter should always do an update instead.</td> 4902 * </tr> 4903 * <tr> 4904 * <td>String</td> 4905 * <td>{@link #TITLE}</td> 4906 * <td>read/write</td> 4907 * <td>The display title of this group.</td> 4908 * </tr> 4909 * <tr> 4910 * <td>String</td> 4911 * <td>{@link #NOTES}</td> 4912 * <td>read/write</td> 4913 * <td>Notes about the group.</td> 4914 * </tr> 4915 * <tr> 4916 * <td>String</td> 4917 * <td>{@link #SYSTEM_ID}</td> 4918 * <td>read/write</td> 4919 * <td>The ID of this group if it is a System Group, i.e. a group that has a 4920 * special meaning to the sync adapter, null otherwise.</td> 4921 * </tr> 4922 * <tr> 4923 * <td>int</td> 4924 * <td>{@link #SUMMARY_COUNT}</td> 4925 * <td>read-only</td> 4926 * <td>The total number of {@link Contacts} that have 4927 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value 4928 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> 4929 * </tr> 4930 * <tr> 4931 * <td>int</td> 4932 * <td>{@link #SUMMARY_WITH_PHONES}</td> 4933 * <td>read-only</td> 4934 * <td>The total number of {@link Contacts} that have both 4935 * {@link CommonDataKinds.GroupMembership} in this group, and also have 4936 * phone numbers. Read-only value that is only present when querying 4937 * {@link Groups#CONTENT_SUMMARY_URI}.</td> 4938 * </tr> 4939 * <tr> 4940 * <td>int</td> 4941 * <td>{@link #GROUP_VISIBLE}</td> 4942 * <td>read-only</td> 4943 * <td>Flag indicating if the contacts belonging to this group should be 4944 * visible in any user interface. Allowed values: 0 and 1.</td> 4945 * </tr> 4946 * <tr> 4947 * <td>int</td> 4948 * <td>{@link #DELETED}</td> 4949 * <td>read/write</td> 4950 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked 4951 * for deletion. When {@link android.content.ContentResolver#delete} is 4952 * called on a group, it is marked for deletion. The sync adaptor deletes 4953 * the group on the server and then calls ContactResolver.delete once more, 4954 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} 4955 * query parameter to finalize the data removal.</td> 4956 * </tr> 4957 * <tr> 4958 * <td>int</td> 4959 * <td>{@link #SHOULD_SYNC}</td> 4960 * <td>read/write</td> 4961 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings 4962 * is false for this group's account.</td> 4963 * </tr> 4964 * </table> 4965 */ 4966 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { 4967 /** 4968 * This utility class cannot be instantiated 4969 */ 4970 private Groups() { 4971 } 4972 4973 /** 4974 * The content:// style URI for this table 4975 */ 4976 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); 4977 4978 /** 4979 * The content:// style URI for this table joined with details data from 4980 * {@link ContactsContract.Data}. 4981 */ 4982 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, 4983 "groups_summary"); 4984 4985 /** 4986 * The MIME type of a directory of groups. 4987 */ 4988 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; 4989 4990 /** 4991 * The MIME type of a single group. 4992 */ 4993 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; 4994 4995 public static EntityIterator newEntityIterator(Cursor cursor) { 4996 return new EntityIteratorImpl(cursor); 4997 } 4998 4999 private static class EntityIteratorImpl extends CursorEntityIterator { 5000 public EntityIteratorImpl(Cursor cursor) { 5001 super(cursor); 5002 } 5003 5004 @Override 5005 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { 5006 // we expect the cursor is already at the row we need to read from 5007 final ContentValues values = new ContentValues(); 5008 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); 5009 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); 5010 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); 5011 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); 5012 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); 5013 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); 5014 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); 5015 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); 5016 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); 5017 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); 5018 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); 5019 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); 5020 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); 5021 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); 5022 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); 5023 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); 5024 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); 5025 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); 5026 cursor.moveToNext(); 5027 return new Entity(values); 5028 } 5029 } 5030 } 5031 5032 /** 5033 * <p> 5034 * Constants for the contact aggregation exceptions table, which contains 5035 * aggregation rules overriding those used by automatic aggregation. This 5036 * type only supports query and update. Neither insert nor delete are 5037 * supported. 5038 * </p> 5039 * <h2>Columns</h2> 5040 * <table class="jd-sumtable"> 5041 * <tr> 5042 * <th colspan='4'>AggregationExceptions</th> 5043 * </tr> 5044 * <tr> 5045 * <td>int</td> 5046 * <td>{@link #TYPE}</td> 5047 * <td>read/write</td> 5048 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, 5049 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> 5050 * </tr> 5051 * <tr> 5052 * <td>long</td> 5053 * <td>{@link #RAW_CONTACT_ID1}</td> 5054 * <td>read/write</td> 5055 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that 5056 * the rule applies to.</td> 5057 * </tr> 5058 * <tr> 5059 * <td>long</td> 5060 * <td>{@link #RAW_CONTACT_ID2}</td> 5061 * <td>read/write</td> 5062 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact 5063 * that the rule applies to.</td> 5064 * </tr> 5065 * </table> 5066 */ 5067 public static final class AggregationExceptions implements BaseColumns { 5068 /** 5069 * This utility class cannot be instantiated 5070 */ 5071 private AggregationExceptions() {} 5072 5073 /** 5074 * The content:// style URI for this table 5075 */ 5076 public static final Uri CONTENT_URI = 5077 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); 5078 5079 /** 5080 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 5081 */ 5082 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; 5083 5084 /** 5085 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception 5086 */ 5087 public static final String CONTENT_ITEM_TYPE = 5088 "vnd.android.cursor.item/aggregation_exception"; 5089 5090 /** 5091 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or 5092 * {@link #TYPE_AUTOMATIC}. 5093 * 5094 * <P>Type: INTEGER</P> 5095 */ 5096 public static final String TYPE = "type"; 5097 5098 /** 5099 * Allows the provider to automatically decide whether the specified raw contacts should 5100 * be included in the same aggregate contact or not. 5101 */ 5102 public static final int TYPE_AUTOMATIC = 0; 5103 5104 /** 5105 * Makes sure that the specified raw contacts are included in the same 5106 * aggregate contact. 5107 */ 5108 public static final int TYPE_KEEP_TOGETHER = 1; 5109 5110 /** 5111 * Makes sure that the specified raw contacts are NOT included in the same 5112 * aggregate contact. 5113 */ 5114 public static final int TYPE_KEEP_SEPARATE = 2; 5115 5116 /** 5117 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. 5118 */ 5119 public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; 5120 5121 /** 5122 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule 5123 * applies to. 5124 */ 5125 public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; 5126 } 5127 5128 /** 5129 * @see Settings 5130 */ 5131 protected interface SettingsColumns { 5132 /** 5133 * The name of the account instance to which this row belongs. 5134 * <P>Type: TEXT</P> 5135 */ 5136 public static final String ACCOUNT_NAME = "account_name"; 5137 5138 /** 5139 * The type of account to which this row belongs, which when paired with 5140 * {@link #ACCOUNT_NAME} identifies a specific account. 5141 * <P>Type: TEXT</P> 5142 */ 5143 public static final String ACCOUNT_TYPE = "account_type"; 5144 5145 /** 5146 * Depending on the mode defined by the sync-adapter, this flag controls 5147 * the top-level sync behavior for this data source. 5148 * <p> 5149 * Type: INTEGER (boolean) 5150 */ 5151 public static final String SHOULD_SYNC = "should_sync"; 5152 5153 /** 5154 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} 5155 * entries should be visible in any user interface. 5156 * <p> 5157 * Type: INTEGER (boolean) 5158 */ 5159 public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; 5160 5161 /** 5162 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any 5163 * {@link Groups#SHOULD_SYNC} under this account have been marked as 5164 * unsynced. 5165 */ 5166 public static final String ANY_UNSYNCED = "any_unsynced"; 5167 5168 /** 5169 * Read-only count of {@link Contacts} from a specific source that have 5170 * no {@link CommonDataKinds.GroupMembership} entries. 5171 * <p> 5172 * Type: INTEGER 5173 */ 5174 public static final String UNGROUPED_COUNT = "summ_count"; 5175 5176 /** 5177 * Read-only count of {@link Contacts} from a specific source that have 5178 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. 5179 * <p> 5180 * Type: INTEGER 5181 */ 5182 public static final String UNGROUPED_WITH_PHONES = "summ_phones"; 5183 } 5184 5185 /** 5186 * <p> 5187 * Contacts-specific settings for various {@link Account}'s. 5188 * </p> 5189 * <h2>Columns</h2> 5190 * <table class="jd-sumtable"> 5191 * <tr> 5192 * <th colspan='4'>Settings</th> 5193 * </tr> 5194 * <tr> 5195 * <td>String</td> 5196 * <td>{@link #ACCOUNT_NAME}</td> 5197 * <td>read/write-once</td> 5198 * <td>The name of the account instance to which this row belongs.</td> 5199 * </tr> 5200 * <tr> 5201 * <td>String</td> 5202 * <td>{@link #ACCOUNT_TYPE}</td> 5203 * <td>read/write-once</td> 5204 * <td>The type of account to which this row belongs, which when paired with 5205 * {@link #ACCOUNT_NAME} identifies a specific account.</td> 5206 * </tr> 5207 * <tr> 5208 * <td>int</td> 5209 * <td>{@link #SHOULD_SYNC}</td> 5210 * <td>read/write</td> 5211 * <td>Depending on the mode defined by the sync-adapter, this flag controls 5212 * the top-level sync behavior for this data source.</td> 5213 * </tr> 5214 * <tr> 5215 * <td>int</td> 5216 * <td>{@link #UNGROUPED_VISIBLE}</td> 5217 * <td>read/write</td> 5218 * <td>Flag indicating if contacts without any 5219 * {@link CommonDataKinds.GroupMembership} entries should be visible in any 5220 * user interface.</td> 5221 * </tr> 5222 * <tr> 5223 * <td>int</td> 5224 * <td>{@link #ANY_UNSYNCED}</td> 5225 * <td>read-only</td> 5226 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any 5227 * {@link Groups#SHOULD_SYNC} under this account have been marked as 5228 * unsynced.</td> 5229 * </tr> 5230 * <tr> 5231 * <td>int</td> 5232 * <td>{@link #UNGROUPED_COUNT}</td> 5233 * <td>read-only</td> 5234 * <td>Read-only count of {@link Contacts} from a specific source that have 5235 * no {@link CommonDataKinds.GroupMembership} entries.</td> 5236 * </tr> 5237 * <tr> 5238 * <td>int</td> 5239 * <td>{@link #UNGROUPED_WITH_PHONES}</td> 5240 * <td>read-only</td> 5241 * <td>Read-only count of {@link Contacts} from a specific source that have 5242 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone 5243 * numbers.</td> 5244 * </tr> 5245 * </table> 5246 */ 5247 5248 public static final class Settings implements SettingsColumns { 5249 /** 5250 * This utility class cannot be instantiated 5251 */ 5252 private Settings() { 5253 } 5254 5255 /** 5256 * The content:// style URI for this table 5257 */ 5258 public static final Uri CONTENT_URI = 5259 Uri.withAppendedPath(AUTHORITY_URI, "settings"); 5260 5261 /** 5262 * The MIME-type of {@link #CONTENT_URI} providing a directory of 5263 * settings. 5264 */ 5265 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; 5266 5267 /** 5268 * The MIME-type of {@link #CONTENT_URI} providing a single setting. 5269 */ 5270 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; 5271 } 5272 5273 /** 5274 * Helper methods to display QuickContact dialogs that allow users to pivot on 5275 * a specific {@link Contacts} entry. 5276 */ 5277 public static final class QuickContact { 5278 /** 5279 * Action used to trigger person pivot dialog. 5280 * @hide 5281 */ 5282 public static final String ACTION_QUICK_CONTACT = 5283 "com.android.contacts.action.QUICK_CONTACT"; 5284 5285 /** 5286 * Extra used to specify pivot dialog location in screen coordinates. 5287 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. 5288 * @hide 5289 */ 5290 @Deprecated 5291 public static final String EXTRA_TARGET_RECT = "target_rect"; 5292 5293 /** 5294 * Extra used to specify size of pivot dialog. 5295 * @hide 5296 */ 5297 public static final String EXTRA_MODE = "mode"; 5298 5299 /** 5300 * Extra used to indicate a list of specific MIME-types to exclude and 5301 * not display. Stored as a {@link String} array. 5302 * @hide 5303 */ 5304 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; 5305 5306 /** 5307 * Small QuickContact mode, usually presented with minimal actions. 5308 */ 5309 public static final int MODE_SMALL = 1; 5310 5311 /** 5312 * Medium QuickContact mode, includes actions and light summary describing 5313 * the {@link Contacts} entry being shown. This may include social 5314 * status and presence details. 5315 */ 5316 public static final int MODE_MEDIUM = 2; 5317 5318 /** 5319 * Large QuickContact mode, includes actions and larger, card-like summary 5320 * of the {@link Contacts} entry being shown. This may include detailed 5321 * information, such as a photo. 5322 */ 5323 public static final int MODE_LARGE = 3; 5324 5325 /** 5326 * Trigger a dialog that lists the various methods of interacting with 5327 * the requested {@link Contacts} entry. This may be based on available 5328 * {@link ContactsContract.Data} rows under that contact, and may also 5329 * include social status and presence details. 5330 * 5331 * @param context The parent {@link Context} that may be used as the 5332 * parent for this dialog. 5333 * @param target Specific {@link View} from your layout that this dialog 5334 * should be centered around. In particular, if the dialog 5335 * has a "callout" arrow, it will be pointed and centered 5336 * around this {@link View}. 5337 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 5338 * {@link Uri} that describes a specific contact to feature 5339 * in this dialog. 5340 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 5341 * {@link #MODE_LARGE}, indicating the desired dialog size, 5342 * when supported. 5343 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 5344 * to exclude when showing this dialog. For example, when 5345 * already viewing the contact details card, this can be used 5346 * to omit the details entry from the dialog. 5347 */ 5348 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, 5349 String[] excludeMimes) { 5350 // Find location and bounds of target view, adjusting based on the 5351 // assumed local density. 5352 final float appScale = context.getResources().getCompatibilityInfo().applicationScale; 5353 final int[] pos = new int[2]; 5354 target.getLocationOnScreen(pos); 5355 5356 final Rect rect = new Rect(); 5357 rect.left = (int) (pos[0] * appScale + 0.5f); 5358 rect.top = (int) (pos[1] * appScale + 0.5f); 5359 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); 5360 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); 5361 5362 // Trigger with obtained rectangle 5363 showQuickContact(context, rect, lookupUri, mode, excludeMimes); 5364 } 5365 5366 /** 5367 * Trigger a dialog that lists the various methods of interacting with 5368 * the requested {@link Contacts} entry. This may be based on available 5369 * {@link ContactsContract.Data} rows under that contact, and may also 5370 * include social status and presence details. 5371 * 5372 * @param context The parent {@link Context} that may be used as the 5373 * parent for this dialog. 5374 * @param target Specific {@link Rect} that this dialog should be 5375 * centered around, in screen coordinates. In particular, if 5376 * the dialog has a "callout" arrow, it will be pointed and 5377 * centered around this {@link Rect}. If you are running at a 5378 * non-native density, you need to manually adjust using 5379 * {@link DisplayMetrics#density} before calling. 5380 * @param lookupUri A 5381 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 5382 * {@link Uri} that describes a specific contact to feature 5383 * in this dialog. 5384 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 5385 * {@link #MODE_LARGE}, indicating the desired dialog size, 5386 * when supported. 5387 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 5388 * to exclude when showing this dialog. For example, when 5389 * already viewing the contact details card, this can be used 5390 * to omit the details entry from the dialog. 5391 */ 5392 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, 5393 String[] excludeMimes) { 5394 // Launch pivot dialog through intent for now 5395 final Intent intent = new Intent(ACTION_QUICK_CONTACT); 5396 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP 5397 | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 5398 5399 intent.setData(lookupUri); 5400 intent.setSourceBounds(target); 5401 intent.putExtra(EXTRA_MODE, mode); 5402 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); 5403 context.startActivity(intent); 5404 } 5405 } 5406 5407 /** 5408 * Contains helper classes used to create or manage {@link android.content.Intent Intents} 5409 * that involve contacts. 5410 */ 5411 public static final class Intents { 5412 /** 5413 * This is the intent that is fired when a search suggestion is clicked on. 5414 */ 5415 public static final String SEARCH_SUGGESTION_CLICKED = 5416 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; 5417 5418 /** 5419 * This is the intent that is fired when a search suggestion for dialing a number 5420 * is clicked on. 5421 */ 5422 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = 5423 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; 5424 5425 /** 5426 * This is the intent that is fired when a search suggestion for creating a contact 5427 * is clicked on. 5428 */ 5429 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = 5430 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; 5431 5432 /** 5433 * Starts an Activity that lets the user pick a contact to attach an image to. 5434 * After picking the contact it launches the image cropper in face detection mode. 5435 */ 5436 public static final String ATTACH_IMAGE = 5437 "com.android.contacts.action.ATTACH_IMAGE"; 5438 5439 /** 5440 * Takes as input a data URI with a mailto: or tel: scheme. If a single 5441 * contact exists with the given data it will be shown. If no contact 5442 * exists, a dialog will ask the user if they want to create a new 5443 * contact with the provided details filled in. If multiple contacts 5444 * share the data the user will be prompted to pick which contact they 5445 * want to view. 5446 * <p> 5447 * For <code>mailto:</code> URIs, the scheme specific portion must be a 5448 * raw email address, such as one built using 5449 * {@link Uri#fromParts(String, String, String)}. 5450 * <p> 5451 * For <code>tel:</code> URIs, the scheme specific portion is compared 5452 * to existing numbers using the standard caller ID lookup algorithm. 5453 * The number must be properly encoded, for example using 5454 * {@link Uri#fromParts(String, String, String)}. 5455 * <p> 5456 * Any extras from the {@link Insert} class will be passed along to the 5457 * create activity if there are no contacts to show. 5458 * <p> 5459 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip 5460 * prompting the user when the contact doesn't exist. 5461 */ 5462 public static final String SHOW_OR_CREATE_CONTACT = 5463 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; 5464 5465 /** 5466 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new 5467 * contact if no matching contact found. Otherwise, default behavior is 5468 * to prompt user with dialog before creating. 5469 * <p> 5470 * Type: BOOLEAN 5471 */ 5472 public static final String EXTRA_FORCE_CREATE = 5473 "com.android.contacts.action.FORCE_CREATE"; 5474 5475 /** 5476 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact 5477 * description to be shown when prompting user about creating a new 5478 * contact. 5479 * <p> 5480 * Type: STRING 5481 */ 5482 public static final String EXTRA_CREATE_DESCRIPTION = 5483 "com.android.contacts.action.CREATE_DESCRIPTION"; 5484 5485 /** 5486 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 5487 * dialog location using screen coordinates. When not specified, the 5488 * dialog will be centered. 5489 * 5490 * @hide 5491 */ 5492 @Deprecated 5493 public static final String EXTRA_TARGET_RECT = "target_rect"; 5494 5495 /** 5496 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 5497 * desired dialog style, usually a variation on size. One of 5498 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. 5499 * 5500 * @hide 5501 */ 5502 @Deprecated 5503 public static final String EXTRA_MODE = "mode"; 5504 5505 /** 5506 * Value for {@link #EXTRA_MODE} to show a small-sized dialog. 5507 * 5508 * @hide 5509 */ 5510 @Deprecated 5511 public static final int MODE_SMALL = 1; 5512 5513 /** 5514 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. 5515 * 5516 * @hide 5517 */ 5518 @Deprecated 5519 public static final int MODE_MEDIUM = 2; 5520 5521 /** 5522 * Value for {@link #EXTRA_MODE} to show a large-sized dialog. 5523 * 5524 * @hide 5525 */ 5526 @Deprecated 5527 public static final int MODE_LARGE = 3; 5528 5529 /** 5530 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate 5531 * a list of specific MIME-types to exclude and not display. Stored as a 5532 * {@link String} array. 5533 * 5534 * @hide 5535 */ 5536 @Deprecated 5537 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; 5538 5539 /** 5540 * Intents related to the Contacts app UI. 5541 * 5542 * @hide 5543 */ 5544 public static final class UI { 5545 /** 5546 * The action for the default contacts list tab. 5547 */ 5548 public static final String LIST_DEFAULT = 5549 "com.android.contacts.action.LIST_DEFAULT"; 5550 5551 /** 5552 * The action for the contacts list tab. 5553 */ 5554 public static final String LIST_GROUP_ACTION = 5555 "com.android.contacts.action.LIST_GROUP"; 5556 5557 /** 5558 * When in LIST_GROUP_ACTION mode, this is the group to display. 5559 */ 5560 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; 5561 5562 /** 5563 * The action for the all contacts list tab. 5564 */ 5565 public static final String LIST_ALL_CONTACTS_ACTION = 5566 "com.android.contacts.action.LIST_ALL_CONTACTS"; 5567 5568 /** 5569 * The action for the contacts with phone numbers list tab. 5570 */ 5571 public static final String LIST_CONTACTS_WITH_PHONES_ACTION = 5572 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; 5573 5574 /** 5575 * The action for the starred contacts list tab. 5576 */ 5577 public static final String LIST_STARRED_ACTION = 5578 "com.android.contacts.action.LIST_STARRED"; 5579 5580 /** 5581 * The action for the frequent contacts list tab. 5582 */ 5583 public static final String LIST_FREQUENT_ACTION = 5584 "com.android.contacts.action.LIST_FREQUENT"; 5585 5586 /** 5587 * The action for the "strequent" contacts list tab. It first lists the starred 5588 * contacts in alphabetical order and then the frequent contacts in descending 5589 * order of the number of times they have been contacted. 5590 */ 5591 public static final String LIST_STREQUENT_ACTION = 5592 "com.android.contacts.action.LIST_STREQUENT"; 5593 5594 /** 5595 * A key for to be used as an intent extra to set the activity 5596 * title to a custom String value. 5597 */ 5598 public static final String TITLE_EXTRA_KEY = 5599 "com.android.contacts.extra.TITLE_EXTRA"; 5600 5601 /** 5602 * Activity Action: Display a filtered list of contacts 5603 * <p> 5604 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for 5605 * filtering 5606 * <p> 5607 * Output: Nothing. 5608 */ 5609 public static final String FILTER_CONTACTS_ACTION = 5610 "com.android.contacts.action.FILTER_CONTACTS"; 5611 5612 /** 5613 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} 5614 * intents to supply the text on which to filter. 5615 */ 5616 public static final String FILTER_TEXT_EXTRA_KEY = 5617 "com.android.contacts.extra.FILTER_TEXT"; 5618 } 5619 5620 /** 5621 * Convenience class that contains string constants used 5622 * to create contact {@link android.content.Intent Intents}. 5623 */ 5624 public static final class Insert { 5625 /** The action code to use when adding a contact */ 5626 public static final String ACTION = Intent.ACTION_INSERT; 5627 5628 /** 5629 * If present, forces a bypass of quick insert mode. 5630 */ 5631 public static final String FULL_MODE = "full_mode"; 5632 5633 /** 5634 * The extra field for the contact name. 5635 * <P>Type: String</P> 5636 */ 5637 public static final String NAME = "name"; 5638 5639 // TODO add structured name values here. 5640 5641 /** 5642 * The extra field for the contact phonetic name. 5643 * <P>Type: String</P> 5644 */ 5645 public static final String PHONETIC_NAME = "phonetic_name"; 5646 5647 /** 5648 * The extra field for the contact company. 5649 * <P>Type: String</P> 5650 */ 5651 public static final String COMPANY = "company"; 5652 5653 /** 5654 * The extra field for the contact job title. 5655 * <P>Type: String</P> 5656 */ 5657 public static final String JOB_TITLE = "job_title"; 5658 5659 /** 5660 * The extra field for the contact notes. 5661 * <P>Type: String</P> 5662 */ 5663 public static final String NOTES = "notes"; 5664 5665 /** 5666 * The extra field for the contact phone number. 5667 * <P>Type: String</P> 5668 */ 5669 public static final String PHONE = "phone"; 5670 5671 /** 5672 * The extra field for the contact phone number type. 5673 * <P>Type: Either an integer value from 5674 * {@link CommonDataKinds.Phone}, 5675 * or a string specifying a custom label.</P> 5676 */ 5677 public static final String PHONE_TYPE = "phone_type"; 5678 5679 /** 5680 * The extra field for the phone isprimary flag. 5681 * <P>Type: boolean</P> 5682 */ 5683 public static final String PHONE_ISPRIMARY = "phone_isprimary"; 5684 5685 /** 5686 * The extra field for an optional second contact phone number. 5687 * <P>Type: String</P> 5688 */ 5689 public static final String SECONDARY_PHONE = "secondary_phone"; 5690 5691 /** 5692 * The extra field for an optional second contact phone number type. 5693 * <P>Type: Either an integer value from 5694 * {@link CommonDataKinds.Phone}, 5695 * or a string specifying a custom label.</P> 5696 */ 5697 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; 5698 5699 /** 5700 * The extra field for an optional third contact phone number. 5701 * <P>Type: String</P> 5702 */ 5703 public static final String TERTIARY_PHONE = "tertiary_phone"; 5704 5705 /** 5706 * The extra field for an optional third contact phone number type. 5707 * <P>Type: Either an integer value from 5708 * {@link CommonDataKinds.Phone}, 5709 * or a string specifying a custom label.</P> 5710 */ 5711 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; 5712 5713 /** 5714 * The extra field for the contact email address. 5715 * <P>Type: String</P> 5716 */ 5717 public static final String EMAIL = "email"; 5718 5719 /** 5720 * The extra field for the contact email type. 5721 * <P>Type: Either an integer value from 5722 * {@link CommonDataKinds.Email} 5723 * or a string specifying a custom label.</P> 5724 */ 5725 public static final String EMAIL_TYPE = "email_type"; 5726 5727 /** 5728 * The extra field for the email isprimary flag. 5729 * <P>Type: boolean</P> 5730 */ 5731 public static final String EMAIL_ISPRIMARY = "email_isprimary"; 5732 5733 /** 5734 * The extra field for an optional second contact email address. 5735 * <P>Type: String</P> 5736 */ 5737 public static final String SECONDARY_EMAIL = "secondary_email"; 5738 5739 /** 5740 * The extra field for an optional second contact email type. 5741 * <P>Type: Either an integer value from 5742 * {@link CommonDataKinds.Email} 5743 * or a string specifying a custom label.</P> 5744 */ 5745 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; 5746 5747 /** 5748 * The extra field for an optional third contact email address. 5749 * <P>Type: String</P> 5750 */ 5751 public static final String TERTIARY_EMAIL = "tertiary_email"; 5752 5753 /** 5754 * The extra field for an optional third contact email type. 5755 * <P>Type: Either an integer value from 5756 * {@link CommonDataKinds.Email} 5757 * or a string specifying a custom label.</P> 5758 */ 5759 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; 5760 5761 /** 5762 * The extra field for the contact postal address. 5763 * <P>Type: String</P> 5764 */ 5765 public static final String POSTAL = "postal"; 5766 5767 /** 5768 * The extra field for the contact postal address type. 5769 * <P>Type: Either an integer value from 5770 * {@link CommonDataKinds.StructuredPostal} 5771 * or a string specifying a custom label.</P> 5772 */ 5773 public static final String POSTAL_TYPE = "postal_type"; 5774 5775 /** 5776 * The extra field for the postal isprimary flag. 5777 * <P>Type: boolean</P> 5778 */ 5779 public static final String POSTAL_ISPRIMARY = "postal_isprimary"; 5780 5781 /** 5782 * The extra field for an IM handle. 5783 * <P>Type: String</P> 5784 */ 5785 public static final String IM_HANDLE = "im_handle"; 5786 5787 /** 5788 * The extra field for the IM protocol 5789 */ 5790 public static final String IM_PROTOCOL = "im_protocol"; 5791 5792 /** 5793 * The extra field for the IM isprimary flag. 5794 * <P>Type: boolean</P> 5795 */ 5796 public static final String IM_ISPRIMARY = "im_isprimary"; 5797 } 5798 } 5799} 5800