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