ContactsContract.java revision eb1a2ec4b2a429ceb924e6bce46b2b52c1cd85b2
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.Context; 25import android.content.Intent; 26import android.content.res.Resources; 27import android.database.Cursor; 28import android.graphics.BitmapFactory; 29import android.net.Uri; 30import android.os.RemoteException; 31import android.provider.ContactsContract.CommonDataKinds.GroupMembership; 32import android.provider.ContactsContract.Contacts.Photo; 33import android.text.TextUtils; 34 35import java.io.ByteArrayInputStream; 36import java.io.InputStream; 37 38/** 39 * The contract between the contacts provider and applications. Contains definitions 40 * for the supported URIs and columns. 41 * 42 * @hide 43 */ 44public final class ContactsContract { 45 /** The authority for the contacts provider */ 46 public static final String AUTHORITY = "com.android.contacts"; 47 /** A content:// style uri to the authority for the contacts provider */ 48 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); 49 50 public interface SyncStateColumns extends SyncStateContract.Columns { 51 } 52 53 public static final class SyncState { 54 /** 55 * This utility class cannot be instantiated 56 */ 57 private SyncState() {} 58 59 public static final String CONTENT_DIRECTORY = 60 SyncStateContract.Constants.CONTENT_DIRECTORY; 61 62 /** 63 * The content:// style URI for this table 64 */ 65 public static final Uri CONTENT_URI = 66 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); 67 68 /** 69 * @see android.provider.SyncStateContract.Helpers#get 70 */ 71 public static byte[] get(ContentProviderClient provider, Account account) 72 throws RemoteException { 73 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); 74 } 75 76 /** 77 * @see android.provider.SyncStateContract.Helpers#set 78 */ 79 public static void set(ContentProviderClient provider, Account account, byte[] data) 80 throws RemoteException { 81 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); 82 } 83 84 /** 85 * @see android.provider.SyncStateContract.Helpers#newSetOperation 86 */ 87 public static ContentProviderOperation newSetOperation(Account account, byte[] data) { 88 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); 89 } 90 } 91 92 /** 93 * Generic columns for use by sync adapters. The specific functions of 94 * these columns are private to the sync adapter. Other clients of the API 95 * should not attempt to either read or write this column. 96 */ 97 private interface BaseSyncColumns { 98 99 /** Generic column for use by sync adapters. */ 100 public static final String SYNC1 = "sync1"; 101 /** Generic column for use by sync adapters. */ 102 public static final String SYNC2 = "sync2"; 103 /** Generic column for use by sync adapters. */ 104 public static final String SYNC3 = "sync3"; 105 /** Generic column for use by sync adapters. */ 106 public static final String SYNC4 = "sync4"; 107 } 108 109 /** 110 * Columns that appear when each row of a table belongs to a specific 111 * account, including sync information that an account may need. 112 */ 113 private interface SyncColumns extends BaseSyncColumns { 114 /** 115 * The name of the account instance to which this row belongs. 116 * <P>Type: TEXT</P> 117 */ 118 public static final String ACCOUNT_NAME = "account_name"; 119 120 /** 121 * The type of account to which this row belongs, which when paired with 122 * {@link #ACCOUNT_NAME} identifies a specific account. 123 * <P>Type: TEXT</P> 124 */ 125 public static final String ACCOUNT_TYPE = "account_type"; 126 127 /** 128 * String that uniquely identifies this row to its source account. 129 * <P>Type: TEXT</P> 130 */ 131 public static final String SOURCE_ID = "sourceid"; 132 133 /** 134 * Version number that is updated whenever this row or its related data 135 * changes. 136 * <P>Type: INTEGER</P> 137 */ 138 public static final String VERSION = "version"; 139 140 /** 141 * Flag indicating that {@link #VERSION} has changed, and this row needs 142 * to be synchronized by its owning account. 143 * <P>Type: INTEGER (boolean)</P> 144 */ 145 public static final String DIRTY = "dirty"; 146 } 147 148 public interface ContactOptionsColumns { 149 /** 150 * The number of times a person has been contacted 151 * <P>Type: INTEGER</P> 152 */ 153 public static final String TIMES_CONTACTED = "times_contacted"; 154 155 /** 156 * The last time a person was contacted. 157 * <P>Type: INTEGER</P> 158 */ 159 public static final String LAST_TIME_CONTACTED = "last_time_contacted"; 160 161 /** 162 * Is the contact starred? 163 * <P>Type: INTEGER (boolean)</P> 164 */ 165 public static final String STARRED = "starred"; 166 167 /** 168 * A custom ringtone associated with a person. Not always present. 169 * <P>Type: TEXT (URI to the ringtone)</P> 170 */ 171 public static final String CUSTOM_RINGTONE = "custom_ringtone"; 172 173 /** 174 * Whether the person should always be sent to voicemail. Not always 175 * present. 176 * <P>Type: INTEGER (0 for false, 1 for true)</P> 177 */ 178 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; 179 } 180 181 private interface ContactsColumns { 182 /** 183 * The display name for the contact. 184 * <P>Type: TEXT</P> 185 */ 186 public static final String DISPLAY_NAME = "display_name"; 187 188 /** 189 * Reference to the row in the data table holding the photo. 190 * <P>Type: INTEGER REFERENCES data(_id)</P> 191 */ 192 public static final String PHOTO_ID = "photo_id"; 193 194 /** 195 * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of 196 * any {@link GroupMembership} for this contact. 197 */ 198 public static final String IN_VISIBLE_GROUP = "in_visible_group"; 199 200 /** 201 * Contact presence status. See {@link android.provider.Im.CommonPresenceColumns} 202 * for individual status definitions. 203 */ 204 public static final String PRESENCE_STATUS = Presence.PRESENCE_STATUS; 205 206 /** 207 * An indicator of whether this contact has at least one phone number. "1" if there is 208 * at least one phone number, "0" otherwise. 209 * <P>Type: INTEGER</P> 210 */ 211 public static final String HAS_PHONE_NUMBER = "has_phone_number"; 212 } 213 214 /** 215 * Constants for the contacts table, which contains a record per group 216 * of raw contact representing the same person. 217 */ 218 public static class Contacts implements BaseColumns, ContactsColumns, 219 ContactOptionsColumns { 220 /** 221 * This utility class cannot be instantiated 222 */ 223 private Contacts() {} 224 225 /** 226 * The content:// style URI for this table 227 */ 228 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); 229 230 /** 231 * The content:// style URI for this table joined with useful data from 232 * {@link Data}. 233 */ 234 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, 235 "contacts_summary"); 236 237 /** 238 * The content:// style URI used for "type-to-filter" functionality on the 239 * {@link #CONTENT_SUMMARY_URI} URI. The filter string will be used to match 240 * various parts of the contact name. The filter argument should be passed 241 * as an additional path segment after this URI. 242 */ 243 public static final Uri CONTENT_SUMMARY_FILTER_URI = Uri.withAppendedPath( 244 CONTENT_SUMMARY_URI, "filter"); 245 246 /** 247 * The content:// style URI for this table joined with useful data from 248 * {@link Data}, filtered to include only starred contacts 249 * and the most frequently contacted contacts. 250 */ 251 public static final Uri CONTENT_SUMMARY_STREQUENT_URI = Uri.withAppendedPath( 252 CONTENT_SUMMARY_URI, "strequent"); 253 254 /** 255 * The content:// style URI used for "type-to-filter" functionality on the 256 * {@link #CONTENT_SUMMARY_STREQUENT_URI} URI. The filter string will be used to match 257 * various parts of the contact name. The filter argument should be passed 258 * as an additional path segment after this URI. 259 */ 260 public static final Uri CONTENT_SUMMARY_STREQUENT_FILTER_URI = Uri.withAppendedPath( 261 CONTENT_SUMMARY_STREQUENT_URI, "filter"); 262 263 public static final Uri CONTENT_SUMMARY_GROUP_URI = Uri.withAppendedPath( 264 CONTENT_SUMMARY_URI, "group"); 265 /** 266 * The MIME type of {@link #CONTENT_URI} providing a directory of 267 * people. 268 */ 269 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; 270 271 /** 272 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 273 * person. 274 */ 275 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; 276 277 /** 278 * A sub-directory of a single contact that contains all of the constituent raw contact 279 * {@link Data} rows. 280 */ 281 public static final class Data implements BaseColumns, DataColumns { 282 /** 283 * no public constructor since this is a utility class 284 */ 285 private Data() {} 286 287 /** 288 * The directory twig for this sub-table 289 */ 290 public static final String CONTENT_DIRECTORY = "data"; 291 } 292 293 /** 294 * A sub-directory of a single contact aggregate that contains all aggregation suggestions 295 * (other contacts). The aggregation suggestions are computed based on approximate 296 * data matches with this contact. 297 */ 298 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns { 299 /** 300 * No public constructor since this is a utility class 301 */ 302 private AggregationSuggestions() {} 303 304 /** 305 * The directory twig for this sub-table 306 */ 307 public static final String CONTENT_DIRECTORY = "suggestions"; 308 } 309 310 /** 311 * A sub-directory of a single contact that contains the contact's primary photo. 312 */ 313 public static final class Photo implements BaseColumns, DataColumns { 314 /** 315 * no public constructor since this is a utility class 316 */ 317 private Photo() {} 318 319 /** 320 * The directory twig for this sub-table 321 */ 322 public static final String CONTENT_DIRECTORY = "photo"; 323 } 324 325 /** 326 * Opens an InputStream for the person's default photo and returns the 327 * photo as a Bitmap stream. 328 * 329 * @param contactUri the contact whose photo should be used 330 */ 331 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { 332 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); 333 if (photoUri == null) { 334 return null; 335 } 336 Cursor cursor = cr.query(photoUri, 337 new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null); 338 try { 339 if (!cursor.moveToNext()) { 340 return null; 341 } 342 byte[] data = cursor.getBlob(0); 343 if (data == null) { 344 return null; 345 } 346 return new ByteArrayInputStream(data); 347 } finally { 348 cursor.close(); 349 } 350 } 351 } 352 353 private interface RawContactsColumns { 354 /** 355 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this 356 * data belongs to. 357 * <P>Type: INTEGER</P> 358 */ 359 public static final String CONTACT_ID = "contact_id"; 360 361 /** 362 * Flag indicating that this {@link RawContacts} entry and its children has 363 * been restricted to specific platform apps. 364 * <P>Type: INTEGER (boolean)</P> 365 * 366 * @hide until finalized in future platform release 367 */ 368 public static final String IS_RESTRICTED = "is_restricted"; 369 370 /** 371 * The aggregation mode for this contact. 372 * <P>Type: INTEGER</P> 373 */ 374 public static final String AGGREGATION_MODE = "aggregation_mode"; 375 376 /** 377 * The "deleted" flag: "0" by default, "1" if the row has been marked 378 * for deletion. When {@link android.content.ContentResolver#delete} is 379 * called on a raw contact, it is marked for deletion and removed from its 380 * aggregate contact. The sync adaptor deletes the raw contact on the server and 381 * then calls ContactResolver.delete once more, this time passing the 382 * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal. 383 * <P>Type: INTEGER</P> 384 */ 385 public static final String DELETED = "deleted"; 386 } 387 388 /** 389 * Constants for the raw_contacts table, which contains the base contact 390 * information per sync source. Sync adapters and contact management apps 391 * are the primary consumers of this API. 392 */ 393 public static final class RawContacts implements BaseColumns, RawContactsColumns, 394 ContactOptionsColumns, SyncColumns { 395 /** 396 * This utility class cannot be instantiated 397 */ 398 private RawContacts() { 399 } 400 401 /** 402 * The content:// style URI for this table 403 */ 404 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); 405 406 /** 407 * The content:// style URL for filtering people by email address. The 408 * filter argument should be passed as an additional path segment after 409 * this URI. 410 * 411 * @hide 412 */ 413 @Deprecated 414 public static final Uri CONTENT_FILTER_EMAIL_URI = 415 Uri.withAppendedPath(CONTENT_URI, "filter_email"); 416 417 /** 418 * The MIME type of {@link #CONTENT_URI} providing a directory of 419 * people. 420 */ 421 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; 422 423 /** 424 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 425 * person. 426 */ 427 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact"; 428 429 /** 430 * Query parameter that can be passed with the {@link #CONTENT_URI} URI 431 * to the {@link android.content.ContentResolver#delete} method to 432 * indicate that the raw contact can be deleted physically, rather than 433 * merely marked as deleted. 434 */ 435 public static final String DELETE_PERMANENTLY = "delete_permanently"; 436 437 /** 438 * Aggregation mode: aggregate asynchronously. 439 */ 440 public static final int AGGREGATION_MODE_DEFAULT = 0; 441 442 /** 443 * Aggregation mode: aggregate at the time the raw contact is inserted/updated. 444 */ 445 public static final int AGGREGATION_MODE_IMMEDITATE = 1; 446 447 /** 448 * Aggregation mode: never aggregate this raw contact (note that the raw contact will not 449 * have a corresponding Aggregate and therefore will not be included in Aggregates 450 * query results.) 451 */ 452 public static final int AGGREGATION_MODE_DISABLED = 2; 453 454 /** 455 * A sub-directory of a single raw contact that contains all of their {@link Data} rows. 456 * To access this directory append 457 */ 458 public static final class Data implements BaseColumns, DataColumns { 459 /** 460 * no public constructor since this is a utility class 461 */ 462 private Data() { 463 } 464 465 /** 466 * The directory twig for this sub-table 467 */ 468 public static final String CONTENT_DIRECTORY = "data"; 469 } 470 } 471 472 private interface DataColumns { 473 /** 474 * The package name to use when creating {@link Resources} objects for 475 * this data row. This value is only designed for use when building user 476 * interfaces, and should not be used to infer the owner. 477 */ 478 public static final String RES_PACKAGE = "res_package"; 479 480 /** 481 * The MIME type of the item represented by this row. 482 */ 483 public static final String MIMETYPE = "mimetype"; 484 485 /** 486 * A reference to the {@link RawContacts#_ID} 487 * that this data belongs to. 488 */ 489 public static final String RAW_CONTACT_ID = "raw_contact_id"; 490 491 /** 492 * Whether this is the primary entry of its kind for the raw contact it belongs to 493 * <P>Type: INTEGER (if set, non-0 means true)</P> 494 */ 495 public static final String IS_PRIMARY = "is_primary"; 496 497 /** 498 * Whether this is the primary entry of its kind for the aggregate 499 * contact it belongs to. Any data record that is "super primary" must 500 * also be "primary". 501 * <P>Type: INTEGER (if set, non-0 means true)</P> 502 */ 503 public static final String IS_SUPER_PRIMARY = "is_super_primary"; 504 505 /** 506 * The version of this data record. This is a read-only value. The data column is 507 * guaranteed to not change without the version going up. This value is monotonically 508 * increasing. 509 * <P>Type: INTEGER</P> 510 */ 511 public static final String DATA_VERSION = "data_version"; 512 513 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 514 public static final String DATA1 = "data1"; 515 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 516 public static final String DATA2 = "data2"; 517 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 518 public static final String DATA3 = "data3"; 519 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 520 public static final String DATA4 = "data4"; 521 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 522 public static final String DATA5 = "data5"; 523 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 524 public static final String DATA6 = "data6"; 525 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 526 public static final String DATA7 = "data7"; 527 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 528 public static final String DATA8 = "data8"; 529 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 530 public static final String DATA9 = "data9"; 531 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 532 public static final String DATA10 = "data10"; 533 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 534 public static final String DATA11 = "data11"; 535 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 536 public static final String DATA12 = "data12"; 537 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 538 public static final String DATA13 = "data13"; 539 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 540 public static final String DATA14 = "data14"; 541 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 542 public static final String DATA15 = "data15"; 543 544 /** Generic column for use by sync adapters. */ 545 public static final String SYNC1 = "data_sync1"; 546 /** Generic column for use by sync adapters. */ 547 public static final String SYNC2 = "data_sync2"; 548 /** Generic column for use by sync adapters. */ 549 public static final String SYNC3 = "data_sync3"; 550 /** Generic column for use by sync adapters. */ 551 public static final String SYNC4 = "data_sync4"; 552 553 /** 554 * An optional insert, update or delete URI parameter that determines if 555 * the corresponding raw contact should be marked as dirty. The default 556 * value is true. 557 */ 558 public static final String MARK_AS_DIRTY = "mark_as_dirty"; 559 } 560 561 /** 562 * Constants for the data table, which contains data points tied to a raw contact. 563 * For example, a phone number or email address. Each row in this table contains a type 564 * definition and some generic columns. Each data type can define the meaning for each of 565 * the generic columns. 566 */ 567 public static final class Data implements BaseColumns, DataColumns { 568 /** 569 * This utility class cannot be instantiated 570 */ 571 private Data() {} 572 573 /** 574 * The content:// style URI for this table 575 */ 576 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); 577 578 /** 579 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 580 */ 581 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; 582 } 583 584 private interface PhoneLookupColumns { 585 /** 586 * The phone number as the user entered it. 587 * <P>Type: TEXT</P> 588 */ 589 public static final String NUMBER = "number"; 590 591 /** 592 * The type of phone number, for example Home or Work. 593 * <P>Type: INTEGER</P> 594 */ 595 public static final String TYPE = "type"; 596 597 /** 598 * The user defined label for the phone number. 599 * <P>Type: TEXT</P> 600 */ 601 public static final String LABEL = "label"; 602 } 603 604 /** 605 * A table that represents the result of looking up a phone number, for 606 * example for caller ID. To perform a lookup you must append the number you 607 * want to find to {@link #CONTENT_FILTER_URI}. 608 */ 609 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, 610 ContactsColumns, ContactOptionsColumns { 611 /** 612 * This utility class cannot be instantiated 613 */ 614 private PhoneLookup() {} 615 616 /** 617 * The content:// style URI for this table. Append the phone number you want to lookup 618 * to this URI and query it to perform a lookup. For example: 619 * 620 * {@code 621 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber); 622 * } 623 */ 624 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, 625 "phone_lookup"); 626 } 627 628 /** 629 * Additional data mixed in with {@link Im.CommonPresenceColumns} to link 630 * back to specific {@link ContactsContract.Contacts#_ID} entries. 631 */ 632 private interface PresenceColumns { 633 634 /** 635 * The unique ID for a row. 636 * <P>Type: INTEGER (long)</P> 637 */ 638 public static final String _ID = "presence_id"; 639 640 /** 641 * Reference to the {@link RawContacts#_ID} this presence references. 642 * <P>Type: INTEGER</P> 643 */ 644 public static final String RAW_CONTACT_ID = "presence_raw_contact_id"; 645 646 /** 647 * Reference to the {@link Data#_ID} entry that owns this presence. 648 * <P>Type: INTEGER</P> 649 */ 650 public static final String DATA_ID = "presence_data_id"; 651 652 /** 653 * The IM service the presence is coming from. Formatted using either 654 * {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)} or 655 * {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}. 656 * <P>Type: TEXT</P> 657 */ 658 public static final String IM_PROTOCOL = "im_protocol"; 659 660 /** 661 * The IM handle the presence item is for. The handle is scoped to the 662 * {@link #IM_PROTOCOL}. 663 * <P>Type: TEXT</P> 664 */ 665 public static final String IM_HANDLE = "im_handle"; 666 667 /** 668 * The IM account for the local user that the presence data came from. 669 * <P>Type: TEXT</P> 670 */ 671 public static final String IM_ACCOUNT = "im_account"; 672 } 673 674 public static final class Presence implements PresenceColumns, Im.CommonPresenceColumns { 675 /** 676 * This utility class cannot be instantiated 677 */ 678 private Presence() { 679 } 680 681 /** 682 * The content:// style URI for this table 683 */ 684 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence"); 685 686 /** 687 * Gets the resource ID for the proper presence icon. 688 * 689 * @param status the status to get the icon for 690 * @return the resource ID for the proper presence icon 691 */ 692 public static final int getPresenceIconResourceId(int status) { 693 switch (status) { 694 case AVAILABLE: 695 return android.R.drawable.presence_online; 696 case IDLE: 697 case AWAY: 698 return android.R.drawable.presence_away; 699 case DO_NOT_DISTURB: 700 return android.R.drawable.presence_busy; 701 case INVISIBLE: 702 return android.R.drawable.presence_invisible; 703 case OFFLINE: 704 default: 705 return android.R.drawable.presence_offline; 706 } 707 } 708 709 /** 710 * Returns the precedence of the status code the higher number being the higher precedence. 711 * 712 * @param status The status code. 713 * @return An integer representing the precedence, 0 being the lowest. 714 */ 715 public static final int getPresencePrecedence(int status) { 716 // Keep this function here incase we want to enforce a different precedence than the 717 // natural order of the status constants. 718 return status; 719 } 720 721 /** 722 * The MIME type of {@link #CONTENT_URI} providing a directory of 723 * presence details. 724 */ 725 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence"; 726 727 /** 728 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 729 * presence detail. 730 */ 731 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence"; 732 } 733 734 /** 735 * Container for definitions of common data types stored in the {@link Data} table. 736 */ 737 public static final class CommonDataKinds { 738 /** 739 * The {@link Data#RES_PACKAGE} value for common data that should be 740 * shown using a default style. 741 */ 742 public static final String PACKAGE_COMMON = "common"; 743 744 /** 745 * Columns common across the specific types. 746 */ 747 private interface BaseCommonColumns { 748 /** 749 * The package name to use when creating {@link Resources} objects for 750 * this data row. This value is only designed for use when building user 751 * interfaces, and should not be used to infer the owner. 752 */ 753 public static final String RES_PACKAGE = "res_package"; 754 755 /** 756 * The MIME type of the item represented by this row. 757 */ 758 public static final String MIMETYPE = "mimetype"; 759 760 /** 761 * The {@link RawContacts#_ID} that this data belongs to. 762 */ 763 public static final String RAW_CONTACT_ID = "raw_contact_id"; 764 } 765 766 /** 767 * The base types that all "Typed" data kinds support. 768 */ 769 public interface BaseTypes { 770 771 /** 772 * A custom type. The custom label should be supplied by user. 773 */ 774 public static int TYPE_CUSTOM = 0; 775 } 776 777 /** 778 * Columns common across the specific types. 779 */ 780 private interface CommonColumns extends BaseTypes{ 781 /** 782 * The type of data, for example Home or Work. 783 * <P>Type: INTEGER</P> 784 */ 785 public static final String TYPE = "data1"; 786 787 /** 788 * The data for the contact method. 789 * <P>Type: TEXT</P> 790 */ 791 public static final String DATA = "data2"; 792 793 /** 794 * The user defined label for the the contact method. 795 * <P>Type: TEXT</P> 796 */ 797 public static final String LABEL = "data3"; 798 } 799 800 /** 801 * Parts of the name. 802 */ 803 public static final class StructuredName implements BaseCommonColumns { 804 private StructuredName() {} 805 806 /** MIME type used when storing this in data table. */ 807 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; 808 809 /** 810 * The given name for the contact. 811 * <P>Type: TEXT</P> 812 */ 813 public static final String GIVEN_NAME = "data1"; 814 815 /** 816 * The family name for the contact. 817 * <P>Type: TEXT</P> 818 */ 819 public static final String FAMILY_NAME = "data2"; 820 821 /** 822 * The contact's honorific prefix, e.g. "Sir" 823 * <P>Type: TEXT</P> 824 */ 825 public static final String PREFIX = "data3"; 826 827 /** 828 * The contact's middle name 829 * <P>Type: TEXT</P> 830 */ 831 public static final String MIDDLE_NAME = "data4"; 832 833 /** 834 * The contact's honorific suffix, e.g. "Jr" 835 */ 836 public static final String SUFFIX = "data5"; 837 838 /** 839 * The phonetic version of the given name for the contact. 840 * <P>Type: TEXT</P> 841 */ 842 public static final String PHONETIC_GIVEN_NAME = "data6"; 843 844 /** 845 * The phonetic version of the additional name for the contact. 846 * <P>Type: TEXT</P> 847 */ 848 public static final String PHONETIC_MIDDLE_NAME = "data7"; 849 850 /** 851 * The phonetic version of the family name for the contact. 852 * <P>Type: TEXT</P> 853 */ 854 public static final String PHONETIC_FAMILY_NAME = "data8"; 855 856 /** 857 * The name that should be used to display the contact. 858 * <i>Unstructured component of the name should be consistent with 859 * its structured representation.</i> 860 * <p> 861 * Type: TEXT 862 */ 863 public static final String DISPLAY_NAME = "data9"; 864 } 865 866 /** 867 * A nickname. 868 */ 869 public static final class Nickname implements CommonColumns, BaseCommonColumns { 870 private Nickname() {} 871 872 /** MIME type used when storing this in data table. */ 873 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; 874 875 public static final int TYPE_DEFAULT = 1; 876 public static final int TYPE_OTHER_NAME = 2; 877 public static final int TYPE_MAINDEN_NAME = 3; 878 public static final int TYPE_SHORT_NAME = 4; 879 public static final int TYPE_INITIALS = 5; 880 881 /** 882 * The name itself 883 */ 884 public static final String NAME = DATA; 885 } 886 887 /** 888 * Common data definition for telephone numbers. 889 */ 890 public static final class Phone implements BaseCommonColumns, CommonColumns { 891 private Phone() {} 892 893 /** MIME type used when storing this in data table. */ 894 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone"; 895 896 /** 897 * The MIME type of {@link #CONTENT_URI} providing a directory of 898 * phones. 899 */ 900 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone"; 901 902 /** 903 * The content:// style URI for all data records of the 904 * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the 905 * associated raw contact and aggregate contact data. 906 */ 907 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 908 "phones"); 909 910 /** 911 * The content:// style URI for filtering data records of the 912 * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the 913 * associated raw contact and aggregate contact data. The filter argument should 914 * be passed as an additional path segment after this URI. 915 */ 916 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 917 "filter"); 918 919 public static final int TYPE_HOME = 1; 920 public static final int TYPE_MOBILE = 2; 921 public static final int TYPE_WORK = 3; 922 public static final int TYPE_FAX_WORK = 4; 923 public static final int TYPE_FAX_HOME = 5; 924 public static final int TYPE_PAGER = 6; 925 public static final int TYPE_OTHER = 7; 926 public static final int TYPE_CALLBACK = 8; 927 public static final int TYPE_CAR = 9; 928 public static final int TYPE_COMPANY_MAIN = 10; 929 public static final int TYPE_ISDN = 11; 930 public static final int TYPE_MAIN = 12; 931 public static final int TYPE_OTHER_FAX = 13; 932 public static final int TYPE_RADIO = 14; 933 public static final int TYPE_TELEX = 15; 934 public static final int TYPE_TTY_TDD = 16; 935 public static final int TYPE_WORK_MOBILE = 17; 936 public static final int TYPE_WORK_PAGER = 18; 937 public static final int TYPE_ASSISTANT = 19; 938 939 /** 940 * The phone number as the user entered it. 941 * <P>Type: TEXT</P> 942 */ 943 public static final String NUMBER = DATA; 944 945 public static final CharSequence getDisplayLabel(Context context, int type, 946 CharSequence label, CharSequence[] labelArray) { 947 CharSequence display = ""; 948 949 if (type != Phone.TYPE_CUSTOM) { 950 CharSequence[] labels = labelArray != null? labelArray 951 : context.getResources().getTextArray( 952 com.android.internal.R.array.phoneTypes); 953 try { 954 display = labels[type - 1]; 955 } catch (ArrayIndexOutOfBoundsException e) { 956 display = labels[Phone.TYPE_CUSTOM]; 957 } 958 } else { 959 if (!TextUtils.isEmpty(label)) { 960 display = label; 961 } 962 } 963 return display; 964 } 965 966 public static final CharSequence getDisplayLabel(Context context, int type, 967 CharSequence label) { 968 return getDisplayLabel(context, type, label, null); 969 } 970 } 971 972 /** 973 * Common data definition for email addresses. 974 */ 975 public static final class Email implements BaseCommonColumns, CommonColumns { 976 private Email() {} 977 978 /** MIME type used when storing this in data table. */ 979 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email"; 980 981 /** 982 * The content:// style URI for all data records of the 983 * {@link Email#CONTENT_ITEM_TYPE} MIME type, combined with the 984 * associated raw contact and aggregate contact data. 985 */ 986 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 987 "emails"); 988 989 /** 990 * The content:// style URL for filtering data rows by email address. The 991 * filter argument should be passed as an additional path segment after 992 * this URI. 993 */ 994 public static final Uri CONTENT_FILTER_EMAIL_URI = Uri.withAppendedPath(CONTENT_URI, 995 "filter"); 996 997 public static final int TYPE_HOME = 1; 998 public static final int TYPE_WORK = 2; 999 public static final int TYPE_OTHER = 3; 1000 1001 /** 1002 * The display name for the email address 1003 * <P>Type: TEXT</P> 1004 */ 1005 public static final String DISPLAY_NAME = "data4"; 1006 } 1007 1008 /** 1009 * Common data definition for postal addresses. 1010 */ 1011 public static final class StructuredPostal implements BaseCommonColumns, CommonColumns { 1012 private StructuredPostal() { 1013 } 1014 1015 /** MIME type used when storing this in data table. */ 1016 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/postal-address"; 1017 1018 /** 1019 * The MIME type of {@link #CONTENT_URI} providing a directory of 1020 * postal addresses. 1021 */ 1022 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address"; 1023 1024 /** 1025 * The content:// style URI for all data records of the 1026 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. 1027 */ 1028 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 1029 "postals"); 1030 1031 public static final int TYPE_HOME = 1; 1032 public static final int TYPE_WORK = 2; 1033 public static final int TYPE_OTHER = 3; 1034 1035 /** 1036 * The full, unstructured postal address. <i>This field must be 1037 * consistent with any structured data.</i> 1038 * <p> 1039 * Type: TEXT 1040 */ 1041 public static final String FORMATTED_ADDRESS = DATA; 1042 1043 /** 1044 * The agent who actually receives the mail. Used in work addresses. 1045 * Also for 'in care of' or 'c/o'. 1046 * <p> 1047 * Type: TEXT 1048 * @deprecated since this isn't supported by gd:structuredPostalAddress 1049 */ 1050 @Deprecated 1051 public static final String AGENT = "data4"; 1052 1053 /** 1054 * Used in places where houses or buildings have names (and not 1055 * necessarily numbers), eg. "The Pillars". 1056 * <p> 1057 * Type: TEXT 1058 * @deprecated since this isn't supported by gd:structuredPostalAddress 1059 */ 1060 @Deprecated 1061 public static final String HOUSENAME = "data5"; 1062 1063 /** 1064 * Can be street, avenue, road, etc. This element also includes the 1065 * house number and room/apartment/flat/floor number. 1066 * <p> 1067 * Type: TEXT 1068 */ 1069 public static final String STREET = "data6"; 1070 1071 /** 1072 * Covers actual P.O. boxes, drawers, locked bags, etc. This is 1073 * usually but not always mutually exclusive with street. 1074 * <p> 1075 * Type: TEXT 1076 */ 1077 public static final String POBOX = "data7"; 1078 1079 /** 1080 * This is used to disambiguate a street address when a city 1081 * contains more than one street with the same name, or to specify a 1082 * small place whose mail is routed through a larger postal town. In 1083 * China it could be a county or a minor city. 1084 * <p> 1085 * Type: TEXT 1086 */ 1087 public static final String NEIGHBORHOOD = "data8"; 1088 1089 /** 1090 * Can be city, village, town, borough, etc. This is the postal town 1091 * and not necessarily the place of residence or place of business. 1092 * <p> 1093 * Type: TEXT 1094 */ 1095 public static final String CITY = "data9"; 1096 1097 /** 1098 * Handles administrative districts such as U.S. or U.K. counties 1099 * that are not used for mail addressing purposes. Subregion is not 1100 * intended for delivery addresses. 1101 * <p> 1102 * Type: TEXT 1103 * @deprecated since this isn't supported by gd:structuredPostalAddress 1104 */ 1105 @Deprecated 1106 public static final String SUBREGION = "data10"; 1107 1108 /** 1109 * A state, province, county (in Ireland), Land (in Germany), 1110 * departement (in France), etc. 1111 * <p> 1112 * Type: TEXT 1113 */ 1114 public static final String REGION = "data11"; 1115 1116 /** 1117 * Postal code. Usually country-wide, but sometimes specific to the 1118 * city (e.g. "2" in "Dublin 2, Ireland" addresses). 1119 * <p> 1120 * Type: TEXT 1121 */ 1122 public static final String POSTCODE = "data12"; 1123 1124 /** 1125 * The name or code of the country. 1126 * <p> 1127 * Type: TEXT 1128 */ 1129 public static final String COUNTRY = "data13"; 1130 } 1131 1132 /** 1133 * Common data definition for IM addresses. 1134 */ 1135 public static final class Im implements BaseCommonColumns, CommonColumns { 1136 private Im() {} 1137 1138 /** MIME type used when storing this in data table. */ 1139 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; 1140 1141 public static final int TYPE_HOME = 1; 1142 public static final int TYPE_WORK = 2; 1143 public static final int TYPE_OTHER = 3; 1144 1145 public static final String PROTOCOL = "data5"; 1146 1147 public static final String CUSTOM_PROTOCOL = "data6"; 1148 1149 /** 1150 * The predefined IM protocol types. The protocol can either be non-present, one 1151 * of these types, or a free-form string. These cases are encoded in the PROTOCOL 1152 * column as: 1153 * <ul> 1154 * <li>null</li> 1155 * <li>pre:<an integer, one of the protocols below></li> 1156 * <li>custom:<a string></li> 1157 * </ul> 1158 */ 1159 public static final int PROTOCOL_CUSTOM = -1; 1160 public static final int PROTOCOL_AIM = 0; 1161 public static final int PROTOCOL_MSN = 1; 1162 public static final int PROTOCOL_YAHOO = 2; 1163 public static final int PROTOCOL_SKYPE = 3; 1164 public static final int PROTOCOL_QQ = 4; 1165 public static final int PROTOCOL_GOOGLE_TALK = 5; 1166 public static final int PROTOCOL_ICQ = 6; 1167 public static final int PROTOCOL_JABBER = 7; 1168 public static final int PROTOCOL_NETMEETING = 8; 1169 } 1170 1171 /** 1172 * Common data definition for organizations. 1173 */ 1174 public static final class Organization implements BaseCommonColumns, CommonColumns { 1175 private Organization() {} 1176 1177 /** MIME type used when storing this in data table. */ 1178 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; 1179 1180 public static final int TYPE_WORK = 1; 1181 public static final int TYPE_OTHER = 2; 1182 1183 /** 1184 * The company as the user entered it. 1185 * <P>Type: TEXT</P> 1186 */ 1187 public static final String COMPANY = DATA; 1188 1189 /** 1190 * The position title at this company as the user entered it. 1191 * <P>Type: TEXT</P> 1192 */ 1193 public static final String TITLE = "data4"; 1194 1195 /** 1196 * The department at this company as the user entered it. 1197 * <P>Type: TEXT</P> 1198 */ 1199 public static final String DEPARTMENT = "data5"; 1200 1201 /** 1202 * The job description at this company as the user entered it. 1203 * <P>Type: TEXT</P> 1204 */ 1205 public static final String JOB_DESCRIPTION = "data6"; 1206 1207 /** 1208 * The symbol of this company as the user entered it. 1209 * <P>Type: TEXT</P> 1210 */ 1211 public static final String SYMBOL = "data7"; 1212 1213 /** 1214 * The phonetic name of this company as the user entered it. 1215 * <P>Type: TEXT</P> 1216 */ 1217 public static final String PHONETIC_NAME = "data8"; 1218 } 1219 1220 /** 1221 * Common data definition for miscellaneous information. 1222 */ 1223 public static final class Miscellaneous implements BaseCommonColumns { 1224 private Miscellaneous() {} 1225 1226 /** MIME type used when storing this in data table. */ 1227 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/misc"; 1228 1229 /** 1230 * The birthday as the user entered it. 1231 * <P>Type: TEXT</P> 1232 */ 1233 public static final String BIRTHDAY = "data1"; 1234 1235 /** 1236 * The nickname as the user entered it. 1237 * <P>Type: TEXT</P> 1238 */ 1239 public static final String NICKNAME = "data2"; 1240 } 1241 1242 /** 1243 * Common data definition for relations. 1244 */ 1245 public static final class Relation implements BaseCommonColumns, CommonColumns { 1246 private Relation() {} 1247 1248 /** MIME type used when storing this in data table. */ 1249 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; 1250 1251 public static final int TYPE_ASSISTANT = 1; 1252 public static final int TYPE_BROTHER = 2; 1253 public static final int TYPE_CHILD = 3; 1254 public static final int TYPE_DOMESTIC_PARTNER = 4; 1255 public static final int TYPE_FATHER = 5; 1256 public static final int TYPE_FRIEND = 6; 1257 public static final int TYPE_MANAGER = 7; 1258 public static final int TYPE_MOTHER = 8; 1259 public static final int TYPE_PARENT = 9; 1260 public static final int TYPE_PARTNER = 10; 1261 public static final int TYPE_REFERRED_BY = 11; 1262 public static final int TYPE_RELATIVE = 12; 1263 public static final int TYPE_SISTER = 13; 1264 public static final int TYPE_SPOUSE = 14; 1265 1266 /** 1267 * The name of the relative as the user entered it. 1268 * <P>Type: TEXT</P> 1269 */ 1270 public static final String NAME = DATA; 1271 } 1272 1273 /** 1274 * Common data definition for events. 1275 */ 1276 public static final class Event implements BaseCommonColumns, CommonColumns { 1277 private Event() {} 1278 1279 /** MIME type used when storing this in data table. */ 1280 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event"; 1281 1282 public static final int TYPE_ANNIVERSARY = 1; 1283 public static final int TYPE_OTHER = 2; 1284 1285 /** 1286 * The event start date as the user entered it. 1287 * <P>Type: TEXT</P> 1288 */ 1289 public static final String START_DATE = DATA; 1290 } 1291 1292 /** 1293 * Photo of the contact. 1294 */ 1295 public static final class Photo implements BaseCommonColumns { 1296 private Photo() {} 1297 1298 /** MIME type used when storing this in data table. */ 1299 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; 1300 1301 /** 1302 * Thumbnail photo of the raw contact. This is the raw bytes of an image 1303 * that could be inflated using {@link BitmapFactory}. 1304 * <p> 1305 * Type: BLOB 1306 */ 1307 public static final String PHOTO = "data1"; 1308 } 1309 1310 /** 1311 * Notes about the contact. 1312 */ 1313 public static final class Note implements BaseCommonColumns { 1314 private Note() {} 1315 1316 /** MIME type used when storing this in data table. */ 1317 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; 1318 1319 /** 1320 * The note text. 1321 * <P>Type: TEXT</P> 1322 */ 1323 public static final String NOTE = "data1"; 1324 } 1325 1326 /** 1327 * Group Membership. 1328 */ 1329 public static final class GroupMembership implements BaseCommonColumns { 1330 private GroupMembership() {} 1331 1332 /** MIME type used when storing this in data table. */ 1333 public static final String CONTENT_ITEM_TYPE = 1334 "vnd.android.cursor.item/group_membership"; 1335 1336 /** 1337 * The row id of the group that this group membership refers to. Exactly one of 1338 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. 1339 * <P>Type: INTEGER</P> 1340 */ 1341 public static final String GROUP_ROW_ID = "data1"; 1342 1343 /** 1344 * The sourceid of the group that this group membership refers to. Exactly one of 1345 * this or {@link #GROUP_ROW_ID} must be set when inserting a row. 1346 * <P>Type: TEXT</P> 1347 */ 1348 public static final String GROUP_SOURCE_ID = "group_sourceid"; 1349 } 1350 1351 /** 1352 * Website related to the contact. 1353 */ 1354 public static final class Website implements BaseCommonColumns, CommonColumns { 1355 private Website() {} 1356 1357 /** MIME type used when storing this in data table. */ 1358 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; 1359 1360 public static final int TYPE_HOMEPAGE = 1; 1361 public static final int TYPE_BLOG = 2; 1362 public static final int TYPE_PROFILE = 3; 1363 public static final int TYPE_HOME = 4; 1364 public static final int TYPE_WORK = 5; 1365 public static final int TYPE_FTP = 6; 1366 public static final int TYPE_OTHER = 7; 1367 1368 /** 1369 * The website URL string. 1370 * <P>Type: TEXT</P> 1371 */ 1372 public static final String URL = "data1"; 1373 } 1374 } 1375 1376 // TODO: make this private before unhiding 1377 public interface GroupsColumns { 1378 /** 1379 * The display title of this group. 1380 * <p> 1381 * Type: TEXT 1382 */ 1383 public static final String TITLE = "title"; 1384 1385 /** 1386 * The package name to use when creating {@link Resources} objects for 1387 * this group. This value is only designed for use when building user 1388 * interfaces, and should not be used to infer the owner. 1389 */ 1390 public static final String RES_PACKAGE = "res_package"; 1391 1392 /** 1393 * The display title of this group to load as a resource from 1394 * {@link #RES_PACKAGE}, which may be localized. 1395 * <P>Type: TEXT</P> 1396 */ 1397 public static final String TITLE_RES = "title_res"; 1398 1399 /** 1400 * Notes about the group. 1401 * <p> 1402 * Type: TEXT 1403 */ 1404 public static final String NOTES = "notes"; 1405 1406 /** 1407 * The ID of this group if it is a System Group, i.e. a group that has a special meaning 1408 * to the sync adapter, null otherwise. 1409 * <P>Type: TEXT</P> 1410 */ 1411 public static final String SYSTEM_ID = "system_id"; 1412 1413 /** 1414 * The total number of {@link Contacts} that have 1415 * {@link GroupMembership} in this group. Read-only value that is only 1416 * present when querying {@link Groups#CONTENT_SUMMARY_URI}. 1417 * <p> 1418 * Type: INTEGER 1419 */ 1420 public static final String SUMMARY_COUNT = "summ_count"; 1421 1422 /** 1423 * The total number of {@link Contacts} that have both 1424 * {@link GroupMembership} in this group, and also have phone numbers. 1425 * Read-only value that is only present when querying 1426 * {@link Groups#CONTENT_SUMMARY_URI}. 1427 * <p> 1428 * Type: INTEGER 1429 */ 1430 public static final String SUMMARY_WITH_PHONES = "summ_phones"; 1431 1432 /** 1433 * Flag indicating if the contacts belonging to this group should be 1434 * visible in any user interface. 1435 * <p> 1436 * Type: INTEGER (boolean) 1437 */ 1438 public static final String GROUP_VISIBLE = "group_visible"; 1439 1440 /** 1441 * The "deleted" flag: "0" by default, "1" if the row has been marked 1442 * for deletion. When {@link android.content.ContentResolver#delete} is 1443 * called on a raw contact, it is marked for deletion and removed from its 1444 * aggregate contact. The sync adaptor deletes the raw contact on the server and 1445 * then calls ContactResolver.delete once more, this time passing the 1446 * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal. 1447 * <P>Type: INTEGER</P> 1448 */ 1449 public static final String DELETED = "deleted"; 1450 1451 /** 1452 * Whether this group should be synced if the SYNC_EVERYTHING settings 1453 * is false for this group's account. 1454 * <p> 1455 * Type: INTEGER (boolean) 1456 */ 1457 public static final String SHOULD_SYNC = "should_sync"; 1458 } 1459 1460 /** 1461 * Constants for the groups table. 1462 */ 1463 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { 1464 /** 1465 * This utility class cannot be instantiated 1466 */ 1467 private Groups() { 1468 } 1469 1470 /** 1471 * The content:// style URI for this table 1472 */ 1473 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); 1474 1475 /** 1476 * The content:// style URI for this table joined with details data from 1477 * {@link Data}. 1478 */ 1479 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, 1480 "groups_summary"); 1481 1482 /** 1483 * The MIME type of a directory of groups. 1484 */ 1485 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; 1486 1487 /** 1488 * The MIME type of a single group. 1489 */ 1490 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; 1491 1492 /** 1493 * Query parameter that can be passed with the {@link #CONTENT_URI} URI 1494 * to the {@link android.content.ContentResolver#delete} method to 1495 * indicate that the raw contact can be deleted physically, rather than 1496 * merely marked as deleted. 1497 */ 1498 public static final String DELETE_PERMANENTLY = "delete_permanently"; 1499 1500 /** 1501 * An optional update or insert URI parameter that determines if the 1502 * group should be marked as dirty. The default value is true. 1503 */ 1504 public static final String MARK_AS_DIRTY = "mark_as_dirty"; 1505 } 1506 1507 /** 1508 * Constants for the contact aggregation exceptions table, which contains 1509 * aggregation rules overriding those used by automatic aggregation. This type only 1510 * supports query and update. Neither insert nor delete are supported. 1511 */ 1512 public static final class AggregationExceptions implements BaseColumns { 1513 /** 1514 * This utility class cannot be instantiated 1515 */ 1516 private AggregationExceptions() {} 1517 1518 /** 1519 * The content:// style URI for this table 1520 */ 1521 public static final Uri CONTENT_URI = 1522 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); 1523 1524 /** 1525 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 1526 */ 1527 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; 1528 1529 /** 1530 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception 1531 */ 1532 public static final String CONTENT_ITEM_TYPE = 1533 "vnd.android.cursor.item/aggregation_exception"; 1534 1535 /** 1536 * The type of exception: {@link #TYPE_KEEP_IN}, {@link #TYPE_KEEP_OUT} or 1537 * {@link #TYPE_AUTOMATIC}. 1538 * 1539 * <P>Type: INTEGER</P> 1540 */ 1541 public static final String TYPE = "type"; 1542 1543 /** 1544 * Allows the provider to automatically decide whether the aggregate 1545 * contact should include a particular raw contact or not. 1546 */ 1547 public static final int TYPE_AUTOMATIC = 0; 1548 1549 /** 1550 * Makes sure that the specified raw contact is included in the 1551 * specified aggregate contact. 1552 */ 1553 public static final int TYPE_KEEP_IN = 1; 1554 1555 /** 1556 * Makes sure that the specified raw contact is NOT included in the 1557 * specified aggregate contact. 1558 */ 1559 public static final int TYPE_KEEP_OUT = 2; 1560 1561 /** 1562 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the 1563 * aggregate contact that the rule applies to. 1564 */ 1565 public static final String CONTACT_ID = "contact_id"; 1566 1567 /** 1568 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. 1569 */ 1570 public static final String RAW_CONTACT_ID = "raw_contact_id"; 1571 } 1572 1573 private interface SettingsColumns { 1574 /** 1575 * The name of the account instance to which this row belongs. 1576 * <P>Type: TEXT</P> 1577 */ 1578 public static final String ACCOUNT_NAME = "account_name"; 1579 1580 /** 1581 * The type of account to which this row belongs, which when paired with 1582 * {@link #ACCOUNT_NAME} identifies a specific account. 1583 * <P>Type: TEXT</P> 1584 */ 1585 public static final String ACCOUNT_TYPE = "account_type"; 1586 1587 /** 1588 * Setting to indicate how this source handles {@link #SHOULD_SYNC} and 1589 * {@link Groups#SHOULD_SYNC} flags. This mode should be one of 1590 * {@link Settings#SYNC_MODE_EVERYTHING}, 1591 * {@link Settings#SYNC_MODE_UNGROUPED}, or 1592 * {@link Settings#SYNC_MODE_UNSUPPORTED}. 1593 * <p> 1594 * Type: INTEGER 1595 */ 1596 public static final String SHOULD_SYNC_MODE = "should_sync_mode"; 1597 1598 /** 1599 * When modes is {@link Settings#SYNC_MODE_EVERYTHING}, this flag 1600 * overrides any children {@link Groups#SHOULD_SYNC} when set. When mode 1601 * is {@link Settings#SYNC_MODE_UNGROUPED}, this flag indicates the 1602 * syncing behavior for contacts not belonging to any group. 1603 * <p> 1604 * Type: INTEGER (boolean) 1605 */ 1606 public static final String SHOULD_SYNC = "should_sync"; 1607 1608 /** 1609 * Flag indicating if contacts without any {@link GroupMembership} 1610 * entries should be visible in any user interface. 1611 * <p> 1612 * Type: INTEGER (boolean) 1613 */ 1614 public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; 1615 } 1616 1617 /** 1618 * Contacts-specific settings for various {@link Account}. 1619 */ 1620 public static final class Settings implements BaseColumns, SettingsColumns { 1621 /** 1622 * This utility class cannot be instantiated 1623 */ 1624 private Settings() { 1625 } 1626 1627 /** 1628 * The content:// style URI for this table 1629 */ 1630 public static final Uri CONTENT_URI = 1631 Uri.withAppendedPath(AUTHORITY_URI, "settings"); 1632 1633 /** 1634 * The MIME-type of {@link #CONTENT_URI} providing a directory of 1635 * settings. 1636 */ 1637 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; 1638 1639 /** 1640 * The MIME-type of {@link #CONTENT_URI} providing a single setting. 1641 */ 1642 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; 1643 1644 /** 1645 * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source 1646 * doesn't support per-group {@link Groups#SHOULD_SYNC} flags. 1647 */ 1648 public static final int SYNC_MODE_UNSUPPORTED = 0; 1649 1650 /** 1651 * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source 1652 * fully supports per-group {@link Groups#SHOULD_SYNC} flags and assumes 1653 * that {@link #SHOULD_SYNC} refers to contacts without any 1654 * {@link GroupMembership}. 1655 */ 1656 public static final int SYNC_MODE_UNGROUPED = 1; 1657 1658 /** 1659 * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source 1660 * fully supports per-group {@link Groups#SHOULD_SYNC} flags but assumes 1661 * that {@link #SHOULD_SYNC} overrides per-group flags when set. 1662 */ 1663 public static final int SYNC_MODE_EVERYTHING = 2; 1664 } 1665 1666 /** 1667 * Contains helper classes used to create or manage {@link android.content.Intent Intents} 1668 * that involve contacts. 1669 */ 1670 public static final class Intents { 1671 /** 1672 * This is the intent that is fired when a search suggestion is clicked on. 1673 */ 1674 public static final String SEARCH_SUGGESTION_CLICKED = 1675 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; 1676 1677 /** 1678 * This is the intent that is fired when a search suggestion for dialing a number 1679 * is clicked on. 1680 */ 1681 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = 1682 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; 1683 1684 /** 1685 * This is the intent that is fired when a search suggestion for creating a contact 1686 * is clicked on. 1687 */ 1688 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = 1689 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; 1690 1691 /** 1692 * Starts an Activity that lets the user pick a contact to attach an image to. 1693 * After picking the contact it launches the image cropper in face detection mode. 1694 */ 1695 public static final String ATTACH_IMAGE = 1696 "com.android.contacts.action.ATTACH_IMAGE"; 1697 1698 /** 1699 * Takes as input a data URI with a mailto: or tel: scheme. If a single 1700 * contact exists with the given data it will be shown. If no contact 1701 * exists, a dialog will ask the user if they want to create a new 1702 * contact with the provided details filled in. If multiple contacts 1703 * share the data the user will be prompted to pick which contact they 1704 * want to view. 1705 * <p> 1706 * For <code>mailto:</code> URIs, the scheme specific portion must be a 1707 * raw email address, such as one built using 1708 * {@link Uri#fromParts(String, String, String)}. 1709 * <p> 1710 * For <code>tel:</code> URIs, the scheme specific portion is compared 1711 * to existing numbers using the standard caller ID lookup algorithm. 1712 * The number must be properly encoded, for example using 1713 * {@link Uri#fromParts(String, String, String)}. 1714 * <p> 1715 * Any extras from the {@link Insert} class will be passed along to the 1716 * create activity if there are no contacts to show. 1717 * <p> 1718 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip 1719 * prompting the user when the contact doesn't exist. 1720 */ 1721 public static final String SHOW_OR_CREATE_CONTACT = 1722 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; 1723 1724 /** 1725 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new 1726 * contact if no matching contact found. Otherwise, default behavior is 1727 * to prompt user with dialog before creating. 1728 * <p> 1729 * Type: BOOLEAN 1730 */ 1731 public static final String EXTRA_FORCE_CREATE = 1732 "com.android.contacts.action.FORCE_CREATE"; 1733 1734 /** 1735 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact 1736 * description to be shown when prompting user about creating a new 1737 * contact. 1738 * <p> 1739 * Type: STRING 1740 */ 1741 public static final String EXTRA_CREATE_DESCRIPTION = 1742 "com.android.contacts.action.CREATE_DESCRIPTION"; 1743 1744 /** 1745 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 1746 * dialog location using screen coordinates. When not specified, the 1747 * dialog will be centered. 1748 */ 1749 public static final String EXTRA_TARGET_RECT = "target_rect"; 1750 1751 /** 1752 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 1753 * desired dialog style, usually a variation on size. One of 1754 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. 1755 */ 1756 public static final String EXTRA_MODE = "mode"; 1757 1758 /** 1759 * Value for {@link #EXTRA_MODE} to show a small-sized dialog. 1760 */ 1761 public static final int MODE_SMALL = 1; 1762 1763 /** 1764 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. 1765 */ 1766 public static final int MODE_MEDIUM = 2; 1767 1768 /** 1769 * Value for {@link #EXTRA_MODE} to show a large-sized dialog. 1770 */ 1771 public static final int MODE_LARGE = 3; 1772 1773 /** 1774 * Intents related to the Contacts app UI. 1775 */ 1776 public static final class UI { 1777 /** 1778 * The action for the default contacts list tab. 1779 */ 1780 public static final String LIST_DEFAULT = 1781 "com.android.contacts.action.LIST_DEFAULT"; 1782 1783 /** 1784 * The action for the contacts list tab. 1785 */ 1786 public static final String LIST_GROUP_ACTION = 1787 "com.android.contacts.action.LIST_GROUP"; 1788 1789 /** 1790 * When in LIST_GROUP_ACTION mode, this is the group to display. 1791 */ 1792 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; 1793 1794 /** 1795 * The action for the all contacts list tab. 1796 */ 1797 public static final String LIST_ALL_CONTACTS_ACTION = 1798 "com.android.contacts.action.LIST_ALL_CONTACTS"; 1799 1800 /** 1801 * The action for the contacts with phone numbers list tab. 1802 */ 1803 public static final String LIST_CONTACTS_WITH_PHONES_ACTION = 1804 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; 1805 1806 /** 1807 * The action for the starred contacts list tab. 1808 */ 1809 public static final String LIST_STARRED_ACTION = 1810 "com.android.contacts.action.LIST_STARRED"; 1811 1812 /** 1813 * The action for the frequent contacts list tab. 1814 */ 1815 public static final String LIST_FREQUENT_ACTION = 1816 "com.android.contacts.action.LIST_FREQUENT"; 1817 1818 /** 1819 * The action for the "strequent" contacts list tab. It first lists the starred 1820 * contacts in alphabetical order and then the frequent contacts in descending 1821 * order of the number of times they have been contacted. 1822 */ 1823 public static final String LIST_STREQUENT_ACTION = 1824 "com.android.contacts.action.LIST_STREQUENT"; 1825 1826 /** 1827 * A key for to be used as an intent extra to set the activity 1828 * title to a custom String value. 1829 */ 1830 public static final String TITLE_EXTRA_KEY = 1831 "com.android.contacts.extra.TITLE_EXTRA"; 1832 1833 /** 1834 * Activity Action: Display a filtered list of contacts 1835 * <p> 1836 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for 1837 * filtering 1838 * <p> 1839 * Output: Nothing. 1840 */ 1841 public static final String FILTER_CONTACTS_ACTION = 1842 "com.android.contacts.action.FILTER_CONTACTS"; 1843 1844 /** 1845 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} 1846 * intents to supply the text on which to filter. 1847 */ 1848 public static final String FILTER_TEXT_EXTRA_KEY = 1849 "com.android.contacts.extra.FILTER_TEXT"; 1850 } 1851 1852 /** 1853 * Convenience class that contains string constants used 1854 * to create contact {@link android.content.Intent Intents}. 1855 */ 1856 public static final class Insert { 1857 /** The action code to use when adding a contact */ 1858 public static final String ACTION = Intent.ACTION_INSERT; 1859 1860 /** 1861 * If present, forces a bypass of quick insert mode. 1862 */ 1863 public static final String FULL_MODE = "full_mode"; 1864 1865 /** 1866 * The extra field for the contact name. 1867 * <P>Type: String</P> 1868 */ 1869 public static final String NAME = "name"; 1870 1871 // TODO add structured name values here. 1872 1873 /** 1874 * The extra field for the contact phonetic name. 1875 * <P>Type: String</P> 1876 */ 1877 public static final String PHONETIC_NAME = "phonetic_name"; 1878 1879 /** 1880 * The extra field for the contact company. 1881 * <P>Type: String</P> 1882 */ 1883 public static final String COMPANY = "company"; 1884 1885 /** 1886 * The extra field for the contact job title. 1887 * <P>Type: String</P> 1888 */ 1889 public static final String JOB_TITLE = "job_title"; 1890 1891 /** 1892 * The extra field for the contact notes. 1893 * <P>Type: String</P> 1894 */ 1895 public static final String NOTES = "notes"; 1896 1897 /** 1898 * The extra field for the contact phone number. 1899 * <P>Type: String</P> 1900 */ 1901 public static final String PHONE = "phone"; 1902 1903 /** 1904 * The extra field for the contact phone number type. 1905 * <P>Type: Either an integer value from 1906 * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, 1907 * or a string specifying a custom label.</P> 1908 */ 1909 public static final String PHONE_TYPE = "phone_type"; 1910 1911 /** 1912 * The extra field for the phone isprimary flag. 1913 * <P>Type: boolean</P> 1914 */ 1915 public static final String PHONE_ISPRIMARY = "phone_isprimary"; 1916 1917 /** 1918 * The extra field for an optional second contact phone number. 1919 * <P>Type: String</P> 1920 */ 1921 public static final String SECONDARY_PHONE = "secondary_phone"; 1922 1923 /** 1924 * The extra field for an optional second contact phone number type. 1925 * <P>Type: Either an integer value from 1926 * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, 1927 * or a string specifying a custom label.</P> 1928 */ 1929 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; 1930 1931 /** 1932 * The extra field for an optional third contact phone number. 1933 * <P>Type: String</P> 1934 */ 1935 public static final String TERTIARY_PHONE = "tertiary_phone"; 1936 1937 /** 1938 * The extra field for an optional third contact phone number type. 1939 * <P>Type: Either an integer value from 1940 * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, 1941 * or a string specifying a custom label.</P> 1942 */ 1943 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; 1944 1945 /** 1946 * The extra field for the contact email address. 1947 * <P>Type: String</P> 1948 */ 1949 public static final String EMAIL = "email"; 1950 1951 /** 1952 * The extra field for the contact email type. 1953 * <P>Type: Either an integer value from 1954 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} 1955 * or a string specifying a custom label.</P> 1956 */ 1957 public static final String EMAIL_TYPE = "email_type"; 1958 1959 /** 1960 * The extra field for the email isprimary flag. 1961 * <P>Type: boolean</P> 1962 */ 1963 public static final String EMAIL_ISPRIMARY = "email_isprimary"; 1964 1965 /** 1966 * The extra field for an optional second contact email address. 1967 * <P>Type: String</P> 1968 */ 1969 public static final String SECONDARY_EMAIL = "secondary_email"; 1970 1971 /** 1972 * The extra field for an optional second contact email type. 1973 * <P>Type: Either an integer value from 1974 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} 1975 * or a string specifying a custom label.</P> 1976 */ 1977 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; 1978 1979 /** 1980 * The extra field for an optional third contact email address. 1981 * <P>Type: String</P> 1982 */ 1983 public static final String TERTIARY_EMAIL = "tertiary_email"; 1984 1985 /** 1986 * The extra field for an optional third contact email type. 1987 * <P>Type: Either an integer value from 1988 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} 1989 * or a string specifying a custom label.</P> 1990 */ 1991 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; 1992 1993 /** 1994 * The extra field for the contact postal address. 1995 * <P>Type: String</P> 1996 */ 1997 public static final String POSTAL = "postal"; 1998 1999 /** 2000 * The extra field for the contact postal address type. 2001 * <P>Type: Either an integer value from 2002 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} 2003 * or a string specifying a custom label.</P> 2004 */ 2005 public static final String POSTAL_TYPE = "postal_type"; 2006 2007 /** 2008 * The extra field for the postal isprimary flag. 2009 * <P>Type: boolean</P> 2010 */ 2011 public static final String POSTAL_ISPRIMARY = "postal_isprimary"; 2012 2013 /** 2014 * The extra field for an IM handle. 2015 * <P>Type: String</P> 2016 */ 2017 public static final String IM_HANDLE = "im_handle"; 2018 2019 /** 2020 * The extra field for the IM protocol 2021 * <P>Type: the result of {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)} 2022 * or {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.</P> 2023 */ 2024 public static final String IM_PROTOCOL = "im_protocol"; 2025 2026 /** 2027 * The extra field for the IM isprimary flag. 2028 * <P>Type: boolean</P> 2029 */ 2030 public static final String IM_ISPRIMARY = "im_isprimary"; 2031 } 2032 } 2033 2034} 2035