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