ContactsContract.java revision 28b68e5a59289f6947dc799b66a3b503571f876e
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.graphics.BitmapFactory; 20import android.net.Uri; 21 22/** 23 * The contract between the contacts provider and applications. Contains definitions 24 * for the supported URIs and columns. 25 * 26 * @hide 27 */ 28public final class ContactsContract { 29 /** The authority for the contacts provider */ 30 public static final String AUTHORITY = "com.android.contacts"; 31 /** A content:// style uri to the authority for the contacts provider */ 32 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); 33 34 public interface AccountsColumns { 35 /** 36 * The name of this account data 37 * <P>Type: TEXT</P> 38 */ 39 public static final String NAME = "name"; 40 /** 41 * The name of this account data 42 * <P>Type: TEXT</P> 43 */ 44 public static final String TYPE = "type"; 45 /** 46 * The name of this account data 47 * <P>Type: TEXT</P> 48 */ 49 public static final String DATA1 = "data1"; 50 51 /** 52 * The value for this account data 53 * <P>Type: INTEGER</P> 54 */ 55 public static final String DATA2 = "data2"; 56 57 /** 58 * The value for this account data 59 * <P>Type: INTEGER</P> 60 */ 61 public static final String DATA3 = "data3"; 62 63 /** 64 * The value for this account data 65 * <P>Type: INTEGER</P> 66 */ 67 public static final String DATA4 = "data4"; 68 69 /** 70 * The value for this account data 71 * <P>Type: INTEGER</P> 72 */ 73 public static final String DATA5 = "data5"; 74 } 75 76 /** 77 * Constants for the aggregates table, which contains a record per group 78 * of contact representing the same person. 79 */ 80 public static final class Accounts implements BaseColumns, AccountsColumns { 81 /** 82 * This utility class cannot be instantiated 83 */ 84 private Accounts() {} 85 86 /** 87 * The content:// style URI for this table 88 */ 89 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "accounts"); 90 91 /** 92 * The MIME type of {@link #CONTENT_URI} providing a directory of 93 * account data. 94 */ 95 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contacts_account"; 96 97 /** 98 * The MIME type of a {@link #CONTENT_URI} subdirectory of a account 99 */ 100 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contacts_account"; 101 } 102 103 public interface AggregatesColumns { 104 /** 105 * The display name for the contact. 106 * <P>Type: TEXT</P> 107 */ 108 public static final String DISPLAY_NAME = "display_name"; 109 110 /** 111 * The number of times a person has been contacted 112 * <P>Type: INTEGER</P> 113 */ 114 public static final String TIMES_CONTACTED = "times_contacted"; 115 116 /** 117 * The last time a person was contacted. 118 * <P>Type: INTEGER</P> 119 */ 120 public static final String LAST_TIME_CONTACTED = "last_time_contacted"; 121 122 /** 123 * Is the contact starred? 124 * <P>Type: INTEGER (boolean)</P> 125 */ 126 public static final String STARRED = "starred"; 127 128 /** 129 * Reference to the row in the data table holding the primary phone number. 130 * <P>Type: INTEGER REFERENCES data(_id)</P> 131 */ 132 public static final String PRIMARY_PHONE_ID = "primary_phone_id"; 133 134 /** 135 * Reference to the row in the data table holding the primary email address. 136 * <P>Type: INTEGER REFERENCES data(_id)</P> 137 */ 138 public static final String PRIMARY_EMAIL_ID = "primary_email_id"; 139 140 /** 141 * Reference to the row in the data table holding the photo. 142 * <P>Type: INTEGER REFERENCES data(_id)</P> 143 */ 144 public static final String PHOTO_ID = "photo_id"; 145 146 /** 147 * Reference to a row containing custom ringtone and send to voicemail information. 148 * <P>Type: INTEGER REFERENCES data(_id)</P> 149 */ 150 public static final String CUSTOM_RINGTONE_ID = "custom_ringtone_id"; 151 } 152 153 /** 154 * Constants for the aggregates table, which contains a record per group 155 * of contact representing the same person. 156 */ 157 public static final class Aggregates implements BaseColumns, AggregatesColumns { 158 /** 159 * This utility class cannot be instantiated 160 */ 161 private Aggregates() {} 162 163 /** 164 * The content:// style URI for this table 165 */ 166 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "aggregates"); 167 168 /** 169 * The content:// style URI for this table joined with useful data from 170 * {@link Data} and {@link Presence}. 171 */ 172 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, 173 "aggregates_summary"); 174 175 /** 176 * The MIME type of {@link #CONTENT_URI} providing a directory of 177 * people. 178 */ 179 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/person_aggregate"; 180 181 /** 182 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 183 * person. 184 */ 185 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/person_aggregate"; 186 187 /** 188 * A sub-directory of a single contact aggregate that contains all of their 189 * {@link Data} rows. 190 */ 191 public static final class Data implements BaseColumns, DataColumns { 192 /** 193 * no public constructor since this is a utility class 194 */ 195 private Data() {} 196 197 /** 198 * The directory twig for this sub-table 199 */ 200 public static final String CONTENT_DIRECTORY = "data"; 201 } 202 } 203 204 205 /** 206 * Constants for the contacts table, which contains the base contact information. 207 */ 208 public static final class Contacts implements BaseColumns { 209 /** 210 * This utility class cannot be instantiated 211 */ 212 private Contacts() {} 213 214 /** 215 * A reference to the {@link Accounts#_ID} that this data belongs to. 216 */ 217 public static final String ACCOUNTS_ID = "accounts_id"; 218 219 /** 220 * A reference to the {@link Aggregates#_ID} that this data belongs to. 221 */ 222 public static final String AGGREGATE_ID = "aggregate_id"; 223 224 /** 225 * The content:// style URI for this table 226 */ 227 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); 228 229 /** 230 * The content:// style URL for filtering people by email address. The 231 * filter argument should be passed as an additional path segment after 232 * this URI. 233 * 234 * @hide 235 */ 236 public static final Uri CONTENT_FILTER_EMAIL_URI = Uri.withAppendedPath(CONTENT_URI, "filter_email"); 237 238 /** 239 * The MIME type of {@link #CONTENT_URI} providing a directory of 240 * people. 241 */ 242 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/person"; 243 244 /** 245 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 246 * person. 247 */ 248 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/person"; 249 250 /** 251 * A string that uniquely identifies this contact to its source, which is referred to 252 * by the {@link #ACCOUNTS_ID} 253 */ 254 public static final String SOURCE_ID = "sourceid"; 255 256 /** 257 * An integer that is updated whenever this contact or its data changes. 258 */ 259 public static final String VERSION = "version"; 260 261 /** 262 * Set to 1 whenever the version changes 263 */ 264 public static final String DIRTY = "dirty"; 265 266 /** 267 * A sub-directory of a single contact that contains all of their {@link Data} rows. 268 * To access this directory append 269 */ 270 public static final class Data implements BaseColumns, DataColumns { 271 /** 272 * no public constructor since this is a utility class 273 */ 274 private Data() {} 275 276 /** 277 * The directory twig for this sub-table 278 */ 279 public static final String CONTENT_DIRECTORY = "data"; 280 } 281 } 282 283 private interface DataColumns { 284 /** 285 * The package name that defines this type of data. 286 */ 287 public static final String PACKAGE = "package"; 288 289 /** 290 * The mime-type of the item represented by this row. 291 */ 292 public static final String MIMETYPE = "mimetype"; 293 294 /** 295 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} 296 * that this data belongs to. 297 */ 298 public static final String CONTACT_ID = "contact_id"; 299 300 /** 301 * Whether this is the primary entry of its kind for the contact it belongs to 302 * <P>Type: INTEGER (if set, non-0 means true)</P> 303 */ 304 public static final String IS_PRIMARY = "is_primary"; 305 306 /** 307 * Whether this is the primary entry of its kind for the aggregate it belongs to. Any data 308 * record that is "super primary" must also be "primary". 309 * <P>Type: INTEGER (if set, non-0 means true)</P> 310 */ 311 public static final String IS_SUPER_PRIMARY = "is_super_primary"; 312 313 /** 314 * Flag indicating that this data entry has been restricted by the owner 315 * {@link #PACKAGE}. 316 */ 317 public static final String IS_RESTRICTED = "is_restricted"; 318 319 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 320 public static final String DATA1 = "data1"; 321 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 322 public static final String DATA2 = "data2"; 323 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 324 public static final String DATA3 = "data3"; 325 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 326 public static final String DATA4 = "data4"; 327 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 328 public static final String DATA5 = "data5"; 329 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 330 public static final String DATA6 = "data6"; 331 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 332 public static final String DATA7 = "data7"; 333 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 334 public static final String DATA8 = "data8"; 335 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 336 public static final String DATA9 = "data9"; 337 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 338 public static final String DATA10 = "data10"; 339 } 340 341 /** 342 * Constants for the data table, which contains data points tied to a contact. 343 * For example, a phone number or email address. Each row in this table contains a type 344 * definition and some generic columns. Each data type can define the meaning for each of 345 * the generic columns. 346 */ 347 public static final class Data implements BaseColumns, DataColumns { 348 /** 349 * This utility class cannot be instantiated 350 */ 351 private Data() {} 352 353 /** 354 * The content:// style URI for this table 355 */ 356 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); 357 358 /** 359 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 360 */ 361 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; 362 } 363 364 /** 365 * A table that represents the result of looking up a phone number, for example for caller ID. 366 * The table joins that data row for the phone number with the contact that owns the number. 367 * To perform a lookup you must append the number you want to find to {@link #CONTENT_URI}. 368 */ 369 public static final class PhoneLookup implements BaseColumns, DataColumns, AggregatesColumns { 370 /** 371 * This utility class cannot be instantiated 372 */ 373 private PhoneLookup() {} 374 375 /** 376 * The content:// style URI for this table. Append the phone number you want to lookup 377 * to this URI and query it to perform a lookup. For example: 378 * 379 * {@code 380 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber); 381 * } 382 */ 383 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, 384 "phone_lookup"); 385 } 386 387 /** 388 * Additional data mixed in with {@link Im.CommonPresenceColumns} to link 389 * back to specific {@link ContactsContract.Aggregates#_ID} entries. 390 */ 391 private interface PresenceColumns { 392 /** 393 * Reference to the {@link Aggregates#_ID} this presence references. 394 */ 395 public static final String AGGREGATE_ID = "aggregate_id"; 396 397 /** 398 * Reference to the {@link Data#_ID} entry that owns this presence. 399 */ 400 public static final String DATA_ID = "data_id"; 401 402 /** 403 * The IM service the presence is coming from. Formatted using either 404 * {@link Contacts.ContactMethods#encodePredefinedImProtocol} or 405 * {@link Contacts.ContactMethods#encodeCustomImProtocol}. 406 * <p> 407 * Type: STRING 408 */ 409 public static final String IM_PROTOCOL = "im_protocol"; 410 411 /** 412 * The IM handle the presence item is for. The handle is scoped to the 413 * {@link #IM_PROTOCOL}. 414 * <p> 415 * Type: STRING 416 */ 417 public static final String IM_HANDLE = "im_handle"; 418 419 /** 420 * The IM account for the local user that the presence data came from. 421 * <p> 422 * Type: STRING 423 */ 424 public static final String IM_ACCOUNT = "im_account"; 425 } 426 427 public static final class Presence implements BaseColumns, PresenceColumns, 428 Im.CommonPresenceColumns { 429 /** 430 * This utility class cannot be instantiated 431 */ 432 private Presence() { 433 } 434 435 /** 436 * The content:// style URI for this table 437 */ 438 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence"); 439 440 /** 441 * Gets the resource ID for the proper presence icon. 442 * 443 * @param status the status to get the icon for 444 * @return the resource ID for the proper presence icon 445 */ 446 public static final int getPresenceIconResourceId(int status) { 447 switch (status) { 448 case AVAILABLE: 449 return android.R.drawable.presence_online; 450 case IDLE: 451 case AWAY: 452 return android.R.drawable.presence_away; 453 case DO_NOT_DISTURB: 454 return android.R.drawable.presence_busy; 455 case INVISIBLE: 456 return android.R.drawable.presence_invisible; 457 case OFFLINE: 458 default: 459 return android.R.drawable.presence_offline; 460 } 461 } 462 463 /** 464 * The MIME type of {@link #CONTENT_URI} providing a directory of 465 * presence details. 466 */ 467 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence"; 468 469 /** 470 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 471 * presence detail. 472 */ 473 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence"; 474 } 475 476 /** 477 * Container for definitions of common data types stored in the {@link Data} table. 478 */ 479 public static final class CommonDataKinds { 480 /** 481 * The {@link Data#PACKAGE} value for common data that should be shown 482 * using a default style. 483 */ 484 public static final String PACKAGE_COMMON = "common"; 485 486 /** 487 * Columns common across the specific types. 488 */ 489 private interface BaseCommonColumns { 490 /** 491 * The package name that defines this type of data. 492 */ 493 public static final String PACKAGE = "package"; 494 495 /** 496 * The mime-type of the item represented by this row. 497 */ 498 public static final String MIMETYPE = "mimetype"; 499 500 /** 501 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this 502 * data belongs to. 503 */ 504 public static final String CONTACT_ID = "contact_id"; 505 } 506 507 /** 508 * Columns common across the specific types. 509 */ 510 private interface CommonColumns { 511 /** 512 * The type of data, for example Home or Work. 513 * <P>Type: INTEGER</P> 514 */ 515 public static final String TYPE = "data1"; 516 517 /** 518 * The data for the contact method. 519 * <P>Type: TEXT</P> 520 */ 521 public static final String DATA = "data2"; 522 523 /** 524 * The user defined label for the the contact method. 525 * <P>Type: TEXT</P> 526 */ 527 public static final String LABEL = "data3"; 528 } 529 530 /** 531 * The base types that all "Typed" data kinds support. 532 */ 533 public interface BaseTypes { 534 535 /** 536 * A custom type. The custom label should be supplied by user. 537 */ 538 public static int TYPE_CUSTOM = 0; 539 } 540 541 /** 542 * Parts of the name. 543 */ 544 public static final class StructuredName { 545 private StructuredName() {} 546 547 /** Mime-type used when storing this in data table. */ 548 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; 549 550 /** 551 * The given name for the contact. 552 * <P>Type: TEXT</P> 553 */ 554 public static final String GIVEN_NAME = "data1"; 555 556 /** 557 * The family name for the contact. 558 * <P>Type: TEXT</P> 559 */ 560 public static final String FAMILY_NAME = "data2"; 561 562 /** 563 * The contact's honorific prefix, e.g. "Sir" 564 * <P>Type: TEXT</P> 565 */ 566 public static final String PREFIX = "data3"; 567 568 /** 569 * The contact's middle name 570 * <P>Type: TEXT</P> 571 */ 572 public static final String MIDDLE_NAME = "data4"; 573 574 /** 575 * The contact's honorific suffix, e.g. "Jr" 576 */ 577 public static final String SUFFIX = "data5"; 578 579 /** 580 * The phonetic version of the given name for the contact. 581 * <P>Type: TEXT</P> 582 */ 583 public static final String PHONETIC_GIVEN_NAME = "data6"; 584 585 /** 586 * The phonetic version of the additional name for the contact. 587 * <P>Type: TEXT</P> 588 */ 589 public static final String PHONETIC_MIDDLE_NAME = "data7"; 590 591 /** 592 * The phonetic version of the family name for the contact. 593 * <P>Type: TEXT</P> 594 */ 595 public static final String PHONETIC_FAMILY_NAME = "data8"; 596 597 /** 598 * The name that should be used to display the contact. 599 * <P>Type: TEXT</P> 600 */ 601 public static final String DISPLAY_NAME = "data9"; 602 } 603 604 /** 605 * A nickname. 606 */ 607 public static final class Nickname implements BaseTypes { 608 private Nickname() {} 609 610 /** Mime-type used when storing this in data table. */ 611 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; 612 613 /** 614 * The type of data, for example Home or Work. 615 * <P>Type: INTEGER</P> 616 */ 617 public static final String TYPE = "data1"; 618 619 public static final int TYPE_DEFAULT = 1; 620 public static final int TYPE_OTHER_NAME = 2; 621 public static final int TYPE_MAINDEN_NAME = 3; 622 public static final int TYPE_SHORT_NAME = 4; 623 public static final int TYPE_INITIALS = 5; 624 625 /** 626 * The name itself 627 */ 628 public static final String NAME = "data2"; 629 630 /** 631 * The user provided label, only used if TYPE is {@link #TYPE_CUSTOM}. 632 * <P>Type: TEXT</P> 633 */ 634 public static final String LABEL = "data3"; 635 } 636 637 /** 638 * Common data definition for telephone numbers. 639 */ 640 public static final class Phone implements BaseCommonColumns, CommonColumns, BaseTypes { 641 private Phone() {} 642 643 /** Mime-type used when storing this in data table. */ 644 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone"; 645 646 public static final int TYPE_HOME = 1; 647 public static final int TYPE_MOBILE = 2; 648 public static final int TYPE_WORK = 3; 649 public static final int TYPE_FAX_WORK = 4; 650 public static final int TYPE_FAX_HOME = 5; 651 public static final int TYPE_PAGER = 6; 652 public static final int TYPE_OTHER = 7; 653 654 /** 655 * The phone number as the user entered it. 656 * <P>Type: TEXT</P> 657 */ 658 public static final String NUMBER = "data2"; 659 } 660 661 /** 662 * Common data definition for email addresses. 663 */ 664 public static final class Email implements BaseCommonColumns, CommonColumns, BaseTypes { 665 private Email() {} 666 667 /** Mime-type used when storing this in data table. */ 668 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email"; 669 670 public static final int TYPE_HOME = 1; 671 public static final int TYPE_WORK = 2; 672 public static final int TYPE_OTHER = 3; 673 } 674 675 /** 676 * Common data definition for postal addresses. 677 */ 678 public static final class Postal implements BaseCommonColumns, CommonColumns, BaseTypes { 679 private Postal() {} 680 681 /** Mime-type used when storing this in data table. */ 682 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/postal-address"; 683 684 public static final int TYPE_HOME = 1; 685 public static final int TYPE_WORK = 2; 686 public static final int TYPE_OTHER = 3; 687 } 688 689 /** 690 * Common data definition for IM addresses. 691 */ 692 public static final class Im implements BaseCommonColumns, CommonColumns, BaseTypes { 693 private Im() {} 694 695 /** Mime-type used when storing this in data table. */ 696 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; 697 698 public static final int TYPE_HOME = 1; 699 public static final int TYPE_WORK = 2; 700 public static final int TYPE_OTHER = 3; 701 702 public static final String PROTOCOL = "data5"; 703 704 /** 705 * The predefined IM protocol types. The protocol can either be non-present, one 706 * of these types, or a free-form string. These cases are encoded in the PROTOCOL 707 * column as: 708 * <ul> 709 * <li>null</li> 710 * <li>pre:<an integer, one of the protocols below></li> 711 * <li>custom:<a string></li> 712 * </ul> 713 */ 714 public static final int PROTOCOL_AIM = 0; 715 public static final int PROTOCOL_MSN = 1; 716 public static final int PROTOCOL_YAHOO = 2; 717 public static final int PROTOCOL_SKYPE = 3; 718 public static final int PROTOCOL_QQ = 4; 719 public static final int PROTOCOL_GOOGLE_TALK = 5; 720 public static final int PROTOCOL_ICQ = 6; 721 public static final int PROTOCOL_JABBER = 7; 722 723 public static String encodePredefinedImProtocol(int protocol) { 724 return "pre:" + protocol; 725 } 726 727 public static String encodeCustomImProtocol(String protocolString) { 728 return "custom:" + protocolString; 729 } 730 731 public static Object decodeImProtocol(String encodedString) { 732 if (encodedString == null) { 733 return null; 734 } 735 736 if (encodedString.startsWith("pre:")) { 737 return Integer.parseInt(encodedString.substring(4)); 738 } 739 740 if (encodedString.startsWith("custom:")) { 741 return encodedString.substring(7); 742 } 743 744 throw new IllegalArgumentException( 745 "the value is not a valid encoded protocol, " + encodedString); 746 } 747 } 748 749 /** 750 * Common data definition for organizations. 751 */ 752 public static final class Organization implements BaseCommonColumns, BaseTypes { 753 private Organization() {} 754 755 /** Mime-type used when storing this in data table. */ 756 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; 757 758 /** 759 * The type of data, for example Home or Work. 760 * <P>Type: INTEGER</P> 761 */ 762 public static final String TYPE = "data1"; 763 764 public static final int TYPE_HOME = 1; 765 public static final int TYPE_WORK = 2; 766 public static final int TYPE_OTHER = 3; 767 768 /** 769 * The user provided label, only used if TYPE is {@link #TYPE_CUSTOM}. 770 * <P>Type: TEXT</P> 771 */ 772 public static final String LABEL = "data2"; 773 774 /** 775 * The company as the user entered it. 776 * <P>Type: TEXT</P> 777 */ 778 public static final String COMPANY = "data3"; 779 780 /** 781 * The position title at this company as the user entered it. 782 * <P>Type: TEXT</P> 783 */ 784 public static final String TITLE = "data4"; 785 } 786 787 /** 788 * Photo of the contact. 789 */ 790 public static final class Photo implements BaseCommonColumns { 791 private Photo() {} 792 793 /** Mime-type used when storing this in data table. */ 794 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; 795 796 /** 797 * Thumbnail photo of the contact. This is the raw bytes of an image 798 * that could be inflated using {@link BitmapFactory}. 799 * <p> 800 * Type: BLOB 801 */ 802 public static final String PHOTO = "data1"; 803 } 804 805 /** 806 * Notes about the contact. 807 */ 808 public static final class Note implements BaseCommonColumns { 809 private Note() {} 810 811 /** Mime-type used when storing this in data table. */ 812 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; 813 814 /** 815 * The note text. 816 * <P>Type: TEXT</P> 817 */ 818 public static final String NOTE = "data1"; 819 } 820 821 /** 822 * Custom ringtone associated with the contact. 823 */ 824 public static final class CustomRingtone implements BaseCommonColumns { 825 private CustomRingtone() {} 826 827 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/custom_ringtone"; 828 829 /** 830 * Whether to send the number to voicemail. 831 * <P>Type: INTEGER (if set, non-0 means true)</P> 832 */ 833 public static final String SEND_TO_VOICEMAIL = "data1"; 834 835 /** 836 * The ringtone uri. 837 * <P>Type: TEXT</P> 838 */ 839 public static final String RINGTONE_URI = "data2"; 840 } 841 842 /** 843 * Group Membership. 844 */ 845 public static final class GroupMembership implements BaseCommonColumns { 846 private GroupMembership() {} 847 848 /** Mime-type used when storing this in data table. */ 849 public static final String CONTENT_ITEM_TYPE = 850 "vnd.android.cursor.item/group_membership"; 851 852 /** 853 * The row id of the group that this group membership refers to. Either this or the 854 * GROUP_SOURCE_ID must be set. If they are both set then they must refer to the same 855 * group. 856 * <P>Type: INTEGER</P> 857 */ 858 public static final String GROUP_ROW_ID = "data1"; 859 860 /** 861 * The source id of the group that this membership refers to. Either this or the 862 * GROUP_ROW_ID must be set. If they are both set then they must refer to the same 863 * group. 864 * <P>Type: STRING</P> 865 */ 866 public static final String GROUP_SOURCE_ID = "data2"; 867 } 868 } 869 870 /** 871 * Constants for the contact aggregation exceptions table, which contains 872 * aggregation rules overriding those used by automatic aggregation. 873 */ 874 public static final class AggregationExceptions { 875 /** 876 * This utility class cannot be instantiated 877 */ 878 private AggregationExceptions() {} 879 880 /** 881 * The content:// style URI for this table 882 */ 883 public static final Uri CONTENT_URI = 884 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); 885 886 /** 887 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 888 */ 889 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; 890 891 /** 892 * The type of exception: {@link #TYPE_NEVER_MATCH} or {@link #TYPE_ALWAYS_MATCH}. 893 * 894 * <P>Type: INTEGER</P> 895 */ 896 public static final String TYPE = "type"; 897 898 public static final int TYPE_NEVER_MATCH = 0; 899 public static final int TYPE_ALWAYS_MATCH = 1; 900 901 /** 902 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of one of 903 * the contacts that the rule applies to. 904 */ 905 public static final String CONTACT_ID1 = "contact_id1"; 906 907 /** 908 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the other 909 * contact that the rule applies to. 910 */ 911 public static final String CONTACT_ID2 = "contact_id2"; 912 } 913 914 private interface RestrictionExceptionsColumns { 915 /** 916 * Package name of a specific data provider, which will be matched 917 * against {@link Data#PACKAGE}. 918 * <p> 919 * Type: STRING 920 */ 921 public static final String PACKAGE_PROVIDER = "package_provider"; 922 923 /** 924 * Package name of a specific data client, which will be matched against 925 * the incoming {@link android.os.Binder#getCallingUid()} to decide if 926 * the caller can access values with {@link Data#IS_RESTRICTED} flags. 927 * <p> 928 * Type: STRING 929 */ 930 public static final String PACKAGE_CLIENT = "package_client"; 931 932 /** 933 * Flag indicating if {@link #PACKAGE_PROVIDER} allows 934 * {@link #PACKAGE_CLIENT} to access restricted {@link Data} rows. 935 * <p> 936 * Type: INTEGER 937 */ 938 public static final String ALLOW_ACCESS = "allow_access"; 939 } 940 941 /** 942 * Constants for {@link Data} restriction exceptions. Sync adapters who 943 * insert restricted data can use this table to specify exceptions about 944 * which additional packages can access that restricted data.You can only 945 * modify rules for a {@link RestrictionExceptionsColumns#PACKAGE_PROVIDER} 946 * that your {@link android.os.Binder#getCallingUid()} owns. 947 */ 948 public static final class RestrictionExceptions implements RestrictionExceptionsColumns { 949 /** 950 * This utility class cannot be instantiated 951 */ 952 private RestrictionExceptions() {} 953 954 /** 955 * The content:// style URI for this table 956 */ 957 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, 958 "restriction_exceptions"); 959 } 960} 961