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