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