ContactsContract.java revision 59024f1697e09ea50d4349e9813d0c101411292b
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.ContentValues; 25import android.content.Context; 26import android.content.CursorEntityIterator; 27import android.content.Entity; 28import android.content.EntityIterator; 29import android.content.Intent; 30import android.content.res.Resources; 31import android.database.Cursor; 32import android.database.DatabaseUtils; 33import android.graphics.Rect; 34import android.net.Uri; 35import android.net.Uri.Builder; 36import android.os.RemoteException; 37import android.text.TextUtils; 38import android.util.DisplayMetrics; 39import android.util.Pair; 40import android.view.View; 41 42import java.io.ByteArrayInputStream; 43import java.io.InputStream; 44import java.util.ArrayList; 45 46/** 47 * <p> 48 * The contract between the contacts provider and applications. Contains 49 * definitions for the supported URIs and columns. These APIs supersede 50 * {@link Contacts}. 51 * </p> 52 * <h3>Overview</h3> 53 * <p> 54 * ContactsContract defines an extensible database of contact-related 55 * information. Contact information is stored in a three-tier data model: 56 * </p> 57 * <ul> 58 * <li> 59 * A row in the {@link Data} table can store any kind of personal data, such 60 * as a phone number or email addresses. The set of data kinds that can be 61 * stored in this table is open-ended. There is a predefined set of common 62 * kinds, but any application can add its own data kinds. 63 * </li> 64 * <li> 65 * A row in the {@link RawContacts} table represents a set of data describing a 66 * person and associated with a single account (for example, one of the user's 67 * Gmail accounts). 68 * </li> 69 * <li> 70 * A row in the {@link Contacts} table represents an aggregate of one or more 71 * RawContacts presumably describing the same person. When data in or associated with 72 * the RawContacts table is changed, the affected aggregate contacts are updated as 73 * necessary. 74 * </li> 75 * </ul> 76 * <p> 77 * Other tables include: 78 * </p> 79 * <ul> 80 * <li> 81 * {@link Groups}, which contains information about raw contact groups 82 * such as Gmail contact groups. The 83 * current API does not support the notion of groups spanning multiple accounts. 84 * </li> 85 * <li> 86 * {@link StatusUpdates}, which contains social status updates including IM 87 * availability. 88 * </li> 89 * <li> 90 * {@link AggregationExceptions}, which is used for manual aggregation and 91 * disaggregation of raw contacts 92 * </li> 93 * <li> 94 * {@link Settings}, which contains visibility and sync settings for accounts 95 * and groups. 96 * </li> 97 * <li> 98 * {@link SyncState}, which contains free-form data maintained on behalf of sync 99 * adapters 100 * </li> 101 * <li> 102 * {@link PhoneLookup}, which is used for quick caller-ID lookup</li> 103 * </ul> 104 */ 105@SuppressWarnings("unused") 106public final class ContactsContract { 107 /** The authority for the contacts provider */ 108 public static final String AUTHORITY = "com.android.contacts"; 109 /** A content:// style uri to the authority for the contacts provider */ 110 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); 111 112 /** 113 * An optional URI parameter for insert, update, or delete queries 114 * that allows the caller 115 * to specify that it is a sync adapter. The default value is false. If true 116 * {@link RawContacts#DIRTY} is not automatically set and the 117 * "syncToNetwork" parameter is set to false when calling 118 * {@link 119 * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. 120 * This prevents an unnecessary extra synchronization, see the discussion of 121 * the delete operation in {@link RawContacts}. 122 */ 123 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; 124 125 /** 126 * A query parameter key used to specify the package that is requesting a query. 127 * This is used for restricting data based on package name. 128 * 129 * @hide 130 */ 131 public static final String REQUESTING_PACKAGE_PARAM_KEY = "requesting_package"; 132 133 /** 134 * Query parameter that should be used by the client to access a specific 135 * {@link Directory}. The parameter value should be the _ID of the corresponding 136 * directory, e.g. 137 * {@code content://com.android.contacts/data/emails/filter/acme?directory=3} 138 */ 139 public static final String DIRECTORY_PARAM_KEY = "directory"; 140 141 /** 142 * @hide 143 */ 144 public static final class Preferences { 145 146 /** 147 * A key in the {@link android.provider.Settings android.provider.Settings} provider 148 * that stores the preferred sorting order for contacts (by given name vs. by family name). 149 * 150 * @hide 151 */ 152 public static final String SORT_ORDER = "android.contacts.SORT_ORDER"; 153 154 /** 155 * The value for the SORT_ORDER key corresponding to sorting by given name first. 156 * 157 * @hide 158 */ 159 public static final int SORT_ORDER_PRIMARY = 1; 160 161 /** 162 * The value for the SORT_ORDER key corresponding to sorting by family name first. 163 * 164 * @hide 165 */ 166 public static final int SORT_ORDER_ALTERNATIVE = 2; 167 168 /** 169 * A key in the {@link android.provider.Settings android.provider.Settings} provider 170 * that stores the preferred display order for contacts (given name first vs. family 171 * name first). 172 * 173 * @hide 174 */ 175 public static final String DISPLAY_ORDER = "android.contacts.DISPLAY_ORDER"; 176 177 /** 178 * The value for the DISPLAY_ORDER key corresponding to showing the given name first. 179 * 180 * @hide 181 */ 182 public static final int DISPLAY_ORDER_PRIMARY = 1; 183 184 /** 185 * The value for the DISPLAY_ORDER key corresponding to showing the family name first. 186 * 187 * @hide 188 */ 189 public static final int DISPLAY_ORDER_ALTERNATIVE = 2; 190 } 191 192 /** 193 * A Directory represents a contacts corpus, e.g. Local contacts, 194 * Google Apps Global Address List or Corporate Global Address List. 195 * <p> 196 * A Directory is implemented as a content provider with its unique authority and 197 * the same API as the main Contacts Provider. However, there is no expectation that 198 * every directory provider will implement this Contract in its entirety. If a 199 * directory provider does not have an implementation for a specific request, it 200 * should throw an UnsupportedOperationException. 201 * </p> 202 * <p> 203 * The most important use case for Directories is search. A Directory provider is 204 * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI 205 * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate 206 * in email and phone lookup functionalities, it should also implement 207 * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI} 208 * and 209 * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}. 210 * </p> 211 * <p> 212 * A directory provider should return NULL for every projection field it does not 213 * recognize, rather than throwing an exception. This way it will not be broken 214 * if ContactsContract is extended with new fields in the future. 215 * </p> 216 * <p> 217 * The client interacts with a directory via Contacts Provider by supplying an 218 * optional {@code directory=} query parameter. 219 * <p> 220 * <p> 221 * When the Contacts Provider receives the request, it transforms the URI and forwards 222 * the request to the corresponding directory content provider. 223 * The URI is transformed in the following fashion: 224 * <ul> 225 * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li> 226 * <li>The {@code accountName=} and {@code accountType=} parameters are added or 227 * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li> 228 * <li>If the URI is missing a ContactsContract.REQUESTING_PACKAGE_PARAM_KEY 229 * parameter, this parameter is added.</li> 230 * </ul> 231 * </p> 232 * <p> 233 * Clients should send directory requests to Contacts Provider and let it 234 * forward them to the respective providers rather than constructing 235 * directory provider URIs by themselves. This level of indirection allows 236 * Contacts Provider to implement additional system-level features and 237 * optimizations. Access to Contacts Provider is protected by the 238 * READ_CONTACTS permission, but access to the directory provider is not. 239 * Therefore directory providers must reject requests coming from clients 240 * other than the Contacts Provider itself. An easy way to prevent such 241 * unauthorized access is to check the name of the calling package: 242 * <pre> 243 * private boolean isCallerAllowed() { 244 * PackageManager pm = getContext().getPackageManager(); 245 * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) { 246 * if (packageName.equals("com.android.providers.contacts")) { 247 * return true; 248 * } 249 * } 250 * return false; 251 * } 252 * </pre> 253 * </p> 254 * <p> 255 * The Directory table is read-only and is maintained by the Contacts Provider 256 * automatically. 257 * </p> 258 * <p>It always has at least these two rows: 259 * <ul> 260 * <li> 261 * The local directory. It has {@link Directory#_ID Directory._ID} = 262 * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally 263 * stored contacts. The same can be achieved by omitting the {@code directory=} 264 * parameter altogether. 265 * </li> 266 * <li> 267 * The local invisible contacts. The corresponding directory ID is 268 * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}. 269 * </li> 270 * </ul> 271 * </p> 272 * <p>Custom Directories are discovered by the Contacts Provider following this procedure: 273 * <ul> 274 * <li>It finds all installed content providers with meta data identifying them 275 * as directory providers in AndroidManifest.xml: 276 * <code> 277 * <meta-data android:name="android.content.ContactDirectory" 278 * android:value="true" /> 279 * </code> 280 * <p> 281 * This tag should be placed inside the corresponding content provider declaration. 282 * </p> 283 * </li> 284 * <li> 285 * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI} 286 * query to each of the directory authorities. A directory provider must implement 287 * this query and return a list of directories. Each directory returned by 288 * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and 289 * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned 290 * automatically, the _ID field will not be part of the query projection. 291 * </li> 292 * <li>Contacts Provider compiles directory lists received from all directory 293 * providers into one, assigns each individual directory a globally unique ID and 294 * stores all directory records in the Directory table. 295 * </li> 296 * </ul> 297 * </p> 298 * <p>Contacts Provider automatically interrogates newly installed or replaced packages. 299 * Thus simply installing a package containing a directory provider is sufficient 300 * to have that provider registered. A package supplying a directory provider does 301 * not have to contain launchable activities. 302 * </p> 303 * <p> 304 * Every row in the Directory table is automatically associated with the corresponding package 305 * (apk). If the package is later uninstalled, all corresponding directory rows 306 * are automatically removed from the Contacts Provider. 307 * </p> 308 * <p> 309 * When the list of directories handled by a directory provider changes 310 * (for instance when the user adds a new Directory account), the directory provider 311 * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change. 312 * In response, the Contacts Provider will requery the directory provider to obtain the 313 * new list of directories. 314 * </p> 315 * <p> 316 * A directory row can be optionally associated with an existing account 317 * (see {@link android.accounts.AccountManager}). If the account is later removed, 318 * the corresponding directory rows are automatically removed from the Contacts Provider. 319 * </p> 320 */ 321 public static final class Directory implements BaseColumns { 322 323 /** 324 * Not instantiable. 325 */ 326 private Directory() { 327 } 328 329 /** 330 * The content:// style URI for this table. Requests to this URI can be 331 * performed on the UI thread because they are always unblocking. 332 */ 333 public static final Uri CONTENT_URI = 334 Uri.withAppendedPath(AUTHORITY_URI, "directories"); 335 336 /** 337 * The MIME-type of {@link #CONTENT_URI} providing a directory of 338 * contact directories. 339 */ 340 public static final String CONTENT_TYPE = 341 "vnd.android.cursor.dir/contact_directories"; 342 343 /** 344 * The MIME type of a {@link #CONTENT_URI} item. 345 */ 346 public static final String CONTENT_ITEM_TYPE = 347 "vnd.android.cursor.item/contact_directory"; 348 349 /** 350 * _ID of the default directory, which represents locally stored contacts. 351 */ 352 public static final long DEFAULT = 0; 353 354 /** 355 * _ID of the directory that represents locally stored invisible contacts. 356 */ 357 public static final long LOCAL_INVISIBLE = 1; 358 359 /** 360 * The name of the package that owns this directory. Contacts Provider 361 * fill it in with the name of the package containing the directory provider. 362 * If the package is later uninstalled, the directories it owns are 363 * automatically removed from this table. 364 * 365 * <p>TYPE: TEXT</p> 366 */ 367 public static final String PACKAGE_NAME = "packageName"; 368 369 /** 370 * The type of directory captured as a resource ID in the context of the 371 * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory" 372 * 373 * <p>TYPE: INTEGER</p> 374 */ 375 public static final String TYPE_RESOURCE_ID = "typeResourceId"; 376 377 /** 378 * An optional name that can be used in the UI to represent this directory, 379 * e.g. "Acme Corp" 380 * <p>TYPE: text</p> 381 */ 382 public static final String DISPLAY_NAME = "displayName"; 383 384 /** 385 * <p> 386 * The authority of the Directory Provider. Contacts Provider will 387 * use this authority to forward requests to the directory provider. 388 * A directory provider can leave this column empty - Contacts Provider will fill it in. 389 * </p> 390 * <p> 391 * Clients of this API should not send requests directly to this authority. 392 * All directory requests must be routed through Contacts Provider. 393 * </p> 394 * 395 * <p>TYPE: text</p> 396 */ 397 public static final String DIRECTORY_AUTHORITY = "authority"; 398 399 /** 400 * The account type which this directory is associated. 401 * 402 * <p>TYPE: text</p> 403 */ 404 public static final String ACCOUNT_TYPE = "accountType"; 405 406 /** 407 * The account with which this directory is associated. If the account is later 408 * removed, the directories it owns are automatically removed from this table. 409 * 410 * <p>TYPE: text</p> 411 */ 412 public static final String ACCOUNT_NAME = "accountName"; 413 414 /** 415 * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT}, 416 * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the 417 * directory has for data exported from it. Clients must obey this setting. 418 */ 419 public static final String EXPORT_SUPPORT = "exportSupport"; 420 421 /** 422 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory 423 * does not allow any data to be copied out of it. 424 */ 425 public static final int EXPORT_SUPPORT_NONE = 0; 426 427 /** 428 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory 429 * allow its data copied only to the account specified by 430 * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}. 431 */ 432 public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1; 433 434 /** 435 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory 436 * allow its data copied to any contacts account. 437 */ 438 public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; 439 440 /** 441 * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY}, 442 * {@link #SHORTCUT_SUPPORT_FULL}, This is the expectation the directory 443 * has for shortcuts created for its elements. Clients must obey this setting. 444 */ 445 public static final String SHORTCUT_SUPPORT = "shortcutSupport"; 446 447 /** 448 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory 449 * does not allow any shortcuts created for its contacts. 450 */ 451 public static final int SHORTCUT_SUPPORT_NONE = 0; 452 453 /** 454 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory 455 * allow creation of shortcuts for data items like email, phone or postal address, 456 * but not the entire contact. 457 */ 458 public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1; 459 460 /** 461 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory 462 * allow creation of shortcuts for contact as well as their constituent elements. 463 */ 464 public static final int SHORTCUT_SUPPORT_FULL = 2; 465 466 /** 467 * Notifies the system of a change in the list of directories handled by 468 * a particular directory provider. The Contacts provider will turn around 469 * and send a query to the directory provider for the full list of directories, 470 * which will replace the previous list. 471 */ 472 public static void notifyDirectoryChange(ContentResolver resolver) { 473 // This is done to trigger a query by Contacts Provider back to the directory provider. 474 // No data needs to be sent back, because the provider can infer the calling 475 // package from binder. 476 ContentValues contentValues = new ContentValues(); 477 resolver.update(Directory.CONTENT_URI, contentValues, null, null); 478 } 479 } 480 481 /** 482 * @hide should be removed when users are updated to refer to SyncState 483 * @deprecated use SyncState instead 484 */ 485 @Deprecated 486 public interface SyncStateColumns extends SyncStateContract.Columns { 487 } 488 489 /** 490 * A table provided for sync adapters to use for storing private sync state data. 491 * 492 * @see SyncStateContract 493 */ 494 public static final class SyncState implements SyncStateContract.Columns { 495 /** 496 * This utility class cannot be instantiated 497 */ 498 private SyncState() {} 499 500 public static final String CONTENT_DIRECTORY = 501 SyncStateContract.Constants.CONTENT_DIRECTORY; 502 503 /** 504 * The content:// style URI for this table 505 */ 506 public static final Uri CONTENT_URI = 507 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); 508 509 /** 510 * @see android.provider.SyncStateContract.Helpers#get 511 */ 512 public static byte[] get(ContentProviderClient provider, Account account) 513 throws RemoteException { 514 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); 515 } 516 517 /** 518 * @see android.provider.SyncStateContract.Helpers#get 519 */ 520 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) 521 throws RemoteException { 522 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); 523 } 524 525 /** 526 * @see android.provider.SyncStateContract.Helpers#set 527 */ 528 public static void set(ContentProviderClient provider, Account account, byte[] data) 529 throws RemoteException { 530 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); 531 } 532 533 /** 534 * @see android.provider.SyncStateContract.Helpers#newSetOperation 535 */ 536 public static ContentProviderOperation newSetOperation(Account account, byte[] data) { 537 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); 538 } 539 } 540 541 /** 542 * Generic columns for use by sync adapters. The specific functions of 543 * these columns are private to the sync adapter. Other clients of the API 544 * should not attempt to either read or write this column. 545 * 546 * @see RawContacts 547 * @see Groups 548 */ 549 protected interface BaseSyncColumns { 550 551 /** Generic column for use by sync adapters. */ 552 public static final String SYNC1 = "sync1"; 553 /** Generic column for use by sync adapters. */ 554 public static final String SYNC2 = "sync2"; 555 /** Generic column for use by sync adapters. */ 556 public static final String SYNC3 = "sync3"; 557 /** Generic column for use by sync adapters. */ 558 public static final String SYNC4 = "sync4"; 559 } 560 561 /** 562 * Columns that appear when each row of a table belongs to a specific 563 * account, including sync information that an account may need. 564 * 565 * @see RawContacts 566 * @see Groups 567 */ 568 protected interface SyncColumns extends BaseSyncColumns { 569 /** 570 * The name of the account instance to which this row belongs, which when paired with 571 * {@link #ACCOUNT_TYPE} identifies a specific account. 572 * <P>Type: TEXT</P> 573 */ 574 public static final String ACCOUNT_NAME = "account_name"; 575 576 /** 577 * The type of account to which this row belongs, which when paired with 578 * {@link #ACCOUNT_NAME} identifies a specific account. 579 * <P>Type: TEXT</P> 580 */ 581 public static final String ACCOUNT_TYPE = "account_type"; 582 583 /** 584 * String that uniquely identifies this row to its source account. 585 * <P>Type: TEXT</P> 586 */ 587 public static final String SOURCE_ID = "sourceid"; 588 589 /** 590 * Version number that is updated whenever this row or its related data 591 * changes. 592 * <P>Type: INTEGER</P> 593 */ 594 public static final String VERSION = "version"; 595 596 /** 597 * Flag indicating that {@link #VERSION} has changed, and this row needs 598 * to be synchronized by its owning account. 599 * <P>Type: INTEGER (boolean)</P> 600 */ 601 public static final String DIRTY = "dirty"; 602 } 603 604 /** 605 * Columns of {@link ContactsContract.Contacts} that track the user's 606 * preferences for, or interactions with, the contact. 607 * 608 * @see Contacts 609 * @see RawContacts 610 * @see ContactsContract.Data 611 * @see PhoneLookup 612 * @see ContactsContract.Contacts.AggregationSuggestions 613 */ 614 protected interface ContactOptionsColumns { 615 /** 616 * The number of times a contact has been contacted 617 * <P>Type: INTEGER</P> 618 */ 619 public static final String TIMES_CONTACTED = "times_contacted"; 620 621 /** 622 * The last time a contact was contacted. 623 * <P>Type: INTEGER</P> 624 */ 625 public static final String LAST_TIME_CONTACTED = "last_time_contacted"; 626 627 /** 628 * Is the contact starred? 629 * <P>Type: INTEGER (boolean)</P> 630 */ 631 public static final String STARRED = "starred"; 632 633 /** 634 * URI for a custom ringtone associated with the contact. If null or missing, 635 * the default ringtone is used. 636 * <P>Type: TEXT (URI to the ringtone)</P> 637 */ 638 public static final String CUSTOM_RINGTONE = "custom_ringtone"; 639 640 /** 641 * Whether the contact should always be sent to voicemail. If missing, 642 * defaults to false. 643 * <P>Type: INTEGER (0 for false, 1 for true)</P> 644 */ 645 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; 646 } 647 648 /** 649 * Columns of {@link ContactsContract.Contacts} that refer to intrinsic 650 * properties of the contact, as opposed to the user-specified options 651 * found in {@link ContactOptionsColumns}. 652 * 653 * @see Contacts 654 * @see ContactsContract.Data 655 * @see PhoneLookup 656 * @see ContactsContract.Contacts.AggregationSuggestions 657 */ 658 protected interface ContactsColumns { 659 /** 660 * The display name for the contact. 661 * <P>Type: TEXT</P> 662 */ 663 public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; 664 665 /** 666 * Reference to the row in the RawContacts table holding the contact name. 667 * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> 668 * @hide 669 */ 670 public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; 671 672 /** 673 * Reference to the row in the data table holding the photo. 674 * <P>Type: INTEGER REFERENCES data(_id)</P> 675 */ 676 public static final String PHOTO_ID = "photo_id"; 677 678 /** 679 * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of 680 * any {@link CommonDataKinds.GroupMembership} for this contact. 681 */ 682 public static final String IN_VISIBLE_GROUP = "in_visible_group"; 683 684 /** 685 * An indicator of whether this contact has at least one phone number. "1" if there is 686 * at least one phone number, "0" otherwise. 687 * <P>Type: INTEGER</P> 688 */ 689 public static final String HAS_PHONE_NUMBER = "has_phone_number"; 690 691 /** 692 * An opaque value that contains hints on how to find the contact if 693 * its row id changed as a result of a sync or aggregation. 694 */ 695 public static final String LOOKUP_KEY = "lookup"; 696 } 697 698 /** 699 * @see Contacts 700 */ 701 protected interface ContactStatusColumns { 702 /** 703 * Contact presence status. See {@link StatusUpdates} for individual status 704 * definitions. 705 * <p>Type: NUMBER</p> 706 */ 707 public static final String CONTACT_PRESENCE = "contact_presence"; 708 709 /** 710 * Contact Chat Capabilities. See {@link StatusUpdates} for individual 711 * definitions. 712 * <p>Type: NUMBER</p> 713 */ 714 public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; 715 716 /** 717 * Contact's latest status update. 718 * <p>Type: TEXT</p> 719 */ 720 public static final String CONTACT_STATUS = "contact_status"; 721 722 /** 723 * The absolute time in milliseconds when the latest status was 724 * inserted/updated. 725 * <p>Type: NUMBER</p> 726 */ 727 public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; 728 729 /** 730 * The package containing resources for this status: label and icon. 731 * <p>Type: TEXT</p> 732 */ 733 public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; 734 735 /** 736 * The resource ID of the label describing the source of contact 737 * status, e.g. "Google Talk". This resource is scoped by the 738 * {@link #CONTACT_STATUS_RES_PACKAGE}. 739 * <p>Type: NUMBER</p> 740 */ 741 public static final String CONTACT_STATUS_LABEL = "contact_status_label"; 742 743 /** 744 * The resource ID of the icon for the source of contact status. This 745 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. 746 * <p>Type: NUMBER</p> 747 */ 748 public static final String CONTACT_STATUS_ICON = "contact_status_icon"; 749 } 750 751 /** 752 * Constants for various styles of combining given name, family name etc into 753 * a full name. For example, the western tradition follows the pattern 754 * 'given name' 'middle name' 'family name' with the alternative pattern being 755 * 'family name', 'given name' 'middle name'. The CJK tradition is 756 * 'family name' 'middle name' 'given name', with Japanese favoring a space between 757 * the names and Chinese omitting the space. 758 */ 759 public interface FullNameStyle { 760 public static final int UNDEFINED = 0; 761 public static final int WESTERN = 1; 762 763 /** 764 * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine 765 * which specific language it belongs to: Chinese, Japanese or Korean. 766 */ 767 public static final int CJK = 2; 768 769 public static final int CHINESE = 3; 770 public static final int JAPANESE = 4; 771 public static final int KOREAN = 5; 772 } 773 774 /** 775 * Constants for various styles of capturing the pronunciation of a person's name. 776 */ 777 public interface PhoneticNameStyle { 778 public static final int UNDEFINED = 0; 779 780 /** 781 * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly 782 * shown in UIs, but used for searches and sorting. 783 */ 784 public static final int PINYIN = 3; 785 786 /** 787 * Hiragana and Katakana are two common styles of writing out the pronunciation 788 * of a Japanese names. 789 */ 790 public static final int JAPANESE = 4; 791 792 /** 793 * Hangul is the Korean phonetic alphabet. 794 */ 795 public static final int KOREAN = 5; 796 } 797 798 /** 799 * Types of data used to produce the display name for a contact. Listed in the order 800 * of increasing priority. 801 */ 802 public interface DisplayNameSources { 803 public static final int UNDEFINED = 0; 804 public static final int EMAIL = 10; 805 public static final int PHONE = 20; 806 public static final int ORGANIZATION = 30; 807 public static final int NICKNAME = 35; 808 public static final int STRUCTURED_NAME = 40; 809 } 810 811 /** 812 * Contact name and contact name metadata columns in the RawContacts table. 813 * 814 * @see Contacts 815 * @see RawContacts 816 */ 817 protected interface ContactNameColumns { 818 819 /** 820 * The kind of data that is used as the display name for the contact, such as 821 * structured name or email address. See {@link DisplayNameSources}. 822 */ 823 public static final String DISPLAY_NAME_SOURCE = "display_name_source"; 824 825 /** 826 * <p> 827 * The standard text shown as the contact's display name, based on the best 828 * available information for the contact (for example, it might be the email address 829 * if the name is not available). 830 * The information actually used to compute the name is stored in 831 * {@link #DISPLAY_NAME_SOURCE}. 832 * </p> 833 * <p> 834 * A contacts provider is free to choose whatever representation makes most 835 * sense for its target market. 836 * For example in the default Android Open Source Project implementation, 837 * if the display name is 838 * based on the structured name and the structured name follows 839 * the Western full-name style, then this field contains the "given name first" 840 * version of the full name. 841 * <p> 842 * 843 * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE 844 */ 845 public static final String DISPLAY_NAME_PRIMARY = "display_name"; 846 847 /** 848 * <p> 849 * An alternative representation of the display name, such as "family name first" 850 * instead of "given name first" for Western names. If an alternative is not 851 * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. 852 * </p> 853 * <p> 854 * A contacts provider is free to provide alternatives as necessary for 855 * its target market. 856 * For example the default Android Open Source Project contacts provider 857 * currently provides an 858 * alternative in a single case: if the display name is 859 * based on the structured name and the structured name follows 860 * the Western full name style, then the field contains the "family name first" 861 * version of the full name. 862 * Other cases may be added later. 863 * </p> 864 */ 865 public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; 866 867 /** 868 * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See 869 * {@link PhoneticNameStyle}. 870 */ 871 public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; 872 873 /** 874 * <p> 875 * Pronunciation of the full name in the phonetic alphabet specified by 876 * {@link #PHONETIC_NAME_STYLE}. 877 * </p> 878 * <p> 879 * The value may be set manually by the user. This capability is of 880 * interest only in countries with commonly used phonetic alphabets, 881 * such as Japan and Korea. See {@link PhoneticNameStyle}. 882 * </p> 883 */ 884 public static final String PHONETIC_NAME = "phonetic_name"; 885 886 /** 887 * Sort key that takes into account locale-based traditions for sorting 888 * names in address books. The default 889 * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names 890 * the sort key is the name's Pinyin spelling, and for Japanese names 891 * it is the Hiragana version of the phonetic name. 892 */ 893 public static final String SORT_KEY_PRIMARY = "sort_key"; 894 895 /** 896 * Sort key based on the alternative representation of the full name, 897 * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, 898 * it is the one using the "family name first" format. 899 */ 900 public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; 901 } 902 903 /** 904 * URI parameter and cursor extras that return counts of rows grouped by the 905 * address book index, which is usually the first letter of the sort key. 906 * When this parameter is supplied, the row counts are returned in the 907 * cursor extras bundle. 908 * 909 * @hide 910 */ 911 public final static class ContactCounts { 912 913 /** 914 * Add this query parameter to a URI to get back row counts grouped by 915 * the address book index as cursor extras. For most languages it is the 916 * first letter of the sort key. This parameter does not affect the main 917 * content of the cursor. 918 * 919 * @hide 920 */ 921 public static final String ADDRESS_BOOK_INDEX_EXTRAS = "address_book_index_extras"; 922 923 /** 924 * The array of address book index titles, which are returned in the 925 * same order as the data in the cursor. 926 * <p>TYPE: String[]</p> 927 * 928 * @hide 929 */ 930 public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "address_book_index_titles"; 931 932 /** 933 * The array of group counts for the corresponding group. Contains the same number 934 * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. 935 * <p>TYPE: int[]</p> 936 * 937 * @hide 938 */ 939 public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "address_book_index_counts"; 940 } 941 942 /** 943 * Constants for the contacts table, which contains a record per aggregate 944 * of raw contacts representing the same person. 945 * <h3>Operations</h3> 946 * <dl> 947 * <dt><b>Insert</b></dt> 948 * <dd>A Contact cannot be created explicitly. When a raw contact is 949 * inserted, the provider will first try to find a Contact representing the 950 * same person. If one is found, the raw contact's 951 * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate 952 * Contact. If no match is found, the provider automatically inserts a new 953 * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column 954 * of the newly inserted raw contact.</dd> 955 * <dt><b>Update</b></dt> 956 * <dd>Only certain columns of Contact are modifiable: 957 * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, 958 * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of 959 * these columns on the Contact also changes them on all constituent raw 960 * contacts.</dd> 961 * <dt><b>Delete</b></dt> 962 * <dd>Be careful with deleting Contacts! Deleting an aggregate contact 963 * deletes all constituent raw contacts. The corresponding sync adapters 964 * will notice the deletions of their respective raw contacts and remove 965 * them from their back end storage.</dd> 966 * <dt><b>Query</b></dt> 967 * <dd> 968 * <ul> 969 * <li>If you need to read an individual contact, consider using 970 * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> 971 * <li>If you need to look up a contact by the phone number, use 972 * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, 973 * which is optimized for this purpose.</li> 974 * <li>If you need to look up a contact by partial name, e.g. to produce 975 * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. 976 * <li>If you need to look up a contact by some data element like email 977 * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. 978 * The result will contain contact ID, name etc. 979 * </ul> 980 * </dd> 981 * </dl> 982 * <h2>Columns</h2> 983 * <table class="jd-sumtable"> 984 * <tr> 985 * <th colspan='4'>Contacts</th> 986 * </tr> 987 * <tr> 988 * <td>long</td> 989 * <td>{@link #_ID}</td> 990 * <td>read-only</td> 991 * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> 992 * </tr> 993 * <tr> 994 * <td>String</td> 995 * <td>{@link #LOOKUP_KEY}</td> 996 * <td>read-only</td> 997 * <td>An opaque value that contains hints on how to find the contact if its 998 * row id changed as a result of a sync or aggregation.</td> 999 * </tr> 1000 * <tr> 1001 * <td>long</td> 1002 * <td>NAME_RAW_CONTACT_ID</td> 1003 * <td>read-only</td> 1004 * <td>The ID of the raw contact that contributes the display name 1005 * to the aggregate contact. During aggregation one of the constituent 1006 * raw contacts is chosen using a heuristic: a longer name or a name 1007 * with more diacritic marks or more upper case characters is chosen.</td> 1008 * </tr> 1009 * <tr> 1010 * <td>String</td> 1011 * <td>DISPLAY_NAME_PRIMARY</td> 1012 * <td>read-only</td> 1013 * <td>The display name for the contact. It is the display name 1014 * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID 1015 * column.</td> 1016 * </tr> 1017 * <tr> 1018 * <td>long</td> 1019 * <td>{@link #PHOTO_ID}</td> 1020 * <td>read-only</td> 1021 * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. 1022 * That row has the mime type 1023 * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field 1024 * is computed automatically based on the 1025 * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of 1026 * that mime type.</td> 1027 * </tr> 1028 * <tr> 1029 * <td>int</td> 1030 * <td>{@link #IN_VISIBLE_GROUP}</td> 1031 * <td>read-only</td> 1032 * <td>An indicator of whether this contact is supposed to be visible in the 1033 * UI. "1" if the contact has at least one raw contact that belongs to a 1034 * visible group; "0" otherwise.</td> 1035 * </tr> 1036 * <tr> 1037 * <td>int</td> 1038 * <td>{@link #HAS_PHONE_NUMBER}</td> 1039 * <td>read-only</td> 1040 * <td>An indicator of whether this contact has at least one phone number. 1041 * "1" if there is at least one phone number, "0" otherwise.</td> 1042 * </tr> 1043 * <tr> 1044 * <td>int</td> 1045 * <td>{@link #TIMES_CONTACTED}</td> 1046 * <td>read/write</td> 1047 * <td>The number of times the contact has been contacted. See 1048 * {@link #markAsContacted}. When raw contacts are aggregated, this field is 1049 * computed automatically as the maximum number of times contacted among all 1050 * constituent raw contacts. Setting this field automatically changes the 1051 * corresponding field on all constituent raw contacts.</td> 1052 * </tr> 1053 * <tr> 1054 * <td>long</td> 1055 * <td>{@link #LAST_TIME_CONTACTED}</td> 1056 * <td>read/write</td> 1057 * <td>The timestamp of the last time the contact was contacted. See 1058 * {@link #markAsContacted}. Setting this field also automatically 1059 * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, 1060 * this field is computed automatically as the latest time contacted of all 1061 * constituent raw contacts. Setting this field automatically changes the 1062 * corresponding field on all constituent raw contacts.</td> 1063 * </tr> 1064 * <tr> 1065 * <td>int</td> 1066 * <td>{@link #STARRED}</td> 1067 * <td>read/write</td> 1068 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. 1069 * When raw contacts are aggregated, this field is automatically computed: 1070 * if any constituent raw contacts are starred, then this field is set to 1071 * '1'. Setting this field automatically changes the corresponding field on 1072 * all constituent raw contacts.</td> 1073 * </tr> 1074 * <tr> 1075 * <td>String</td> 1076 * <td>{@link #CUSTOM_RINGTONE}</td> 1077 * <td>read/write</td> 1078 * <td>A custom ringtone associated with a contact. Typically this is the 1079 * URI returned by an activity launched with the 1080 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> 1081 * </tr> 1082 * <tr> 1083 * <td>int</td> 1084 * <td>{@link #SEND_TO_VOICEMAIL}</td> 1085 * <td>read/write</td> 1086 * <td>An indicator of whether calls from this contact should be forwarded 1087 * directly to voice mail ('1') or not ('0'). When raw contacts are 1088 * aggregated, this field is automatically computed: if <i>all</i> 1089 * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set 1090 * to '1'. Setting this field automatically changes the corresponding field 1091 * on all constituent raw contacts.</td> 1092 * </tr> 1093 * <tr> 1094 * <td>int</td> 1095 * <td>{@link #CONTACT_PRESENCE}</td> 1096 * <td>read-only</td> 1097 * <td>Contact IM presence status. See {@link StatusUpdates} for individual 1098 * status definitions. Automatically computed as the highest presence of all 1099 * constituent raw contacts. The provider may choose not to store this value 1100 * in persistent storage. The expectation is that presence status will be 1101 * updated on a regular basic.</td> 1102 * </tr> 1103 * <tr> 1104 * <td>String</td> 1105 * <td>{@link #CONTACT_STATUS}</td> 1106 * <td>read-only</td> 1107 * <td>Contact's latest status update. Automatically computed as the latest 1108 * of all constituent raw contacts' status updates.</td> 1109 * </tr> 1110 * <tr> 1111 * <td>long</td> 1112 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> 1113 * <td>read-only</td> 1114 * <td>The absolute time in milliseconds when the latest status was 1115 * inserted/updated.</td> 1116 * </tr> 1117 * <tr> 1118 * <td>String</td> 1119 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> 1120 * <td>read-only</td> 1121 * <td> The package containing resources for this status: label and icon.</td> 1122 * </tr> 1123 * <tr> 1124 * <td>long</td> 1125 * <td>{@link #CONTACT_STATUS_LABEL}</td> 1126 * <td>read-only</td> 1127 * <td>The resource ID of the label describing the source of contact status, 1128 * e.g. "Google Talk". This resource is scoped by the 1129 * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> 1130 * </tr> 1131 * <tr> 1132 * <td>long</td> 1133 * <td>{@link #CONTACT_STATUS_ICON}</td> 1134 * <td>read-only</td> 1135 * <td>The resource ID of the icon for the source of contact status. This 1136 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> 1137 * </tr> 1138 * </table> 1139 */ 1140 public static class Contacts implements BaseColumns, ContactsColumns, 1141 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { 1142 /** 1143 * This utility class cannot be instantiated 1144 */ 1145 private Contacts() {} 1146 1147 /** 1148 * The content:// style URI for this table 1149 */ 1150 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); 1151 1152 /** 1153 * A content:// style URI for this table that should be used to create 1154 * shortcuts or otherwise create long-term links to contacts. This URI 1155 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. 1156 * It can optionally also have a "/" and last known contact ID appended after 1157 * that. This "complete" format is an important optimization and is highly recommended. 1158 * <p> 1159 * As long as the contact's row ID remains the same, this URI is 1160 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes 1161 * as a result of a sync or aggregation, this URI will look up the 1162 * contact using indirect information (sync IDs or constituent raw 1163 * contacts). 1164 * <p> 1165 * Lookup key should be appended unencoded - it is stored in the encoded 1166 * form, ready for use in a URI. 1167 */ 1168 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, 1169 "lookup"); 1170 1171 /** 1172 * Base {@link Uri} for referencing a single {@link Contacts} entry, 1173 * created by appending {@link #LOOKUP_KEY} using 1174 * {@link Uri#withAppendedPath(Uri, String)}. Provides 1175 * {@link OpenableColumns} columns when queried, or returns the 1176 * referenced contact formatted as a vCard when opened through 1177 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. 1178 */ 1179 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, 1180 "as_vcard"); 1181 1182 /** 1183 * Base {@link Uri} for referencing multiple {@link Contacts} entry, 1184 * created by appending {@link #LOOKUP_KEY} using 1185 * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be 1186 * encoded and joined with the colon (":") seperator. The resulting string 1187 * has to be encoded again. Provides 1188 * {@link OpenableColumns} columns when queried, or returns the 1189 * referenced contact formatted as a vCard when opened through 1190 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. 1191 * 1192 * This is private API because we do not have a well-defined way to 1193 * specify several entities yet. The format of this Uri might change in the future 1194 * or the Uri might be completely removed. 1195 * 1196 * @hide 1197 */ 1198 public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, 1199 "as_multi_vcard"); 1200 1201 /** 1202 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the 1203 * requested {@link Contacts} entry. 1204 * 1205 * @param contactUri A {@link #CONTENT_URI} row, or an existing 1206 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. 1207 */ 1208 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { 1209 final Cursor c = resolver.query(contactUri, new String[] { 1210 Contacts.LOOKUP_KEY, Contacts._ID 1211 }, null, null, null); 1212 if (c == null) { 1213 return null; 1214 } 1215 1216 try { 1217 if (c.moveToFirst()) { 1218 final String lookupKey = c.getString(0); 1219 final long contactId = c.getLong(1); 1220 return getLookupUri(contactId, lookupKey); 1221 } 1222 } finally { 1223 c.close(); 1224 } 1225 return null; 1226 } 1227 1228 /** 1229 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the 1230 * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. 1231 */ 1232 public static Uri getLookupUri(long contactId, String lookupKey) { 1233 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, 1234 lookupKey), contactId); 1235 } 1236 1237 /** 1238 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. 1239 * <p> 1240 * Returns null if the contact cannot be found. 1241 */ 1242 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { 1243 if (lookupUri == null) { 1244 return null; 1245 } 1246 1247 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); 1248 if (c == null) { 1249 return null; 1250 } 1251 1252 try { 1253 if (c.moveToFirst()) { 1254 long contactId = c.getLong(0); 1255 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); 1256 } 1257 } finally { 1258 c.close(); 1259 } 1260 return null; 1261 } 1262 1263 /** 1264 * Mark a contact as having been contacted. This updates the 1265 * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED} for the 1266 * contact, plus the corresponding values of any associated raw 1267 * contacts. 1268 * 1269 * @param resolver the ContentResolver to use 1270 * @param contactId the person who was contacted 1271 */ 1272 public static void markAsContacted(ContentResolver resolver, long contactId) { 1273 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); 1274 ContentValues values = new ContentValues(); 1275 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. 1276 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis()); 1277 resolver.update(uri, values, null, null); 1278 } 1279 1280 /** 1281 * The content:// style URI used for "type-to-filter" functionality on the 1282 * {@link #CONTENT_URI} URI. The filter string will be used to match 1283 * various parts of the contact name. The filter argument should be passed 1284 * as an additional path segment after this URI. 1285 */ 1286 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( 1287 CONTENT_URI, "filter"); 1288 1289 /** 1290 * The content:// style URI for this table joined with useful data from 1291 * {@link ContactsContract.Data}, filtered to include only starred contacts 1292 * and the most frequently contacted contacts. 1293 */ 1294 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( 1295 CONTENT_URI, "strequent"); 1296 1297 /** 1298 * The content:// style URI used for "type-to-filter" functionality on the 1299 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match 1300 * various parts of the contact name. The filter argument should be passed 1301 * as an additional path segment after this URI. 1302 */ 1303 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( 1304 CONTENT_STREQUENT_URI, "filter"); 1305 1306 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( 1307 CONTENT_URI, "group"); 1308 1309 /** 1310 * The MIME type of {@link #CONTENT_URI} providing a directory of 1311 * people. 1312 */ 1313 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; 1314 1315 /** 1316 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 1317 * person. 1318 */ 1319 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; 1320 1321 /** 1322 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 1323 * person. 1324 */ 1325 public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; 1326 1327 /** 1328 * A sub-directory of a single contact that contains all of the constituent raw contact 1329 * {@link ContactsContract.Data} rows. 1330 */ 1331 public static final class Data implements BaseColumns, DataColumns { 1332 /** 1333 * no public constructor since this is a utility class 1334 */ 1335 private Data() {} 1336 1337 /** 1338 * The directory twig for this sub-table 1339 */ 1340 public static final String CONTENT_DIRECTORY = "data"; 1341 } 1342 1343 /** 1344 * <p> 1345 * A sub-directory of a contact that contains all of its 1346 * {@link ContactsContract.RawContacts} as well as 1347 * {@link ContactsContract.Data} rows. To access this directory append 1348 * {@link #CONTENT_DIRECTORY} to the contact URI. 1349 * </p> 1350 * <p> 1351 * Entity has three ID fields: {@link #CONTACT_ID} for the contact, 1352 * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for 1353 * the data rows. Entity always contains at least one row per 1354 * constituent raw contact, even if there are no actual data rows. In 1355 * this case the {@link #DATA_ID} field will be null. 1356 * </p> 1357 * <p> 1358 * Entity reads all data for the entire contact in one transaction, to 1359 * guarantee consistency. There is significant data duplication 1360 * in the Entity (each row repeats all Contact columns and all RawContact 1361 * columns), so the benefits of transactional consistency should be weighed 1362 * against the cost of transferring large amounts of denormalized data 1363 * from the Provider. 1364 * </p> 1365 */ 1366 public static final class Entity implements BaseColumns, ContactsColumns, 1367 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, 1368 StatusColumns, ContactOptionsColumns, ContactStatusColumns { 1369 /** 1370 * no public constructor since this is a utility class 1371 */ 1372 private Entity() { 1373 } 1374 1375 /** 1376 * The directory twig for this sub-table 1377 */ 1378 public static final String CONTENT_DIRECTORY = "entities"; 1379 1380 /** 1381 * The ID of the raw contact row. 1382 * <P>Type: INTEGER</P> 1383 */ 1384 public static final String RAW_CONTACT_ID = "raw_contact_id"; 1385 1386 /** 1387 * The ID of the data row. The value will be null if this raw contact has no 1388 * data rows. 1389 * <P>Type: INTEGER</P> 1390 */ 1391 public static final String DATA_ID = "data_id"; 1392 } 1393 1394 /** 1395 * <p> 1396 * A <i>read-only</i> sub-directory of a single contact aggregate that 1397 * contains all aggregation suggestions (other contacts). The 1398 * aggregation suggestions are computed based on approximate data 1399 * matches with this contact. 1400 * </p> 1401 * <p> 1402 * <i>Note: this query may be expensive! If you need to use it in bulk, 1403 * make sure the user experience is acceptable when the query runs for a 1404 * long time.</i> 1405 * <p> 1406 * Usage example: 1407 * 1408 * <pre> 1409 * Uri uri = Contacts.CONTENT_URI.buildUpon() 1410 * .appendEncodedPath(String.valueOf(contactId)) 1411 * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) 1412 * .appendQueryParameter("limit", "3") 1413 * .build() 1414 * Cursor cursor = getContentResolver().query(suggestionsUri, 1415 * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, 1416 * null, null, null); 1417 * </pre> 1418 * 1419 * </p> 1420 */ 1421 // TODO: add ContactOptionsColumns, ContactStatusColumns 1422 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns { 1423 /** 1424 * No public constructor since this is a utility class 1425 */ 1426 private AggregationSuggestions() {} 1427 1428 /** 1429 * The directory twig for this sub-table. The URI can be followed by an optional 1430 * type-to-filter, similar to 1431 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. 1432 */ 1433 public static final String CONTENT_DIRECTORY = "suggestions"; 1434 1435 /** 1436 * Used with {@link Builder#addParameter} to specify what kind of data is 1437 * supplied for the suggestion query. 1438 * 1439 * @hide 1440 */ 1441 public static final String PARAMETER_MATCH_NAME = "name"; 1442 1443 /** 1444 * Used with {@link Builder#addParameter} to specify what kind of data is 1445 * supplied for the suggestion query. 1446 * 1447 * @hide 1448 */ 1449 public static final String PARAMETER_MATCH_EMAIL = "email"; 1450 1451 /** 1452 * Used with {@link Builder#addParameter} to specify what kind of data is 1453 * supplied for the suggestion query. 1454 * 1455 * @hide 1456 */ 1457 public static final String PARAMETER_MATCH_PHONE = "phone"; 1458 1459 /** 1460 * Used with {@link Builder#addParameter} to specify what kind of data is 1461 * supplied for the suggestion query. 1462 * 1463 * @hide 1464 */ 1465 public static final String PARAMETER_MATCH_NICKNAME = "nickname"; 1466 1467 /** 1468 * A convenience builder for aggregation suggestion content URIs. 1469 * 1470 * TODO: change documentation for this class to use the builder. 1471 * @hide 1472 */ 1473 public static final class Builder { 1474 private long mContactId; 1475 private ArrayList<String> mKinds = new ArrayList<String>(); 1476 private ArrayList<String> mValues = new ArrayList<String>(); 1477 private int mLimit; 1478 1479 /** 1480 * Optional existing contact ID. If it is not provided, the search 1481 * will be based exclusively on the values supplied with {@link #addParameter}. 1482 */ 1483 public Builder setContactId(long contactId) { 1484 this.mContactId = contactId; 1485 return this; 1486 } 1487 1488 /** 1489 * A value that can be used when searching for an aggregation 1490 * suggestion. 1491 * 1492 * @param kind can be one of 1493 * {@link AggregationSuggestions#PARAMETER_MATCH_NAME}, 1494 * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL}, 1495 * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME}, 1496 * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE} 1497 */ 1498 public Builder addParameter(String kind, String value) { 1499 if (!TextUtils.isEmpty(value)) { 1500 mKinds.add(kind); 1501 mValues.add(value); 1502 } 1503 return this; 1504 } 1505 1506 public Builder setLimit(int limit) { 1507 mLimit = limit; 1508 return this; 1509 } 1510 1511 public Uri build() { 1512 android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); 1513 builder.appendEncodedPath(String.valueOf(mContactId)); 1514 builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); 1515 if (mLimit != 0) { 1516 builder.appendQueryParameter("limit", String.valueOf(mLimit)); 1517 } 1518 1519 int count = mKinds.size(); 1520 for (int i = 0; i < count; i++) { 1521 builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i)); 1522 } 1523 1524 return builder.build(); 1525 } 1526 } 1527 1528 /** 1529 * @hide 1530 */ 1531 public static final Builder builder() { 1532 return new Builder(); 1533 } 1534 } 1535 1536 /** 1537 * A <i>read-only</i> sub-directory of a single contact that contains 1538 * the contact's primary photo. 1539 * <p> 1540 * Usage example: 1541 * 1542 * <pre> 1543 * public InputStream openPhoto(long contactId) { 1544 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); 1545 * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); 1546 * Cursor cursor = getContentResolver().query(photoUri, 1547 * new String[] {Contacts.Photo.PHOTO}, null, null, null); 1548 * if (cursor == null) { 1549 * return null; 1550 * } 1551 * try { 1552 * if (cursor.moveToFirst()) { 1553 * byte[] data = cursor.getBlob(0); 1554 * if (data != null) { 1555 * return new ByteArrayInputStream(data); 1556 * } 1557 * } 1558 * } finally { 1559 * cursor.close(); 1560 * } 1561 * return null; 1562 * } 1563 * </pre> 1564 * 1565 * </p> 1566 * <p>You should also consider using the convenience method 1567 * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri)} 1568 * </p> 1569 */ 1570 // TODO: change DataColumns to DataColumnsWithJoins 1571 public static final class Photo implements BaseColumns, DataColumns { 1572 /** 1573 * no public constructor since this is a utility class 1574 */ 1575 private Photo() {} 1576 1577 /** 1578 * The directory twig for this sub-table 1579 */ 1580 public static final String CONTENT_DIRECTORY = "photo"; 1581 1582 /** 1583 * Thumbnail photo of the raw contact. This is the raw bytes of an image 1584 * that could be inflated using {@link android.graphics.BitmapFactory}. 1585 * <p> 1586 * Type: BLOB 1587 */ 1588 public static final String PHOTO = DATA15; 1589 } 1590 1591 /** 1592 * Opens an InputStream for the contacts's default photo and returns the 1593 * photo as a byte stream. If there is not photo null will be returned. 1594 * 1595 * @param contactUri the contact whose photo should be used 1596 * @return an InputStream of the photo, or null if no photo is present 1597 */ 1598 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { 1599 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); 1600 if (photoUri == null) { 1601 return null; 1602 } 1603 Cursor cursor = cr.query(photoUri, 1604 new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null); 1605 try { 1606 if (cursor == null || !cursor.moveToNext()) { 1607 return null; 1608 } 1609 byte[] data = cursor.getBlob(0); 1610 if (data == null) { 1611 return null; 1612 } 1613 return new ByteArrayInputStream(data); 1614 } finally { 1615 if (cursor != null) { 1616 cursor.close(); 1617 } 1618 } 1619 } 1620 } 1621 1622 protected interface RawContactsColumns { 1623 /** 1624 * A reference to the {@link ContactsContract.Contacts#_ID} that this 1625 * data belongs to. 1626 * <P>Type: INTEGER</P> 1627 */ 1628 public static final String CONTACT_ID = "contact_id"; 1629 1630 /** 1631 * Flag indicating that this {@link RawContacts} entry and its children have 1632 * been restricted to specific platform apps. 1633 * <P>Type: INTEGER (boolean)</P> 1634 * 1635 * @hide until finalized in future platform release 1636 */ 1637 public static final String IS_RESTRICTED = "is_restricted"; 1638 1639 /** 1640 * The aggregation mode for this contact. 1641 * <P>Type: INTEGER</P> 1642 */ 1643 public static final String AGGREGATION_MODE = "aggregation_mode"; 1644 1645 /** 1646 * The "deleted" flag: "0" by default, "1" if the row has been marked 1647 * for deletion. When {@link android.content.ContentResolver#delete} is 1648 * called on a raw contact, it is marked for deletion and removed from its 1649 * aggregate contact. The sync adaptor deletes the raw contact on the server and 1650 * then calls ContactResolver.delete once more, this time passing the 1651 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize 1652 * the data removal. 1653 * <P>Type: INTEGER</P> 1654 */ 1655 public static final String DELETED = "deleted"; 1656 1657 /** 1658 * The "name_verified" flag: "1" means that the name fields on this raw 1659 * contact can be trusted and therefore should be used for the entire 1660 * aggregated contact. 1661 * <p> 1662 * If an aggregated contact contains more than one raw contact with a 1663 * verified name, one of those verified names is chosen at random. 1664 * If an aggregated contact contains no verified names, the 1665 * name is chosen randomly from the constituent raw contacts. 1666 * </p> 1667 * <p> 1668 * Updating this flag from "0" to "1" automatically resets it to "0" on 1669 * all other raw contacts in the same aggregated contact. 1670 * </p> 1671 * <p> 1672 * Sync adapters should only specify a value for this column when 1673 * inserting a raw contact and leave it out when doing an update. 1674 * </p> 1675 * <p> 1676 * The default value is "0" 1677 * </p> 1678 * <p>Type: INTEGER</p> 1679 * 1680 * @hide 1681 */ 1682 public static final String NAME_VERIFIED = "name_verified"; 1683 1684 /** 1685 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or 1686 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. 1687 * <P>Type: INTEGER</P> 1688 */ 1689 public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only"; 1690 } 1691 1692 /** 1693 * Constants for the raw contacts table, which contains one row of contact 1694 * information for each person in each synced account. Sync adapters and 1695 * contact management apps 1696 * are the primary consumers of this API. 1697 * 1698 * <h3>Aggregation</h3> 1699 * <p> 1700 * As soon as a raw contact is inserted or whenever its constituent data 1701 * changes, the provider will check if the raw contact matches other 1702 * existing raw contacts and if so will aggregate it with those. The 1703 * aggregation is reflected in the {@link RawContacts} table by the change of the 1704 * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. 1705 * </p> 1706 * <p> 1707 * Changes to the structured name, organization, phone number, email address, 1708 * or nickname trigger a re-aggregation. 1709 * </p> 1710 * <p> 1711 * See also {@link AggregationExceptions} for a mechanism to control 1712 * aggregation programmatically. 1713 * </p> 1714 * 1715 * <h3>Operations</h3> 1716 * <dl> 1717 * <dt><b>Insert</b></dt> 1718 * <dd> 1719 * <p> 1720 * Raw contacts can be inserted incrementally or in a batch. 1721 * The incremental method is more traditional but less efficient. 1722 * It should be used 1723 * only if no {@link Data} values are available at the time the raw contact is created: 1724 * <pre> 1725 * ContentValues values = new ContentValues(); 1726 * values.put(RawContacts.ACCOUNT_TYPE, accountType); 1727 * values.put(RawContacts.ACCOUNT_NAME, accountName); 1728 * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); 1729 * long rawContactId = ContentUris.parseId(rawContactUri); 1730 * </pre> 1731 * </p> 1732 * <p> 1733 * Once {@link Data} values become available, insert those. 1734 * For example, here's how you would insert a name: 1735 * 1736 * <pre> 1737 * values.clear(); 1738 * values.put(Data.RAW_CONTACT_ID, rawContactId); 1739 * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); 1740 * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); 1741 * getContentResolver().insert(Data.CONTENT_URI, values); 1742 * </pre> 1743 * </p> 1744 * <p> 1745 * The batch method is by far preferred. It inserts the raw contact and its 1746 * constituent data rows in a single database transaction 1747 * and causes at most one aggregation pass. 1748 * <pre> 1749 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 1750 * ... 1751 * int rawContactInsertIndex = ops.size(); 1752 * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) 1753 * .withValue(RawContacts.ACCOUNT_TYPE, accountType) 1754 * .withValue(RawContacts.ACCOUNT_NAME, accountName) 1755 * .build()); 1756 * 1757 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 1758 * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) 1759 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 1760 * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") 1761 * .build()); 1762 * 1763 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 1764 * </pre> 1765 * </p> 1766 * <p> 1767 * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} 1768 * to refer to the as-yet-unknown index value of the raw contact inserted in the 1769 * first operation. 1770 * </p> 1771 * 1772 * <dt><b>Update</b></dt> 1773 * <dd><p> 1774 * Raw contacts can be updated incrementally or in a batch. 1775 * Batch mode should be used whenever possible. 1776 * The procedures and considerations are analogous to those documented above for inserts. 1777 * </p></dd> 1778 * <dt><b>Delete</b></dt> 1779 * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, 1780 * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw 1781 * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row 1782 * itself is also deleted automatically. 1783 * </p> 1784 * <p> 1785 * The invocation of {@code resolver.delete(...)}, does not immediately delete 1786 * a raw contacts row. 1787 * Instead, it sets the {@link #DELETED} flag on the raw contact and 1788 * removes the raw contact from its aggregate contact. 1789 * The sync adapter then deletes the raw contact from the server and 1790 * finalizes phone-side deletion by calling {@code resolver.delete(...)} 1791 * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> 1792 * <p>Some sync adapters are read-only, meaning that they only sync server-side 1793 * changes to the phone, but not the reverse. If one of those raw contacts 1794 * is marked for deletion, it will remain on the phone. However it will be 1795 * effectively invisible, because it will not be part of any aggregate contact. 1796 * </dd> 1797 * 1798 * <dt><b>Query</b></dt> 1799 * <dd> 1800 * <p> 1801 * It is easy to find all raw contacts in a Contact: 1802 * <pre> 1803 * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, 1804 * new String[]{RawContacts._ID}, 1805 * RawContacts.CONTACT_ID + "=?", 1806 * new String[]{String.valueOf(contactId)}, null); 1807 * </pre> 1808 * </p> 1809 * <p> 1810 * To find raw contacts within a specific account, 1811 * you can either put the account name and type in the selection or pass them as query 1812 * parameters. The latter approach is preferable, especially when you can reuse the 1813 * URI: 1814 * <pre> 1815 * Uri rawContactUri = RawContacts.URI.buildUpon() 1816 * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) 1817 * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) 1818 * .build(); 1819 * Cursor c1 = getContentResolver().query(rawContactUri, 1820 * RawContacts.STARRED + "<>0", null, null, null); 1821 * ... 1822 * Cursor c2 = getContentResolver().query(rawContactUri, 1823 * RawContacts.DELETED + "<>0", null, null, null); 1824 * </pre> 1825 * </p> 1826 * <p>The best way to read a raw contact along with all the data associated with it is 1827 * by using the {@link Entity} directory. If the raw contact has data rows, 1828 * the Entity cursor will contain a row for each data row. If the raw contact has no 1829 * data rows, the cursor will still contain one row with the raw contact-level information. 1830 * <pre> 1831 * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); 1832 * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); 1833 * Cursor c = getContentResolver().query(entityUri, 1834 * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, 1835 * null, null, null); 1836 * try { 1837 * while (c.moveToNext()) { 1838 * String sourceId = c.getString(0); 1839 * if (!c.isNull(1)) { 1840 * String mimeType = c.getString(2); 1841 * String data = c.getString(3); 1842 * ... 1843 * } 1844 * } 1845 * } finally { 1846 * c.close(); 1847 * } 1848 * </pre> 1849 * </p> 1850 * </dd> 1851 * </dl> 1852 * <h2>Columns</h2> 1853 * 1854 * <table class="jd-sumtable"> 1855 * <tr> 1856 * <th colspan='4'>RawContacts</th> 1857 * </tr> 1858 * <tr> 1859 * <td>long</td> 1860 * <td>{@link #_ID}</td> 1861 * <td>read-only</td> 1862 * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, 1863 * it is much better for a sync adapter to update a raw contact rather than to delete and 1864 * re-insert it.</td> 1865 * </tr> 1866 * <tr> 1867 * <td>long</td> 1868 * <td>{@link #CONTACT_ID}</td> 1869 * <td>read-only</td> 1870 * <td>The ID of the row in the {@link ContactsContract.Contacts} table 1871 * that this raw contact belongs 1872 * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled 1873 * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> 1874 * </tr> 1875 * <tr> 1876 * <td>int</td> 1877 * <td>{@link #AGGREGATION_MODE}</td> 1878 * <td>read/write</td> 1879 * <td>A mechanism that allows programmatic control of the aggregation process. The allowed 1880 * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} 1881 * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> 1882 * </tr> 1883 * <tr> 1884 * <td>int</td> 1885 * <td>{@link #DELETED}</td> 1886 * <td>read/write</td> 1887 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked 1888 * for deletion. When {@link android.content.ContentResolver#delete} is 1889 * called on a raw contact, it is marked for deletion and removed from its 1890 * aggregate contact. The sync adaptor deletes the raw contact on the server and 1891 * then calls ContactResolver.delete once more, this time passing the 1892 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize 1893 * the data removal.</td> 1894 * </tr> 1895 * <tr> 1896 * <td>int</td> 1897 * <td>{@link #TIMES_CONTACTED}</td> 1898 * <td>read/write</td> 1899 * <td>The number of times the contact has been contacted. To have an effect 1900 * on the corresponding value of the aggregate contact, this field 1901 * should be set at the time the raw contact is inserted. 1902 * After that, this value is typically updated via 1903 * {@link ContactsContract.Contacts#markAsContacted}.</td> 1904 * </tr> 1905 * <tr> 1906 * <td>long</td> 1907 * <td>{@link #LAST_TIME_CONTACTED}</td> 1908 * <td>read/write</td> 1909 * <td>The timestamp of the last time the contact was contacted. To have an effect 1910 * on the corresponding value of the aggregate contact, this field 1911 * should be set at the time the raw contact is inserted. 1912 * After that, this value is typically updated via 1913 * {@link ContactsContract.Contacts#markAsContacted}. 1914 * </td> 1915 * </tr> 1916 * <tr> 1917 * <td>int</td> 1918 * <td>{@link #STARRED}</td> 1919 * <td>read/write</td> 1920 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. 1921 * Changing this field immediately affects the corresponding aggregate contact: 1922 * if any raw contacts in that aggregate contact are starred, then the contact 1923 * itself is marked as starred.</td> 1924 * </tr> 1925 * <tr> 1926 * <td>String</td> 1927 * <td>{@link #CUSTOM_RINGTONE}</td> 1928 * <td>read/write</td> 1929 * <td>A custom ringtone associated with a raw contact. Typically this is the 1930 * URI returned by an activity launched with the 1931 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. 1932 * To have an effect on the corresponding value of the aggregate contact, this field 1933 * should be set at the time the raw contact is inserted. To set a custom 1934 * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE 1935 * Contacts.CUSTOM_RINGTONE} 1936 * instead.</td> 1937 * </tr> 1938 * <tr> 1939 * <td>int</td> 1940 * <td>{@link #SEND_TO_VOICEMAIL}</td> 1941 * <td>read/write</td> 1942 * <td>An indicator of whether calls from this raw contact should be forwarded 1943 * directly to voice mail ('1') or not ('0'). To have an effect 1944 * on the corresponding value of the aggregate contact, this field 1945 * should be set at the time the raw contact is inserted.</td> 1946 * </tr> 1947 * <tr> 1948 * <td>String</td> 1949 * <td>{@link #ACCOUNT_NAME}</td> 1950 * <td>read/write-once</td> 1951 * <td>The name of the account instance to which this row belongs, which when paired with 1952 * {@link #ACCOUNT_TYPE} identifies a specific account. 1953 * For example, this will be the Gmail address if it is a Google account. 1954 * It should be set at the time 1955 * the raw contact is inserted and never changed afterwards.</td> 1956 * </tr> 1957 * <tr> 1958 * <td>String</td> 1959 * <td>{@link #ACCOUNT_TYPE}</td> 1960 * <td>read/write-once</td> 1961 * <td> 1962 * <p> 1963 * The type of account to which this row belongs, which when paired with 1964 * {@link #ACCOUNT_NAME} identifies a specific account. 1965 * It should be set at the time 1966 * the raw contact is inserted and never changed afterwards. 1967 * </p> 1968 * <p> 1969 * To ensure uniqueness, new account types should be chosen according to the 1970 * Java package naming convention. Thus a Google account is of type "com.google". 1971 * </p> 1972 * </td> 1973 * </tr> 1974 * <tr> 1975 * <td>String</td> 1976 * <td>{@link #SOURCE_ID}</td> 1977 * <td>read/write</td> 1978 * <td>String that uniquely identifies this row to its source account. 1979 * Typically it is set at the time the raw contact is inserted and never 1980 * changed afterwards. The one notable exception is a new raw contact: it 1981 * will have an account name and type, but no source id. This 1982 * indicates to the sync adapter that a new contact needs to be created 1983 * server-side and its ID stored in the corresponding SOURCE_ID field on 1984 * the phone. 1985 * </td> 1986 * </tr> 1987 * <tr> 1988 * <td>int</td> 1989 * <td>{@link #VERSION}</td> 1990 * <td>read-only</td> 1991 * <td>Version number that is updated whenever this row or its related data 1992 * changes. This field can be used for optimistic locking of a raw contact. 1993 * </td> 1994 * </tr> 1995 * <tr> 1996 * <td>int</td> 1997 * <td>{@link #DIRTY}</td> 1998 * <td>read/write</td> 1999 * <td>Flag indicating that {@link #VERSION} has changed, and this row needs 2000 * to be synchronized by its owning account. The value is set to "1" automatically 2001 * whenever the raw contact changes, unless the URI has the 2002 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. 2003 * The sync adapter should always supply this query parameter to prevent 2004 * unnecessary synchronization: user changes some data on the server, 2005 * the sync adapter updates the contact on the phone (without the 2006 * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, 2007 * which triggers a sync to bring the changes to the server. 2008 * </td> 2009 * </tr> 2010 * <tr> 2011 * <td>String</td> 2012 * <td>{@link #SYNC1}</td> 2013 * <td>read/write</td> 2014 * <td>Generic column provided for arbitrary use by sync adapters. 2015 * The content provider 2016 * stores this information on behalf of the sync adapter but does not 2017 * interpret it in any way. 2018 * </td> 2019 * </tr> 2020 * <tr> 2021 * <td>String</td> 2022 * <td>{@link #SYNC2}</td> 2023 * <td>read/write</td> 2024 * <td>Generic column for use by sync adapters. 2025 * </td> 2026 * </tr> 2027 * <tr> 2028 * <td>String</td> 2029 * <td>{@link #SYNC3}</td> 2030 * <td>read/write</td> 2031 * <td>Generic column for use by sync adapters. 2032 * </td> 2033 * </tr> 2034 * <tr> 2035 * <td>String</td> 2036 * <td>{@link #SYNC4}</td> 2037 * <td>read/write</td> 2038 * <td>Generic column for use by sync adapters. 2039 * </td> 2040 * </tr> 2041 * </table> 2042 */ 2043 public static final class RawContacts implements BaseColumns, RawContactsColumns, 2044 ContactOptionsColumns, ContactNameColumns, SyncColumns { 2045 /** 2046 * This utility class cannot be instantiated 2047 */ 2048 private RawContacts() { 2049 } 2050 2051 /** 2052 * The content:// style URI for this table, which requests a directory of 2053 * raw contact rows matching the selection criteria. 2054 */ 2055 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); 2056 2057 /** 2058 * The MIME type of the results from {@link #CONTENT_URI} when a specific 2059 * ID value is not provided, and multiple raw contacts may be returned. 2060 */ 2061 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; 2062 2063 /** 2064 * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, 2065 * yielding a subdirectory of a single person. 2066 */ 2067 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact"; 2068 2069 /** 2070 * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. 2071 */ 2072 public static final int AGGREGATION_MODE_DEFAULT = 0; 2073 2074 /** 2075 * Do not use. 2076 * 2077 * TODO: deprecate in favor of {@link #AGGREGATION_MODE_DEFAULT} 2078 */ 2079 public static final int AGGREGATION_MODE_IMMEDIATE = 1; 2080 2081 /** 2082 * <p> 2083 * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. 2084 * Changes to the raw contact will update the associated aggregate contact but will not 2085 * result in any change in how the contact is aggregated. Similar to 2086 * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding 2087 * {@link Contacts} aggregate. 2088 * </p> 2089 * <p> 2090 * This can be used to postpone aggregation until after a series of updates, for better 2091 * performance and/or user experience. 2092 * </p> 2093 * <p> 2094 * Note that changing 2095 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to 2096 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any 2097 * subsequent 2098 * change to the raw contact's data will. 2099 * </p> 2100 */ 2101 public static final int AGGREGATION_MODE_SUSPENDED = 2; 2102 2103 /** 2104 * <p> 2105 * Aggregation mode: never aggregate this raw contact. The raw contact will not 2106 * have a corresponding {@link Contacts} aggregate and therefore will not be included in 2107 * {@link Contacts} query results. 2108 * </p> 2109 * <p> 2110 * For example, this mode can be used for a raw contact that is marked for deletion while 2111 * waiting for the deletion to occur on the server side. 2112 * </p> 2113 * 2114 * @see #AGGREGATION_MODE_SUSPENDED 2115 */ 2116 public static final int AGGREGATION_MODE_DISABLED = 3; 2117 2118 /** 2119 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} 2120 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} 2121 * entry of the given {@link RawContacts} entry. 2122 */ 2123 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { 2124 // TODO: use a lighter query by joining rawcontacts with contacts in provider 2125 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); 2126 final Cursor cursor = resolver.query(dataUri, new String[] { 2127 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY 2128 }, null, null, null); 2129 2130 Uri lookupUri = null; 2131 try { 2132 if (cursor != null && cursor.moveToFirst()) { 2133 final long contactId = cursor.getLong(0); 2134 final String lookupKey = cursor.getString(1); 2135 return Contacts.getLookupUri(contactId, lookupKey); 2136 } 2137 } finally { 2138 if (cursor != null) cursor.close(); 2139 } 2140 return lookupUri; 2141 } 2142 2143 /** 2144 * A sub-directory of a single raw contact that contains all of its 2145 * {@link ContactsContract.Data} rows. To access this directory 2146 * append {@link Data#CONTENT_DIRECTORY} to the contact URI. 2147 * 2148 * TODO: deprecate in favor of {@link RawContacts.Entity}. 2149 */ 2150 public static final class Data implements BaseColumns, DataColumns { 2151 /** 2152 * no public constructor since this is a utility class 2153 */ 2154 private Data() { 2155 } 2156 2157 /** 2158 * The directory twig for this sub-table 2159 */ 2160 public static final String CONTENT_DIRECTORY = "data"; 2161 } 2162 2163 /** 2164 * <p> 2165 * A sub-directory of a single raw contact that contains all of its 2166 * {@link ContactsContract.Data} rows. To access this directory append 2167 * {@link #CONTENT_DIRECTORY} to the contact URI. See 2168 * {@link RawContactsEntity} for a stand-alone table containing the same 2169 * data. 2170 * </p> 2171 * <p> 2172 * Entity has two ID fields: {@link #_ID} for the raw contact 2173 * and {@link #DATA_ID} for the data rows. 2174 * Entity always contains at least one row, even if there are no 2175 * actual data rows. In this case the {@link #DATA_ID} field will be 2176 * null. 2177 * </p> 2178 * <p> 2179 * Entity reads all 2180 * data for a raw contact in one transaction, to guarantee 2181 * consistency. 2182 * </p> 2183 */ 2184 public static final class Entity implements BaseColumns, DataColumns { 2185 /** 2186 * no public constructor since this is a utility class 2187 */ 2188 private Entity() { 2189 } 2190 2191 /** 2192 * The directory twig for this sub-table 2193 */ 2194 public static final String CONTENT_DIRECTORY = "entity"; 2195 2196 /** 2197 * The ID of the data row. The value will be null if this raw contact has no 2198 * data rows. 2199 * <P>Type: INTEGER</P> 2200 */ 2201 public static final String DATA_ID = "data_id"; 2202 } 2203 2204 /** 2205 * TODO: javadoc 2206 * @param cursor 2207 * @return 2208 */ 2209 public static EntityIterator newEntityIterator(Cursor cursor) { 2210 return new EntityIteratorImpl(cursor); 2211 } 2212 2213 private static class EntityIteratorImpl extends CursorEntityIterator { 2214 private static final String[] DATA_KEYS = new String[]{ 2215 Data.DATA1, 2216 Data.DATA2, 2217 Data.DATA3, 2218 Data.DATA4, 2219 Data.DATA5, 2220 Data.DATA6, 2221 Data.DATA7, 2222 Data.DATA8, 2223 Data.DATA9, 2224 Data.DATA10, 2225 Data.DATA11, 2226 Data.DATA12, 2227 Data.DATA13, 2228 Data.DATA14, 2229 Data.DATA15, 2230 Data.SYNC1, 2231 Data.SYNC2, 2232 Data.SYNC3, 2233 Data.SYNC4}; 2234 2235 public EntityIteratorImpl(Cursor cursor) { 2236 super(cursor); 2237 } 2238 2239 @Override 2240 public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) 2241 throws RemoteException { 2242 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); 2243 final long rawContactId = cursor.getLong(columnRawContactId); 2244 2245 // we expect the cursor is already at the row we need to read from 2246 ContentValues cv = new ContentValues(); 2247 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); 2248 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); 2249 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); 2250 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); 2251 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); 2252 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); 2253 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); 2254 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); 2255 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); 2256 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); 2257 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); 2258 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); 2259 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); 2260 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, IS_RESTRICTED); 2261 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED); 2262 android.content.Entity contact = new android.content.Entity(cv); 2263 2264 // read data rows until the contact id changes 2265 do { 2266 if (rawContactId != cursor.getLong(columnRawContactId)) { 2267 break; 2268 } 2269 // add the data to to the contact 2270 cv = new ContentValues(); 2271 cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); 2272 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 2273 Data.RES_PACKAGE); 2274 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); 2275 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); 2276 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, 2277 Data.IS_SUPER_PRIMARY); 2278 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); 2279 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 2280 CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); 2281 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 2282 Data.DATA_VERSION); 2283 for (String key : DATA_KEYS) { 2284 final int columnIndex = cursor.getColumnIndexOrThrow(key); 2285 switch (cursor.getType(columnIndex)) { 2286 case Cursor.FIELD_TYPE_NULL: 2287 // don't put anything 2288 break; 2289 case Cursor.FIELD_TYPE_INTEGER: 2290 case Cursor.FIELD_TYPE_FLOAT: 2291 case Cursor.FIELD_TYPE_STRING: 2292 cv.put(key, cursor.getString(columnIndex)); 2293 break; 2294 case Cursor.FIELD_TYPE_BLOB: 2295 cv.put(key, cursor.getBlob(columnIndex)); 2296 break; 2297 default: 2298 throw new IllegalStateException("Invalid or unhandled data type"); 2299 } 2300 } 2301 contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); 2302 } while (cursor.moveToNext()); 2303 2304 return contact; 2305 } 2306 2307 } 2308 } 2309 2310 /** 2311 * Social status update columns. 2312 * 2313 * @see StatusUpdates 2314 * @see ContactsContract.Data 2315 */ 2316 protected interface StatusColumns { 2317 /** 2318 * Contact's latest presence level. 2319 * <P>Type: INTEGER (one of the values below)</P> 2320 */ 2321 public static final String PRESENCE = "mode"; 2322 2323 /** 2324 * @deprecated use {@link #PRESENCE} 2325 */ 2326 @Deprecated 2327 public static final String PRESENCE_STATUS = PRESENCE; 2328 2329 /** 2330 * An allowed value of {@link #PRESENCE}. 2331 */ 2332 int OFFLINE = 0; 2333 2334 /** 2335 * An allowed value of {@link #PRESENCE}. 2336 */ 2337 int INVISIBLE = 1; 2338 2339 /** 2340 * An allowed value of {@link #PRESENCE}. 2341 */ 2342 int AWAY = 2; 2343 2344 /** 2345 * An allowed value of {@link #PRESENCE}. 2346 */ 2347 int IDLE = 3; 2348 2349 /** 2350 * An allowed value of {@link #PRESENCE}. 2351 */ 2352 int DO_NOT_DISTURB = 4; 2353 2354 /** 2355 * An allowed value of {@link #PRESENCE}. 2356 */ 2357 int AVAILABLE = 5; 2358 2359 /** 2360 * Contact latest status update. 2361 * <p>Type: TEXT</p> 2362 */ 2363 public static final String STATUS = "status"; 2364 2365 /** 2366 * @deprecated use {@link #STATUS} 2367 */ 2368 @Deprecated 2369 public static final String PRESENCE_CUSTOM_STATUS = STATUS; 2370 2371 /** 2372 * The absolute time in milliseconds when the latest status was inserted/updated. 2373 * <p>Type: NUMBER</p> 2374 */ 2375 public static final String STATUS_TIMESTAMP = "status_ts"; 2376 2377 /** 2378 * The package containing resources for this status: label and icon. 2379 * <p>Type: NUMBER</p> 2380 */ 2381 public static final String STATUS_RES_PACKAGE = "status_res_package"; 2382 2383 /** 2384 * The resource ID of the label describing the source of the status update, e.g. "Google 2385 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. 2386 * <p>Type: NUMBER</p> 2387 */ 2388 public static final String STATUS_LABEL = "status_label"; 2389 2390 /** 2391 * The resource ID of the icon for the source of the status update. 2392 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. 2393 * <p>Type: NUMBER</p> 2394 */ 2395 public static final String STATUS_ICON = "status_icon"; 2396 2397 /** 2398 * Contact's audio/video chat capability level. 2399 * <P>Type: INTEGER (one of the values below)</P> 2400 */ 2401 public static final String CHAT_CAPABILITY = "chat_capability"; 2402 2403 /** 2404 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone 2405 * and speaker) 2406 */ 2407 public static final int CAPABILITY_HAS_VOICE = 1; 2408 2409 /** 2410 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can 2411 * display a video feed. 2412 */ 2413 public static final int CAPABILITY_HAS_VIDEO = 2; 2414 2415 /** 2416 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a 2417 * camera that can be used for video chat (e.g. a front-facing camera on a phone). 2418 */ 2419 public static final int CAPABILITY_HAS_CAMERA = 4; 2420 } 2421 2422 /** 2423 * Columns in the Data table. 2424 * 2425 * @see ContactsContract.Data 2426 */ 2427 protected interface DataColumns { 2428 /** 2429 * The package name to use when creating {@link Resources} objects for 2430 * this data row. This value is only designed for use when building user 2431 * interfaces, and should not be used to infer the owner. 2432 * 2433 * @hide 2434 */ 2435 public static final String RES_PACKAGE = "res_package"; 2436 2437 /** 2438 * The MIME type of the item represented by this row. 2439 */ 2440 public static final String MIMETYPE = "mimetype"; 2441 2442 /** 2443 * A reference to the {@link RawContacts#_ID} 2444 * that this data belongs to. 2445 */ 2446 public static final String RAW_CONTACT_ID = "raw_contact_id"; 2447 2448 /** 2449 * Whether this is the primary entry of its kind for the raw contact it belongs to. 2450 * <P>Type: INTEGER (if set, non-0 means true)</P> 2451 */ 2452 public static final String IS_PRIMARY = "is_primary"; 2453 2454 /** 2455 * Whether this is the primary entry of its kind for the aggregate 2456 * contact it belongs to. Any data record that is "super primary" must 2457 * also be "primary". 2458 * <P>Type: INTEGER (if set, non-0 means true)</P> 2459 */ 2460 public static final String IS_SUPER_PRIMARY = "is_super_primary"; 2461 2462 /** 2463 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or 2464 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. 2465 * <P>Type: INTEGER</P> 2466 */ 2467 public static final String IS_READ_ONLY = "is_read_only"; 2468 2469 /** 2470 * The version of this data record. This is a read-only value. The data column is 2471 * guaranteed to not change without the version going up. This value is monotonically 2472 * increasing. 2473 * <P>Type: INTEGER</P> 2474 */ 2475 public static final String DATA_VERSION = "data_version"; 2476 2477 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2478 public static final String DATA1 = "data1"; 2479 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2480 public static final String DATA2 = "data2"; 2481 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2482 public static final String DATA3 = "data3"; 2483 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2484 public static final String DATA4 = "data4"; 2485 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2486 public static final String DATA5 = "data5"; 2487 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2488 public static final String DATA6 = "data6"; 2489 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2490 public static final String DATA7 = "data7"; 2491 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2492 public static final String DATA8 = "data8"; 2493 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2494 public static final String DATA9 = "data9"; 2495 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2496 public static final String DATA10 = "data10"; 2497 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2498 public static final String DATA11 = "data11"; 2499 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2500 public static final String DATA12 = "data12"; 2501 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2502 public static final String DATA13 = "data13"; 2503 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 2504 public static final String DATA14 = "data14"; 2505 /** 2506 * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, 2507 * this field is used to store BLOBs (binary data). 2508 */ 2509 public static final String DATA15 = "data15"; 2510 2511 /** Generic column for use by sync adapters. */ 2512 public static final String SYNC1 = "data_sync1"; 2513 /** Generic column for use by sync adapters. */ 2514 public static final String SYNC2 = "data_sync2"; 2515 /** Generic column for use by sync adapters. */ 2516 public static final String SYNC3 = "data_sync3"; 2517 /** Generic column for use by sync adapters. */ 2518 public static final String SYNC4 = "data_sync4"; 2519 } 2520 2521 /** 2522 * Combines all columns returned by {@link ContactsContract.Data} table queries. 2523 * 2524 * @see ContactsContract.Data 2525 */ 2526 protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, 2527 RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, 2528 ContactStatusColumns { 2529 } 2530 2531 /** 2532 * <p> 2533 * Constants for the data table, which contains data points tied to a raw 2534 * contact. Each row of the data table is typically used to store a single 2535 * piece of contact 2536 * information (such as a phone number) and its 2537 * associated metadata (such as whether it is a work or home number). 2538 * </p> 2539 * <h3>Data kinds</h3> 2540 * <p> 2541 * Data is a generic table that can hold any kind of contact data. 2542 * The kind of data stored in a given row is specified by the row's 2543 * {@link #MIMETYPE} value, which determines the meaning of the 2544 * generic columns {@link #DATA1} through 2545 * {@link #DATA15}. 2546 * For example, if the data kind is 2547 * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column 2548 * {@link #DATA1} stores the 2549 * phone number, but if the data kind is 2550 * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} 2551 * stores the email address. 2552 * Sync adapters and applications can introduce their own data kinds. 2553 * </p> 2554 * <p> 2555 * ContactsContract defines a small number of pre-defined data kinds, e.g. 2556 * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a 2557 * convenience, these classes define data kind specific aliases for DATA1 etc. 2558 * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as 2559 * {@link ContactsContract.Data Data.DATA1}. 2560 * </p> 2561 * <p> 2562 * {@link #DATA1} is an indexed column and should be used for the data element that is 2563 * expected to be most frequently used in query selections. For example, in the 2564 * case of a row representing email addresses {@link #DATA1} should probably 2565 * be used for the email address itself, while {@link #DATA2} etc can be 2566 * used for auxiliary information like type of email address. 2567 * <p> 2568 * <p> 2569 * By convention, {@link #DATA15} is used for storing BLOBs (binary data). 2570 * </p> 2571 * <p> 2572 * The sync adapter for a given account type must correctly handle every data type 2573 * used in the corresponding raw contacts. Otherwise it could result in lost or 2574 * corrupted data. 2575 * </p> 2576 * <p> 2577 * Similarly, you should refrain from introducing new kinds of data for an other 2578 * party's account types. For example, if you add a data row for 2579 * "favorite song" to a raw contact owned by a Google account, it will not 2580 * get synced to the server, because the Google sync adapter does not know 2581 * how to handle this data kind. Thus new data kinds are typically 2582 * introduced along with new account types, i.e. new sync adapters. 2583 * </p> 2584 * <h3>Batch operations</h3> 2585 * <p> 2586 * Data rows can be inserted/updated/deleted using the traditional 2587 * {@link ContentResolver#insert}, {@link ContentResolver#update} and 2588 * {@link ContentResolver#delete} methods, however the newer mechanism based 2589 * on a batch of {@link ContentProviderOperation} will prove to be a better 2590 * choice in almost all cases. All operations in a batch are executed in a 2591 * single transaction, which ensures that the phone-side and server-side 2592 * state of a raw contact are always consistent. Also, the batch-based 2593 * approach is far more efficient: not only are the database operations 2594 * faster when executed in a single transaction, but also sending a batch of 2595 * commands to the content provider saves a lot of time on context switching 2596 * between your process and the process in which the content provider runs. 2597 * </p> 2598 * <p> 2599 * The flip side of using batched operations is that a large batch may lock 2600 * up the database for a long time preventing other applications from 2601 * accessing data and potentially causing ANRs ("Application Not Responding" 2602 * dialogs.) 2603 * </p> 2604 * <p> 2605 * To avoid such lockups of the database, make sure to insert "yield points" 2606 * in the batch. A yield point indicates to the content provider that before 2607 * executing the next operation it can commit the changes that have already 2608 * been made, yield to other requests, open another transaction and continue 2609 * processing operations. A yield point will not automatically commit the 2610 * transaction, but only if there is another request waiting on the 2611 * database. Normally a sync adapter should insert a yield point at the 2612 * beginning of each raw contact operation sequence in the batch. See 2613 * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. 2614 * </p> 2615 * <h3>Operations</h3> 2616 * <dl> 2617 * <dt><b>Insert</b></dt> 2618 * <dd> 2619 * <p> 2620 * An individual data row can be inserted using the traditional 2621 * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows 2622 * should always be inserted as a batch. 2623 * </p> 2624 * <p> 2625 * An example of a traditional insert: 2626 * <pre> 2627 * ContentValues values = new ContentValues(); 2628 * values.put(Data.RAW_CONTACT_ID, rawContactId); 2629 * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); 2630 * values.put(Phone.NUMBER, "1-800-GOOG-411"); 2631 * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); 2632 * values.put(Phone.LABEL, "free directory assistance"); 2633 * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); 2634 * </pre> 2635 * <p> 2636 * The same done using ContentProviderOperations: 2637 * <pre> 2638 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 2639 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 2640 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 2641 * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) 2642 * .withValue(Phone.NUMBER, "1-800-GOOG-411") 2643 * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) 2644 * .withValue(Phone.LABEL, "free directory assistance") 2645 * .build()); 2646 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 2647 * </pre> 2648 * </p> 2649 * <dt><b>Update</b></dt> 2650 * <dd> 2651 * <p> 2652 * Just as with insert, update can be done incrementally or as a batch, 2653 * the batch mode being the preferred method: 2654 * <pre> 2655 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 2656 * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) 2657 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) 2658 * .withValue(Email.DATA, "somebody@android.com") 2659 * .build()); 2660 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 2661 * </pre> 2662 * </p> 2663 * </dd> 2664 * <dt><b>Delete</b></dt> 2665 * <dd> 2666 * <p> 2667 * Just as with insert and update, deletion can be done either using the 2668 * {@link ContentResolver#delete} method or using a ContentProviderOperation: 2669 * <pre> 2670 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 2671 * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) 2672 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) 2673 * .build()); 2674 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 2675 * </pre> 2676 * </p> 2677 * </dd> 2678 * <dt><b>Query</b></dt> 2679 * <dd> 2680 * <p> 2681 * <dl> 2682 * <dt>Finding all Data of a given type for a given contact</dt> 2683 * <dd> 2684 * <pre> 2685 * Cursor c = getContentResolver().query(Data.CONTENT_URI, 2686 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, 2687 * Data.CONTACT_ID + "=?" + " AND " 2688 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", 2689 * new String[] {String.valueOf(contactId)}, null); 2690 * </pre> 2691 * </p> 2692 * <p> 2693 * </dd> 2694 * <dt>Finding all Data of a given type for a given raw contact</dt> 2695 * <dd> 2696 * <pre> 2697 * Cursor c = getContentResolver().query(Data.CONTENT_URI, 2698 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, 2699 * Data.RAW_CONTACT_ID + "=?" + " AND " 2700 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", 2701 * new String[] {String.valueOf(rawContactId)}, null); 2702 * </pre> 2703 * </dd> 2704 * <dt>Finding all Data for a given raw contact</dt> 2705 * <dd> 2706 * Most sync adapters will want to read all data rows for a raw contact 2707 * along with the raw contact itself. For that you should use the 2708 * {@link RawContactsEntity}. See also {@link RawContacts}. 2709 * </dd> 2710 * </dl> 2711 * </p> 2712 * </dd> 2713 * </dl> 2714 * <h2>Columns</h2> 2715 * <p> 2716 * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you 2717 * should explicitly specify a projection to only those columns that you need. 2718 * </p> 2719 * <table class="jd-sumtable"> 2720 * <tr> 2721 * <th colspan='4'>Data</th> 2722 * </tr> 2723 * <tr> 2724 * <td style="width: 7em;">long</td> 2725 * <td style="width: 20em;">{@link #_ID}</td> 2726 * <td style="width: 5em;">read-only</td> 2727 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words, 2728 * it would be a bad idea to delete and reinsert a data row. A sync adapter should 2729 * always do an update instead.</td> 2730 * </tr> 2731 * <tr> 2732 * <td>String</td> 2733 * <td>{@link #MIMETYPE}</td> 2734 * <td>read/write-once</td> 2735 * <td> 2736 * <p>The MIME type of the item represented by this row. Examples of common 2737 * MIME types are: 2738 * <ul> 2739 * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> 2740 * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> 2741 * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> 2742 * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> 2743 * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> 2744 * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> 2745 * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> 2746 * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> 2747 * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> 2748 * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> 2749 * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> 2750 * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> 2751 * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> 2752 * </ul> 2753 * </p> 2754 * </td> 2755 * </tr> 2756 * <tr> 2757 * <td>long</td> 2758 * <td>{@link #RAW_CONTACT_ID}</td> 2759 * <td>read/write-once</td> 2760 * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td> 2761 * </tr> 2762 * <tr> 2763 * <td>int</td> 2764 * <td>{@link #IS_PRIMARY}</td> 2765 * <td>read/write</td> 2766 * <td>Whether this is the primary entry of its kind for the raw contact it belongs to. 2767 * "1" if true, "0" if false. 2768 * </td> 2769 * </tr> 2770 * <tr> 2771 * <td>int</td> 2772 * <td>{@link #IS_SUPER_PRIMARY}</td> 2773 * <td>read/write</td> 2774 * <td>Whether this is the primary entry of its kind for the aggregate 2775 * contact it belongs to. Any data record that is "super primary" must 2776 * also be "primary". For example, the super-primary entry may be 2777 * interpreted as the default contact value of its kind (for example, 2778 * the default phone number to use for the contact).</td> 2779 * </tr> 2780 * <tr> 2781 * <td>int</td> 2782 * <td>{@link #DATA_VERSION}</td> 2783 * <td>read-only</td> 2784 * <td>The version of this data record. Whenever the data row changes 2785 * the version goes up. This value is monotonically increasing.</td> 2786 * </tr> 2787 * <tr> 2788 * <td>Any type</td> 2789 * <td> 2790 * {@link #DATA1}<br> 2791 * {@link #DATA2}<br> 2792 * {@link #DATA3}<br> 2793 * {@link #DATA4}<br> 2794 * {@link #DATA5}<br> 2795 * {@link #DATA6}<br> 2796 * {@link #DATA7}<br> 2797 * {@link #DATA8}<br> 2798 * {@link #DATA9}<br> 2799 * {@link #DATA10}<br> 2800 * {@link #DATA11}<br> 2801 * {@link #DATA12}<br> 2802 * {@link #DATA13}<br> 2803 * {@link #DATA14}<br> 2804 * {@link #DATA15} 2805 * </td> 2806 * <td>read/write</td> 2807 * <td> 2808 * <p> 2809 * Generic data columns. The meaning of each column is determined by the 2810 * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing 2811 * BLOBs (binary data). 2812 * </p> 2813 * <p> 2814 * Data columns whose meaning is not explicitly defined for a given MIMETYPE 2815 * should not be used. There is no guarantee that any sync adapter will 2816 * preserve them. Sync adapters themselves should not use such columns either, 2817 * but should instead use {@link #SYNC1}-{@link #SYNC4}. 2818 * </p> 2819 * </td> 2820 * </tr> 2821 * <tr> 2822 * <td>Any type</td> 2823 * <td> 2824 * {@link #SYNC1}<br> 2825 * {@link #SYNC2}<br> 2826 * {@link #SYNC3}<br> 2827 * {@link #SYNC4} 2828 * </td> 2829 * <td>read/write</td> 2830 * <td>Generic columns for use by sync adapters. For example, a Photo row 2831 * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) 2832 * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> 2833 * </tr> 2834 * </table> 2835 * 2836 * <p> 2837 * Some columns from the most recent associated status update are also available 2838 * through an implicit join. 2839 * </p> 2840 * <table class="jd-sumtable"> 2841 * <tr> 2842 * <th colspan='4'>Join with {@link StatusUpdates}</th> 2843 * </tr> 2844 * <tr> 2845 * <td style="width: 7em;">int</td> 2846 * <td style="width: 20em;">{@link #PRESENCE}</td> 2847 * <td style="width: 5em;">read-only</td> 2848 * <td>IM presence status linked to this data row. Compare with 2849 * {@link #CONTACT_PRESENCE}, which contains the contact's presence across 2850 * all IM rows. See {@link StatusUpdates} for individual status definitions. 2851 * The provider may choose not to store this value 2852 * in persistent storage. The expectation is that presence status will be 2853 * updated on a regular basic. 2854 * </td> 2855 * </tr> 2856 * <tr> 2857 * <td>String</td> 2858 * <td>{@link #STATUS}</td> 2859 * <td>read-only</td> 2860 * <td>Latest status update linked with this data row.</td> 2861 * </tr> 2862 * <tr> 2863 * <td>long</td> 2864 * <td>{@link #STATUS_TIMESTAMP}</td> 2865 * <td>read-only</td> 2866 * <td>The absolute time in milliseconds when the latest status was 2867 * inserted/updated for this data row.</td> 2868 * </tr> 2869 * <tr> 2870 * <td>String</td> 2871 * <td>{@link #STATUS_RES_PACKAGE}</td> 2872 * <td>read-only</td> 2873 * <td>The package containing resources for this status: label and icon.</td> 2874 * </tr> 2875 * <tr> 2876 * <td>long</td> 2877 * <td>{@link #STATUS_LABEL}</td> 2878 * <td>read-only</td> 2879 * <td>The resource ID of the label describing the source of status update linked 2880 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 2881 * </tr> 2882 * <tr> 2883 * <td>long</td> 2884 * <td>{@link #STATUS_ICON}</td> 2885 * <td>read-only</td> 2886 * <td>The resource ID of the icon for the source of the status update linked 2887 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 2888 * </tr> 2889 * </table> 2890 * 2891 * <p> 2892 * Some columns from the associated raw contact are also available through an 2893 * implicit join. The other columns are excluded as uninteresting in this 2894 * context. 2895 * </p> 2896 * 2897 * <table class="jd-sumtable"> 2898 * <tr> 2899 * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> 2900 * </tr> 2901 * <tr> 2902 * <td style="width: 7em;">long</td> 2903 * <td style="width: 20em;">{@link #CONTACT_ID}</td> 2904 * <td style="width: 5em;">read-only</td> 2905 * <td>The id of the row in the {@link Contacts} table that this data belongs 2906 * to.</td> 2907 * </tr> 2908 * <tr> 2909 * <td>int</td> 2910 * <td>{@link #AGGREGATION_MODE}</td> 2911 * <td>read-only</td> 2912 * <td>See {@link RawContacts}.</td> 2913 * </tr> 2914 * <tr> 2915 * <td>int</td> 2916 * <td>{@link #DELETED}</td> 2917 * <td>read-only</td> 2918 * <td>See {@link RawContacts}.</td> 2919 * </tr> 2920 * </table> 2921 * 2922 * <p> 2923 * The ID column for the associated aggregated contact table 2924 * {@link ContactsContract.Contacts} is available 2925 * via the implicit join to the {@link RawContacts} table, see above. 2926 * The remaining columns from this table are also 2927 * available, through an implicit join. This 2928 * facilitates lookup by 2929 * the value of a single data element, such as the email address. 2930 * </p> 2931 * 2932 * <table class="jd-sumtable"> 2933 * <tr> 2934 * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> 2935 * </tr> 2936 * <tr> 2937 * <td style="width: 7em;">String</td> 2938 * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> 2939 * <td style="width: 5em;">read-only</td> 2940 * <td>See {@link ContactsContract.Contacts}</td> 2941 * </tr> 2942 * <tr> 2943 * <td>String</td> 2944 * <td>{@link #DISPLAY_NAME}</td> 2945 * <td>read-only</td> 2946 * <td>See {@link ContactsContract.Contacts}</td> 2947 * </tr> 2948 * <tr> 2949 * <td>long</td> 2950 * <td>{@link #PHOTO_ID}</td> 2951 * <td>read-only</td> 2952 * <td>See {@link ContactsContract.Contacts}.</td> 2953 * </tr> 2954 * <tr> 2955 * <td>int</td> 2956 * <td>{@link #IN_VISIBLE_GROUP}</td> 2957 * <td>read-only</td> 2958 * <td>See {@link ContactsContract.Contacts}.</td> 2959 * </tr> 2960 * <tr> 2961 * <td>int</td> 2962 * <td>{@link #HAS_PHONE_NUMBER}</td> 2963 * <td>read-only</td> 2964 * <td>See {@link ContactsContract.Contacts}.</td> 2965 * </tr> 2966 * <tr> 2967 * <td>int</td> 2968 * <td>{@link #TIMES_CONTACTED}</td> 2969 * <td>read-only</td> 2970 * <td>See {@link ContactsContract.Contacts}.</td> 2971 * </tr> 2972 * <tr> 2973 * <td>long</td> 2974 * <td>{@link #LAST_TIME_CONTACTED}</td> 2975 * <td>read-only</td> 2976 * <td>See {@link ContactsContract.Contacts}.</td> 2977 * </tr> 2978 * <tr> 2979 * <td>int</td> 2980 * <td>{@link #STARRED}</td> 2981 * <td>read-only</td> 2982 * <td>See {@link ContactsContract.Contacts}.</td> 2983 * </tr> 2984 * <tr> 2985 * <td>String</td> 2986 * <td>{@link #CUSTOM_RINGTONE}</td> 2987 * <td>read-only</td> 2988 * <td>See {@link ContactsContract.Contacts}.</td> 2989 * </tr> 2990 * <tr> 2991 * <td>int</td> 2992 * <td>{@link #SEND_TO_VOICEMAIL}</td> 2993 * <td>read-only</td> 2994 * <td>See {@link ContactsContract.Contacts}.</td> 2995 * </tr> 2996 * <tr> 2997 * <td>int</td> 2998 * <td>{@link #CONTACT_PRESENCE}</td> 2999 * <td>read-only</td> 3000 * <td>See {@link ContactsContract.Contacts}.</td> 3001 * </tr> 3002 * <tr> 3003 * <td>String</td> 3004 * <td>{@link #CONTACT_STATUS}</td> 3005 * <td>read-only</td> 3006 * <td>See {@link ContactsContract.Contacts}.</td> 3007 * </tr> 3008 * <tr> 3009 * <td>long</td> 3010 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> 3011 * <td>read-only</td> 3012 * <td>See {@link ContactsContract.Contacts}.</td> 3013 * </tr> 3014 * <tr> 3015 * <td>String</td> 3016 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> 3017 * <td>read-only</td> 3018 * <td>See {@link ContactsContract.Contacts}.</td> 3019 * </tr> 3020 * <tr> 3021 * <td>long</td> 3022 * <td>{@link #CONTACT_STATUS_LABEL}</td> 3023 * <td>read-only</td> 3024 * <td>See {@link ContactsContract.Contacts}.</td> 3025 * </tr> 3026 * <tr> 3027 * <td>long</td> 3028 * <td>{@link #CONTACT_STATUS_ICON}</td> 3029 * <td>read-only</td> 3030 * <td>See {@link ContactsContract.Contacts}.</td> 3031 * </tr> 3032 * </table> 3033 */ 3034 public final static class Data implements DataColumnsWithJoins { 3035 /** 3036 * This utility class cannot be instantiated 3037 */ 3038 private Data() {} 3039 3040 /** 3041 * The content:// style URI for this table, which requests a directory 3042 * of data rows matching the selection criteria. 3043 */ 3044 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); 3045 3046 /** 3047 * The MIME type of the results from {@link #CONTENT_URI}. 3048 */ 3049 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; 3050 3051 /** 3052 * <p> 3053 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward 3054 * Data.CONTENT_URI contains only exportable data. 3055 * </p> 3056 * <p> 3057 * This flag is useful (currently) only for vCard exporter in Contacts app, which 3058 * needs to exclude "un-exportable" data from available data to export, while 3059 * Contacts app itself has priviledge to access all data including "un-exportable" 3060 * ones and providers return all of them regardless of the callers' intention. 3061 * </p> 3062 * <p> 3063 * Type: INTEGER 3064 * </p> 3065 * 3066 * @hide Maybe available only in Eclair and not really ready for public use. 3067 * TODO: remove, or implement this feature completely. As of now (Eclair), 3068 * we only use this flag in queryEntities(), not query(). 3069 */ 3070 public static final String FOR_EXPORT_ONLY = "for_export_only"; 3071 3072 /** 3073 * <p> 3074 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} 3075 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} 3076 * entry of the given {@link ContactsContract.Data} entry. 3077 * </p> 3078 * <p> 3079 * Returns the Uri for the contact in the first entry returned by 3080 * {@link ContentResolver#query(Uri, String[], String, String[], String)} 3081 * for the provided {@code dataUri}. If the query returns null or empty 3082 * results, silently returns null. 3083 * </p> 3084 */ 3085 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { 3086 final Cursor cursor = resolver.query(dataUri, new String[] { 3087 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY 3088 }, null, null, null); 3089 3090 Uri lookupUri = null; 3091 try { 3092 if (cursor != null && cursor.moveToFirst()) { 3093 final long contactId = cursor.getLong(0); 3094 final String lookupKey = cursor.getString(1); 3095 return Contacts.getLookupUri(contactId, lookupKey); 3096 } 3097 } finally { 3098 if (cursor != null) cursor.close(); 3099 } 3100 return lookupUri; 3101 } 3102 } 3103 3104 /** 3105 * <p> 3106 * Constants for the raw contacts entities table, which can be thought of as 3107 * an outer join of the raw_contacts table with the data table. It is a strictly 3108 * read-only table. 3109 * </p> 3110 * <p> 3111 * If a raw contact has data rows, the RawContactsEntity cursor will contain 3112 * a one row for each data row. If the raw contact has no data rows, the 3113 * cursor will still contain one row with the raw contact-level information 3114 * and nulls for data columns. 3115 * 3116 * <pre> 3117 * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); 3118 * Cursor c = getContentResolver().query(entityUri, 3119 * new String[]{ 3120 * RawContactsEntity.SOURCE_ID, 3121 * RawContactsEntity.DATA_ID, 3122 * RawContactsEntity.MIMETYPE, 3123 * RawContactsEntity.DATA1 3124 * }, null, null, null); 3125 * try { 3126 * while (c.moveToNext()) { 3127 * String sourceId = c.getString(0); 3128 * if (!c.isNull(1)) { 3129 * String mimeType = c.getString(2); 3130 * String data = c.getString(3); 3131 * ... 3132 * } 3133 * } 3134 * } finally { 3135 * c.close(); 3136 * } 3137 * </pre> 3138 * 3139 * <h3>Columns</h3> 3140 * RawContactsEntity has a combination of RawContact and Data columns. 3141 * 3142 * <table class="jd-sumtable"> 3143 * <tr> 3144 * <th colspan='4'>RawContacts</th> 3145 * </tr> 3146 * <tr> 3147 * <td style="width: 7em;">long</td> 3148 * <td style="width: 20em;">{@link #_ID}</td> 3149 * <td style="width: 5em;">read-only</td> 3150 * <td>Raw contact row ID. See {@link RawContacts}.</td> 3151 * </tr> 3152 * <tr> 3153 * <td>long</td> 3154 * <td>{@link #CONTACT_ID}</td> 3155 * <td>read-only</td> 3156 * <td>See {@link RawContacts}.</td> 3157 * </tr> 3158 * <tr> 3159 * <td>int</td> 3160 * <td>{@link #AGGREGATION_MODE}</td> 3161 * <td>read-only</td> 3162 * <td>See {@link RawContacts}.</td> 3163 * </tr> 3164 * <tr> 3165 * <td>int</td> 3166 * <td>{@link #DELETED}</td> 3167 * <td>read-only</td> 3168 * <td>See {@link RawContacts}.</td> 3169 * </tr> 3170 * </table> 3171 * 3172 * <table class="jd-sumtable"> 3173 * <tr> 3174 * <th colspan='4'>Data</th> 3175 * </tr> 3176 * <tr> 3177 * <td style="width: 7em;">long</td> 3178 * <td style="width: 20em;">{@link #DATA_ID}</td> 3179 * <td style="width: 5em;">read-only</td> 3180 * <td>Data row ID. It will be null if the raw contact has no data rows.</td> 3181 * </tr> 3182 * <tr> 3183 * <td>String</td> 3184 * <td>{@link #MIMETYPE}</td> 3185 * <td>read-only</td> 3186 * <td>See {@link ContactsContract.Data}.</td> 3187 * </tr> 3188 * <tr> 3189 * <td>int</td> 3190 * <td>{@link #IS_PRIMARY}</td> 3191 * <td>read-only</td> 3192 * <td>See {@link ContactsContract.Data}.</td> 3193 * </tr> 3194 * <tr> 3195 * <td>int</td> 3196 * <td>{@link #IS_SUPER_PRIMARY}</td> 3197 * <td>read-only</td> 3198 * <td>See {@link ContactsContract.Data}.</td> 3199 * </tr> 3200 * <tr> 3201 * <td>int</td> 3202 * <td>{@link #DATA_VERSION}</td> 3203 * <td>read-only</td> 3204 * <td>See {@link ContactsContract.Data}.</td> 3205 * </tr> 3206 * <tr> 3207 * <td>Any type</td> 3208 * <td> 3209 * {@link #DATA1}<br> 3210 * {@link #DATA2}<br> 3211 * {@link #DATA3}<br> 3212 * {@link #DATA4}<br> 3213 * {@link #DATA5}<br> 3214 * {@link #DATA6}<br> 3215 * {@link #DATA7}<br> 3216 * {@link #DATA8}<br> 3217 * {@link #DATA9}<br> 3218 * {@link #DATA10}<br> 3219 * {@link #DATA11}<br> 3220 * {@link #DATA12}<br> 3221 * {@link #DATA13}<br> 3222 * {@link #DATA14}<br> 3223 * {@link #DATA15} 3224 * </td> 3225 * <td>read-only</td> 3226 * <td>See {@link ContactsContract.Data}.</td> 3227 * </tr> 3228 * <tr> 3229 * <td>Any type</td> 3230 * <td> 3231 * {@link #SYNC1}<br> 3232 * {@link #SYNC2}<br> 3233 * {@link #SYNC3}<br> 3234 * {@link #SYNC4} 3235 * </td> 3236 * <td>read-only</td> 3237 * <td>See {@link ContactsContract.Data}.</td> 3238 * </tr> 3239 * </table> 3240 */ 3241 public final static class RawContactsEntity 3242 implements BaseColumns, DataColumns, RawContactsColumns { 3243 /** 3244 * This utility class cannot be instantiated 3245 */ 3246 private RawContactsEntity() {} 3247 3248 /** 3249 * The content:// style URI for this table 3250 */ 3251 public static final Uri CONTENT_URI = 3252 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); 3253 3254 /** 3255 * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. 3256 */ 3257 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; 3258 3259 /** 3260 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward 3261 * Data.CONTENT_URI contains only exportable data. 3262 * 3263 * This flag is useful (currently) only for vCard exporter in Contacts app, which 3264 * needs to exclude "un-exportable" data from available data to export, while 3265 * Contacts app itself has priviledge to access all data including "un-expotable" 3266 * ones and providers return all of them regardless of the callers' intention. 3267 * <P>Type: INTEGER</p> 3268 * 3269 * @hide Maybe available only in Eclair and not really ready for public use. 3270 * TODO: remove, or implement this feature completely. As of now (Eclair), 3271 * we only use this flag in queryEntities(), not query(). 3272 */ 3273 public static final String FOR_EXPORT_ONLY = "for_export_only"; 3274 3275 /** 3276 * The ID of the data column. The value will be null if this raw contact has no data rows. 3277 * <P>Type: INTEGER</P> 3278 */ 3279 public static final String DATA_ID = "data_id"; 3280 } 3281 3282 /** 3283 * @see PhoneLookup 3284 */ 3285 protected interface PhoneLookupColumns { 3286 /** 3287 * The phone number as the user entered it. 3288 * <P>Type: TEXT</P> 3289 */ 3290 public static final String NUMBER = "number"; 3291 3292 /** 3293 * The type of phone number, for example Home or Work. 3294 * <P>Type: INTEGER</P> 3295 */ 3296 public static final String TYPE = "type"; 3297 3298 /** 3299 * The user defined label for the phone number. 3300 * <P>Type: TEXT</P> 3301 */ 3302 public static final String LABEL = "label"; 3303 } 3304 3305 /** 3306 * A table that represents the result of looking up a phone number, for 3307 * example for caller ID. To perform a lookup you must append the number you 3308 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly 3309 * optimized. 3310 * <pre> 3311 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); 3312 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... 3313 * </pre> 3314 * 3315 * <h3>Columns</h3> 3316 * 3317 * <table class="jd-sumtable"> 3318 * <tr> 3319 * <th colspan='4'>PhoneLookup</th> 3320 * </tr> 3321 * <tr> 3322 * <td>long</td> 3323 * <td>{@link #_ID}</td> 3324 * <td>read-only</td> 3325 * <td>Data row ID.</td> 3326 * </tr> 3327 * <tr> 3328 * <td>String</td> 3329 * <td>{@link #NUMBER}</td> 3330 * <td>read-only</td> 3331 * <td>Phone number.</td> 3332 * </tr> 3333 * <tr> 3334 * <td>String</td> 3335 * <td>{@link #TYPE}</td> 3336 * <td>read-only</td> 3337 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> 3338 * </tr> 3339 * <tr> 3340 * <td>String</td> 3341 * <td>{@link #LABEL}</td> 3342 * <td>read-only</td> 3343 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> 3344 * </tr> 3345 * </table> 3346 * <p> 3347 * Columns from the Contacts table are also available through a join. 3348 * </p> 3349 * <table class="jd-sumtable"> 3350 * <tr> 3351 * <th colspan='4'>Join with {@link Contacts}</th> 3352 * </tr> 3353 * <tr> 3354 * <td>String</td> 3355 * <td>{@link #LOOKUP_KEY}</td> 3356 * <td>read-only</td> 3357 * <td>See {@link ContactsContract.Contacts}</td> 3358 * </tr> 3359 * <tr> 3360 * <td>String</td> 3361 * <td>{@link #DISPLAY_NAME}</td> 3362 * <td>read-only</td> 3363 * <td>See {@link ContactsContract.Contacts}</td> 3364 * </tr> 3365 * <tr> 3366 * <td>long</td> 3367 * <td>{@link #PHOTO_ID}</td> 3368 * <td>read-only</td> 3369 * <td>See {@link ContactsContract.Contacts}.</td> 3370 * </tr> 3371 * <tr> 3372 * <td>int</td> 3373 * <td>{@link #IN_VISIBLE_GROUP}</td> 3374 * <td>read-only</td> 3375 * <td>See {@link ContactsContract.Contacts}.</td> 3376 * </tr> 3377 * <tr> 3378 * <td>int</td> 3379 * <td>{@link #HAS_PHONE_NUMBER}</td> 3380 * <td>read-only</td> 3381 * <td>See {@link ContactsContract.Contacts}.</td> 3382 * </tr> 3383 * <tr> 3384 * <td>int</td> 3385 * <td>{@link #TIMES_CONTACTED}</td> 3386 * <td>read-only</td> 3387 * <td>See {@link ContactsContract.Contacts}.</td> 3388 * </tr> 3389 * <tr> 3390 * <td>long</td> 3391 * <td>{@link #LAST_TIME_CONTACTED}</td> 3392 * <td>read-only</td> 3393 * <td>See {@link ContactsContract.Contacts}.</td> 3394 * </tr> 3395 * <tr> 3396 * <td>int</td> 3397 * <td>{@link #STARRED}</td> 3398 * <td>read-only</td> 3399 * <td>See {@link ContactsContract.Contacts}.</td> 3400 * </tr> 3401 * <tr> 3402 * <td>String</td> 3403 * <td>{@link #CUSTOM_RINGTONE}</td> 3404 * <td>read-only</td> 3405 * <td>See {@link ContactsContract.Contacts}.</td> 3406 * </tr> 3407 * <tr> 3408 * <td>int</td> 3409 * <td>{@link #SEND_TO_VOICEMAIL}</td> 3410 * <td>read-only</td> 3411 * <td>See {@link ContactsContract.Contacts}.</td> 3412 * </tr> 3413 * </table> 3414 */ 3415 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, 3416 ContactsColumns, ContactOptionsColumns { 3417 /** 3418 * This utility class cannot be instantiated 3419 */ 3420 private PhoneLookup() {} 3421 3422 /** 3423 * The content:// style URI for this table. Append the phone number you want to lookup 3424 * to this URI and query it to perform a lookup. For example: 3425 * <pre> 3426 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, Uri.encode(phoneNumber)); 3427 * </pre> 3428 */ 3429 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, 3430 "phone_lookup"); 3431 3432 /** 3433 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. 3434 * 3435 * @hide 3436 */ 3437 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; 3438 } 3439 3440 /** 3441 * Additional data mixed in with {@link StatusColumns} to link 3442 * back to specific {@link ContactsContract.Data#_ID} entries. 3443 * 3444 * @see StatusUpdates 3445 */ 3446 protected interface PresenceColumns { 3447 3448 /** 3449 * Reference to the {@link Data#_ID} entry that owns this presence. 3450 * <P>Type: INTEGER</P> 3451 */ 3452 public static final String DATA_ID = "presence_data_id"; 3453 3454 /** 3455 * See {@link CommonDataKinds.Im} for a list of defined protocol constants. 3456 * <p>Type: NUMBER</p> 3457 */ 3458 public static final String PROTOCOL = "protocol"; 3459 3460 /** 3461 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 3462 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 3463 * omitted if {@link #PROTOCOL} value is not 3464 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. 3465 * 3466 * <p>Type: NUMBER</p> 3467 */ 3468 public static final String CUSTOM_PROTOCOL = "custom_protocol"; 3469 3470 /** 3471 * The IM handle the presence item is for. The handle is scoped to 3472 * {@link #PROTOCOL}. 3473 * <P>Type: TEXT</P> 3474 */ 3475 public static final String IM_HANDLE = "im_handle"; 3476 3477 /** 3478 * The IM account for the local user that the presence data came from. 3479 * <P>Type: TEXT</P> 3480 */ 3481 public static final String IM_ACCOUNT = "im_account"; 3482 } 3483 3484 /** 3485 * <p> 3486 * A status update is linked to a {@link ContactsContract.Data} row and captures 3487 * the user's latest status update via the corresponding source, e.g. 3488 * "Having lunch" via "Google Talk". 3489 * </p> 3490 * <p> 3491 * There are two ways a status update can be inserted: by explicitly linking 3492 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row 3493 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 3494 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use 3495 * either. 3496 * </p> 3497 * <p> 3498 * You cannot use {@link ContentResolver#update} to change a status, but 3499 * {@link ContentResolver#insert} will replace the latests status if it already 3500 * exists. 3501 * </p> 3502 * <p> 3503 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses 3504 * for multiple contacts at once. 3505 * </p> 3506 * 3507 * <h3>Columns</h3> 3508 * <table class="jd-sumtable"> 3509 * <tr> 3510 * <th colspan='4'>StatusUpdates</th> 3511 * </tr> 3512 * <tr> 3513 * <td>long</td> 3514 * <td>{@link #DATA_ID}</td> 3515 * <td>read/write</td> 3516 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this 3517 * field is <i>not</i> specified, the provider will attempt to find a data row 3518 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 3519 * {@link #IM_HANDLE} columns. 3520 * </td> 3521 * </tr> 3522 * <tr> 3523 * <td>long</td> 3524 * <td>{@link #PROTOCOL}</td> 3525 * <td>read/write</td> 3526 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> 3527 * </tr> 3528 * <tr> 3529 * <td>String</td> 3530 * <td>{@link #CUSTOM_PROTOCOL}</td> 3531 * <td>read/write</td> 3532 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 3533 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 3534 * omitted if {@link #PROTOCOL} value is not 3535 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> 3536 * </tr> 3537 * <tr> 3538 * <td>String</td> 3539 * <td>{@link #IM_HANDLE}</td> 3540 * <td>read/write</td> 3541 * <td> The IM handle the presence item is for. The handle is scoped to 3542 * {@link #PROTOCOL}.</td> 3543 * </tr> 3544 * <tr> 3545 * <td>String</td> 3546 * <td>{@link #IM_ACCOUNT}</td> 3547 * <td>read/write</td> 3548 * <td>The IM account for the local user that the presence data came from.</td> 3549 * </tr> 3550 * <tr> 3551 * <td>int</td> 3552 * <td>{@link #PRESENCE}</td> 3553 * <td>read/write</td> 3554 * <td>Contact IM presence status. The allowed values are: 3555 * <p> 3556 * <ul> 3557 * <li>{@link #OFFLINE}</li> 3558 * <li>{@link #INVISIBLE}</li> 3559 * <li>{@link #AWAY}</li> 3560 * <li>{@link #IDLE}</li> 3561 * <li>{@link #DO_NOT_DISTURB}</li> 3562 * <li>{@link #AVAILABLE}</li> 3563 * </ul> 3564 * </p> 3565 * <p> 3566 * Since presence status is inherently volatile, the content provider 3567 * may choose not to store this field in long-term storage. 3568 * </p> 3569 * </td> 3570 * </tr> 3571 * <tr> 3572 * <td>int</td> 3573 * <td>{@link #CHAT_CAPABILITY}</td> 3574 * <td>read/write</td> 3575 * <td>Contact IM chat compatibility value. The allowed values combinations of the following 3576 * flags. If None of these flags is set, the device can only do text messaging. 3577 * <p> 3578 * <ul> 3579 * <li>{@link #CAPABILITY_HAS_VIDEO}</li> 3580 * <li>{@link #CAPABILITY_HAS_VOICE}</li> 3581 * <li>{@link #CAPABILITY_HAS_CAMERA}</li> 3582 * </ul> 3583 * </p> 3584 * <p> 3585 * Since chat compatibility is inherently volatile as the contact's availability moves from 3586 * one device to another, the content provider may choose not to store this field in long-term 3587 * storage. 3588 * </p> 3589 * </td> 3590 * </tr> 3591 * <tr> 3592 * <td>String</td> 3593 * <td>{@link #STATUS}</td> 3594 * <td>read/write</td> 3595 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> 3596 * </tr> 3597 * <tr> 3598 * <td>long</td> 3599 * <td>{@link #STATUS_TIMESTAMP}</td> 3600 * <td>read/write</td> 3601 * <td>The absolute time in milliseconds when the status was 3602 * entered by the user. If this value is not provided, the provider will follow 3603 * this logic: if there was no prior status update, the value will be left as null. 3604 * If there was a prior status update, the provider will default this field 3605 * to the current time.</td> 3606 * </tr> 3607 * <tr> 3608 * <td>String</td> 3609 * <td>{@link #STATUS_RES_PACKAGE}</td> 3610 * <td>read/write</td> 3611 * <td> The package containing resources for this status: label and icon.</td> 3612 * </tr> 3613 * <tr> 3614 * <td>long</td> 3615 * <td>{@link #STATUS_LABEL}</td> 3616 * <td>read/write</td> 3617 * <td>The resource ID of the label describing the source of contact status, 3618 * e.g. "Google Talk". This resource is scoped by the 3619 * {@link #STATUS_RES_PACKAGE}.</td> 3620 * </tr> 3621 * <tr> 3622 * <td>long</td> 3623 * <td>{@link #STATUS_ICON}</td> 3624 * <td>read/write</td> 3625 * <td>The resource ID of the icon for the source of contact status. This 3626 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 3627 * </tr> 3628 * </table> 3629 */ 3630 public static class StatusUpdates implements StatusColumns, PresenceColumns { 3631 3632 /** 3633 * This utility class cannot be instantiated 3634 */ 3635 private StatusUpdates() {} 3636 3637 /** 3638 * The content:// style URI for this table 3639 */ 3640 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); 3641 3642 /** 3643 * Gets the resource ID for the proper presence icon. 3644 * 3645 * @param status the status to get the icon for 3646 * @return the resource ID for the proper presence icon 3647 */ 3648 public static final int getPresenceIconResourceId(int status) { 3649 switch (status) { 3650 case AVAILABLE: 3651 return android.R.drawable.presence_online; 3652 case IDLE: 3653 case AWAY: 3654 return android.R.drawable.presence_away; 3655 case DO_NOT_DISTURB: 3656 return android.R.drawable.presence_busy; 3657 case INVISIBLE: 3658 return android.R.drawable.presence_invisible; 3659 case OFFLINE: 3660 default: 3661 return android.R.drawable.presence_offline; 3662 } 3663 } 3664 3665 /** 3666 * Returns the precedence of the status code the higher number being the higher precedence. 3667 * 3668 * @param status The status code. 3669 * @return An integer representing the precedence, 0 being the lowest. 3670 */ 3671 public static final int getPresencePrecedence(int status) { 3672 // Keep this function here incase we want to enforce a different precedence than the 3673 // natural order of the status constants. 3674 return status; 3675 } 3676 3677 /** 3678 * The MIME type of {@link #CONTENT_URI} providing a directory of 3679 * status update details. 3680 */ 3681 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; 3682 3683 /** 3684 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 3685 * status update detail. 3686 */ 3687 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; 3688 } 3689 3690 /** 3691 * @deprecated This old name was never meant to be made public. Do not use. 3692 */ 3693 @Deprecated 3694 public static final class Presence extends StatusUpdates { 3695 3696 } 3697 3698 /** 3699 * Additional columns returned by the {@link Contacts#CONTENT_FILTER_URI} providing the 3700 * explanation of why the filter matched the contact. Specifically, they contain the 3701 * data type and element that was used for matching. 3702 * <p> 3703 * This is temporary API, it will need to change when we move to FTS. 3704 * 3705 * @hide 3706 */ 3707 public static class SearchSnippetColumns { 3708 3709 /** 3710 * The ID of the data row that was matched by the filter. 3711 * 3712 * @hide 3713 */ 3714 public static final String SNIPPET_DATA_ID = "snippet_data_id"; 3715 3716 /** 3717 * The type of data that was matched by the filter. 3718 * 3719 * @hide 3720 */ 3721 public static final String SNIPPET_MIMETYPE = "snippet_mimetype"; 3722 3723 /** 3724 * The {@link Data#DATA1} field of the data row that was matched by the filter. 3725 * 3726 * @hide 3727 */ 3728 public static final String SNIPPET_DATA1 = "snippet_data1"; 3729 3730 /** 3731 * The {@link Data#DATA2} field of the data row that was matched by the filter. 3732 * 3733 * @hide 3734 */ 3735 public static final String SNIPPET_DATA2 = "snippet_data2"; 3736 3737 /** 3738 * The {@link Data#DATA3} field of the data row that was matched by the filter. 3739 * 3740 * @hide 3741 */ 3742 public static final String SNIPPET_DATA3 = "snippet_data3"; 3743 3744 /** 3745 * The {@link Data#DATA4} field of the data row that was matched by the filter. 3746 * 3747 * @hide 3748 */ 3749 public static final String SNIPPET_DATA4 = "snippet_data4"; 3750 3751 } 3752 3753 /** 3754 * Container for definitions of common data types stored in the {@link ContactsContract.Data} 3755 * table. 3756 */ 3757 public static final class CommonDataKinds { 3758 /** 3759 * This utility class cannot be instantiated 3760 */ 3761 private CommonDataKinds() {} 3762 3763 /** 3764 * The {@link Data#RES_PACKAGE} value for common data that should be 3765 * shown using a default style. 3766 * 3767 * @hide RES_PACKAGE is hidden 3768 */ 3769 public static final String PACKAGE_COMMON = "common"; 3770 3771 /** 3772 * The base types that all "Typed" data kinds support. 3773 */ 3774 public interface BaseTypes { 3775 /** 3776 * A custom type. The custom label should be supplied by user. 3777 */ 3778 public static int TYPE_CUSTOM = 0; 3779 } 3780 3781 /** 3782 * Columns common across the specific types. 3783 */ 3784 protected interface CommonColumns extends BaseTypes { 3785 /** 3786 * The data for the contact method. 3787 * <P>Type: TEXT</P> 3788 */ 3789 public static final String DATA = DataColumns.DATA1; 3790 3791 /** 3792 * The type of data, for example Home or Work. 3793 * <P>Type: INTEGER</P> 3794 */ 3795 public static final String TYPE = DataColumns.DATA2; 3796 3797 /** 3798 * The user defined label for the the contact method. 3799 * <P>Type: TEXT</P> 3800 */ 3801 public static final String LABEL = DataColumns.DATA3; 3802 } 3803 3804 /** 3805 * A data kind representing the contact's proper name. You can use all 3806 * columns defined for {@link ContactsContract.Data} as well as the following aliases. 3807 * 3808 * <h2>Column aliases</h2> 3809 * <table class="jd-sumtable"> 3810 * <tr> 3811 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 3812 * </tr> 3813 * <tr> 3814 * <td>String</td> 3815 * <td>{@link #DISPLAY_NAME}</td> 3816 * <td>{@link #DATA1}</td> 3817 * <td></td> 3818 * </tr> 3819 * <tr> 3820 * <td>String</td> 3821 * <td>{@link #GIVEN_NAME}</td> 3822 * <td>{@link #DATA2}</td> 3823 * <td></td> 3824 * </tr> 3825 * <tr> 3826 * <td>String</td> 3827 * <td>{@link #FAMILY_NAME}</td> 3828 * <td>{@link #DATA3}</td> 3829 * <td></td> 3830 * </tr> 3831 * <tr> 3832 * <td>String</td> 3833 * <td>{@link #PREFIX}</td> 3834 * <td>{@link #DATA4}</td> 3835 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> 3836 * </tr> 3837 * <tr> 3838 * <td>String</td> 3839 * <td>{@link #MIDDLE_NAME}</td> 3840 * <td>{@link #DATA5}</td> 3841 * <td></td> 3842 * </tr> 3843 * <tr> 3844 * <td>String</td> 3845 * <td>{@link #SUFFIX}</td> 3846 * <td>{@link #DATA6}</td> 3847 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> 3848 * </tr> 3849 * <tr> 3850 * <td>String</td> 3851 * <td>{@link #PHONETIC_GIVEN_NAME}</td> 3852 * <td>{@link #DATA7}</td> 3853 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> 3854 * </tr> 3855 * <tr> 3856 * <td>String</td> 3857 * <td>{@link #PHONETIC_MIDDLE_NAME}</td> 3858 * <td>{@link #DATA8}</td> 3859 * <td></td> 3860 * </tr> 3861 * <tr> 3862 * <td>String</td> 3863 * <td>{@link #PHONETIC_FAMILY_NAME}</td> 3864 * <td>{@link #DATA9}</td> 3865 * <td></td> 3866 * </tr> 3867 * </table> 3868 */ 3869 public static final class StructuredName implements DataColumnsWithJoins { 3870 /** 3871 * This utility class cannot be instantiated 3872 */ 3873 private StructuredName() {} 3874 3875 /** MIME type used when storing this in data table. */ 3876 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; 3877 3878 /** 3879 * The name that should be used to display the contact. 3880 * <i>Unstructured component of the name should be consistent with 3881 * its structured representation.</i> 3882 * <p> 3883 * Type: TEXT 3884 */ 3885 public static final String DISPLAY_NAME = DATA1; 3886 3887 /** 3888 * The given name for the contact. 3889 * <P>Type: TEXT</P> 3890 */ 3891 public static final String GIVEN_NAME = DATA2; 3892 3893 /** 3894 * The family name for the contact. 3895 * <P>Type: TEXT</P> 3896 */ 3897 public static final String FAMILY_NAME = DATA3; 3898 3899 /** 3900 * The contact's honorific prefix, e.g. "Sir" 3901 * <P>Type: TEXT</P> 3902 */ 3903 public static final String PREFIX = DATA4; 3904 3905 /** 3906 * The contact's middle name 3907 * <P>Type: TEXT</P> 3908 */ 3909 public static final String MIDDLE_NAME = DATA5; 3910 3911 /** 3912 * The contact's honorific suffix, e.g. "Jr" 3913 */ 3914 public static final String SUFFIX = DATA6; 3915 3916 /** 3917 * The phonetic version of the given name for the contact. 3918 * <P>Type: TEXT</P> 3919 */ 3920 public static final String PHONETIC_GIVEN_NAME = DATA7; 3921 3922 /** 3923 * The phonetic version of the additional name for the contact. 3924 * <P>Type: TEXT</P> 3925 */ 3926 public static final String PHONETIC_MIDDLE_NAME = DATA8; 3927 3928 /** 3929 * The phonetic version of the family name for the contact. 3930 * <P>Type: TEXT</P> 3931 */ 3932 public static final String PHONETIC_FAMILY_NAME = DATA9; 3933 3934 /** 3935 * The style used for combining given/middle/family name into a full name. 3936 * See {@link ContactsContract.FullNameStyle}. 3937 * 3938 * @hide 3939 */ 3940 public static final String FULL_NAME_STYLE = DATA10; 3941 3942 /** 3943 * The alphabet used for capturing the phonetic name. 3944 * See ContactsContract.PhoneticNameStyle. 3945 * @hide 3946 */ 3947 public static final String PHONETIC_NAME_STYLE = DATA11; 3948 } 3949 3950 /** 3951 * <p>A data kind representing the contact's nickname. For example, for 3952 * Bob Parr ("Mr. Incredible"): 3953 * <pre> 3954 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 3955 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 3956 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 3957 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 3958 * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") 3959 * .build()); 3960 * 3961 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 3962 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 3963 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) 3964 * .withValue(Nickname.NAME, "Mr. Incredible") 3965 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) 3966 * .withValue(Nickname.LABEL, "Superhero") 3967 * .build()); 3968 * 3969 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 3970 * </pre> 3971 * </p> 3972 * <p> 3973 * You can use all columns defined for {@link ContactsContract.Data} as well as the 3974 * following aliases. 3975 * </p> 3976 * 3977 * <h2>Column aliases</h2> 3978 * <table class="jd-sumtable"> 3979 * <tr> 3980 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 3981 * </tr> 3982 * <tr> 3983 * <td>String</td> 3984 * <td>{@link #NAME}</td> 3985 * <td>{@link #DATA1}</td> 3986 * <td></td> 3987 * </tr> 3988 * <tr> 3989 * <td>int</td> 3990 * <td>{@link #TYPE}</td> 3991 * <td>{@link #DATA2}</td> 3992 * <td> 3993 * Allowed values are: 3994 * <p> 3995 * <ul> 3996 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3997 * <li>{@link #TYPE_DEFAULT}</li> 3998 * <li>{@link #TYPE_OTHER_NAME}</li> 3999 * <li>{@link #TYPE_MAINDEN_NAME}</li> 4000 * <li>{@link #TYPE_SHORT_NAME}</li> 4001 * <li>{@link #TYPE_INITIALS}</li> 4002 * </ul> 4003 * </p> 4004 * </td> 4005 * </tr> 4006 * <tr> 4007 * <td>String</td> 4008 * <td>{@link #LABEL}</td> 4009 * <td>{@link #DATA3}</td> 4010 * <td></td> 4011 * </tr> 4012 * </table> 4013 */ 4014 public static final class Nickname implements DataColumnsWithJoins, CommonColumns { 4015 /** 4016 * This utility class cannot be instantiated 4017 */ 4018 private Nickname() {} 4019 4020 /** MIME type used when storing this in data table. */ 4021 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; 4022 4023 public static final int TYPE_DEFAULT = 1; 4024 public static final int TYPE_OTHER_NAME = 2; 4025 public static final int TYPE_MAINDEN_NAME = 3; 4026 public static final int TYPE_SHORT_NAME = 4; 4027 public static final int TYPE_INITIALS = 5; 4028 4029 /** 4030 * The name itself 4031 */ 4032 public static final String NAME = DATA; 4033 } 4034 4035 /** 4036 * <p> 4037 * A data kind representing a telephone number. 4038 * </p> 4039 * <p> 4040 * You can use all columns defined for {@link ContactsContract.Data} as 4041 * well as the following aliases. 4042 * </p> 4043 * <h2>Column aliases</h2> 4044 * <table class="jd-sumtable"> 4045 * <tr> 4046 * <th>Type</th> 4047 * <th>Alias</th><th colspan='2'>Data column</th> 4048 * </tr> 4049 * <tr> 4050 * <td>String</td> 4051 * <td>{@link #NUMBER}</td> 4052 * <td>{@link #DATA1}</td> 4053 * <td></td> 4054 * </tr> 4055 * <tr> 4056 * <td>int</td> 4057 * <td>{@link #TYPE}</td> 4058 * <td>{@link #DATA2}</td> 4059 * <td>Allowed values are: 4060 * <p> 4061 * <ul> 4062 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4063 * <li>{@link #TYPE_HOME}</li> 4064 * <li>{@link #TYPE_MOBILE}</li> 4065 * <li>{@link #TYPE_WORK}</li> 4066 * <li>{@link #TYPE_FAX_WORK}</li> 4067 * <li>{@link #TYPE_FAX_HOME}</li> 4068 * <li>{@link #TYPE_PAGER}</li> 4069 * <li>{@link #TYPE_OTHER}</li> 4070 * <li>{@link #TYPE_CALLBACK}</li> 4071 * <li>{@link #TYPE_CAR}</li> 4072 * <li>{@link #TYPE_COMPANY_MAIN}</li> 4073 * <li>{@link #TYPE_ISDN}</li> 4074 * <li>{@link #TYPE_MAIN}</li> 4075 * <li>{@link #TYPE_OTHER_FAX}</li> 4076 * <li>{@link #TYPE_RADIO}</li> 4077 * <li>{@link #TYPE_TELEX}</li> 4078 * <li>{@link #TYPE_TTY_TDD}</li> 4079 * <li>{@link #TYPE_WORK_MOBILE}</li> 4080 * <li>{@link #TYPE_WORK_PAGER}</li> 4081 * <li>{@link #TYPE_ASSISTANT}</li> 4082 * <li>{@link #TYPE_MMS}</li> 4083 * </ul> 4084 * </p> 4085 * </td> 4086 * </tr> 4087 * <tr> 4088 * <td>String</td> 4089 * <td>{@link #LABEL}</td> 4090 * <td>{@link #DATA3}</td> 4091 * <td></td> 4092 * </tr> 4093 * </table> 4094 */ 4095 public static final class Phone implements DataColumnsWithJoins, CommonColumns { 4096 /** 4097 * This utility class cannot be instantiated 4098 */ 4099 private Phone() {} 4100 4101 /** MIME type used when storing this in data table. */ 4102 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2"; 4103 4104 /** 4105 * The MIME type of {@link #CONTENT_URI} providing a directory of 4106 * phones. 4107 */ 4108 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; 4109 4110 /** 4111 * The content:// style URI for all data records of the 4112 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 4113 * associated raw contact and aggregate contact data. 4114 */ 4115 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 4116 "phones"); 4117 4118 /** 4119 * The content:// style URL for phone lookup using a filter. The filter returns 4120 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 4121 * to display names as well as phone numbers. The filter argument should be passed 4122 * as an additional path segment after this URI. 4123 */ 4124 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 4125 "filter"); 4126 4127 public static final int TYPE_HOME = 1; 4128 public static final int TYPE_MOBILE = 2; 4129 public static final int TYPE_WORK = 3; 4130 public static final int TYPE_FAX_WORK = 4; 4131 public static final int TYPE_FAX_HOME = 5; 4132 public static final int TYPE_PAGER = 6; 4133 public static final int TYPE_OTHER = 7; 4134 public static final int TYPE_CALLBACK = 8; 4135 public static final int TYPE_CAR = 9; 4136 public static final int TYPE_COMPANY_MAIN = 10; 4137 public static final int TYPE_ISDN = 11; 4138 public static final int TYPE_MAIN = 12; 4139 public static final int TYPE_OTHER_FAX = 13; 4140 public static final int TYPE_RADIO = 14; 4141 public static final int TYPE_TELEX = 15; 4142 public static final int TYPE_TTY_TDD = 16; 4143 public static final int TYPE_WORK_MOBILE = 17; 4144 public static final int TYPE_WORK_PAGER = 18; 4145 public static final int TYPE_ASSISTANT = 19; 4146 public static final int TYPE_MMS = 20; 4147 4148 /** 4149 * The phone number as the user entered it. 4150 * <P>Type: TEXT</P> 4151 */ 4152 public static final String NUMBER = DATA; 4153 4154 /** 4155 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 4156 * @hide 4157 */ 4158 @Deprecated 4159 public static final CharSequence getDisplayLabel(Context context, int type, 4160 CharSequence label, CharSequence[] labelArray) { 4161 return getTypeLabel(context.getResources(), type, label); 4162 } 4163 4164 /** 4165 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 4166 * @hide 4167 */ 4168 @Deprecated 4169 public static final CharSequence getDisplayLabel(Context context, int type, 4170 CharSequence label) { 4171 return getTypeLabel(context.getResources(), type, label); 4172 } 4173 4174 /** 4175 * Return the string resource that best describes the given 4176 * {@link #TYPE}. Will always return a valid resource. 4177 */ 4178 public static final int getTypeLabelResource(int type) { 4179 switch (type) { 4180 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; 4181 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; 4182 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; 4183 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; 4184 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; 4185 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; 4186 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; 4187 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; 4188 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; 4189 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; 4190 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; 4191 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; 4192 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; 4193 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; 4194 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; 4195 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; 4196 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; 4197 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; 4198 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; 4199 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; 4200 default: return com.android.internal.R.string.phoneTypeCustom; 4201 } 4202 } 4203 4204 /** 4205 * Return a {@link CharSequence} that best describes the given type, 4206 * possibly substituting the given {@link #LABEL} value 4207 * for {@link #TYPE_CUSTOM}. 4208 */ 4209 public static final CharSequence getTypeLabel(Resources res, int type, 4210 CharSequence label) { 4211 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { 4212 return label; 4213 } else { 4214 final int labelRes = getTypeLabelResource(type); 4215 return res.getText(labelRes); 4216 } 4217 } 4218 } 4219 4220 /** 4221 * <p> 4222 * A data kind representing an email address. 4223 * </p> 4224 * <p> 4225 * You can use all columns defined for {@link ContactsContract.Data} as 4226 * well as the following aliases. 4227 * </p> 4228 * <h2>Column aliases</h2> 4229 * <table class="jd-sumtable"> 4230 * <tr> 4231 * <th>Type</th> 4232 * <th>Alias</th><th colspan='2'>Data column</th> 4233 * </tr> 4234 * <tr> 4235 * <td>String</td> 4236 * <td>{@link #DATA}</td> 4237 * <td>{@link #DATA1}</td> 4238 * <td>Email address itself.</td> 4239 * </tr> 4240 * <tr> 4241 * <td>int</td> 4242 * <td>{@link #TYPE}</td> 4243 * <td>{@link #DATA2}</td> 4244 * <td>Allowed values are: 4245 * <p> 4246 * <ul> 4247 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4248 * <li>{@link #TYPE_HOME}</li> 4249 * <li>{@link #TYPE_WORK}</li> 4250 * <li>{@link #TYPE_OTHER}</li> 4251 * <li>{@link #TYPE_MOBILE}</li> 4252 * </ul> 4253 * </p> 4254 * </td> 4255 * </tr> 4256 * <tr> 4257 * <td>String</td> 4258 * <td>{@link #LABEL}</td> 4259 * <td>{@link #DATA3}</td> 4260 * <td></td> 4261 * </tr> 4262 * </table> 4263 */ 4264 public static final class Email implements DataColumnsWithJoins, CommonColumns { 4265 /** 4266 * This utility class cannot be instantiated 4267 */ 4268 private Email() {} 4269 4270 /** MIME type used when storing this in data table. */ 4271 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2"; 4272 4273 /** 4274 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. 4275 */ 4276 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; 4277 4278 /** 4279 * The content:// style URI for all data records of the 4280 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 4281 * associated raw contact and aggregate contact data. 4282 */ 4283 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 4284 "emails"); 4285 4286 /** 4287 * <p> 4288 * The content:// style URL for looking up data rows by email address. The 4289 * lookup argument, an email address, should be passed as an additional path segment 4290 * after this URI. 4291 * </p> 4292 * <p>Example: 4293 * <pre> 4294 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); 4295 * Cursor c = getContentResolver().query(uri, 4296 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, 4297 * null, null, null); 4298 * </pre> 4299 * </p> 4300 */ 4301 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, 4302 "lookup"); 4303 4304 /** 4305 * <p> 4306 * The content:// style URL for email lookup using a filter. The filter returns 4307 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 4308 * to display names as well as email addresses. The filter argument should be passed 4309 * as an additional path segment after this URI. 4310 * </p> 4311 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" 4312 * as well as "Bob Parr (incredible@android.com)". 4313 * <pre> 4314 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); 4315 * Cursor c = getContentResolver().query(uri, 4316 * new String[]{Email.DISPLAY_NAME, Email.DATA}, 4317 * null, null, null); 4318 * </pre> 4319 * </p> 4320 */ 4321 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 4322 "filter"); 4323 4324 /** 4325 * The email address. 4326 * <P>Type: TEXT</P> 4327 */ 4328 public static final String ADDRESS = DATA1; 4329 4330 public static final int TYPE_HOME = 1; 4331 public static final int TYPE_WORK = 2; 4332 public static final int TYPE_OTHER = 3; 4333 public static final int TYPE_MOBILE = 4; 4334 4335 /** 4336 * The display name for the email address 4337 * <P>Type: TEXT</P> 4338 */ 4339 public static final String DISPLAY_NAME = DATA4; 4340 4341 /** 4342 * Return the string resource that best describes the given 4343 * {@link #TYPE}. Will always return a valid resource. 4344 */ 4345 public static final int getTypeLabelResource(int type) { 4346 switch (type) { 4347 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; 4348 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; 4349 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; 4350 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; 4351 default: return com.android.internal.R.string.emailTypeCustom; 4352 } 4353 } 4354 4355 /** 4356 * Return a {@link CharSequence} that best describes the given type, 4357 * possibly substituting the given {@link #LABEL} value 4358 * for {@link #TYPE_CUSTOM}. 4359 */ 4360 public static final CharSequence getTypeLabel(Resources res, int type, 4361 CharSequence label) { 4362 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 4363 return label; 4364 } else { 4365 final int labelRes = getTypeLabelResource(type); 4366 return res.getText(labelRes); 4367 } 4368 } 4369 } 4370 4371 /** 4372 * <p> 4373 * A data kind representing a postal addresses. 4374 * </p> 4375 * <p> 4376 * You can use all columns defined for {@link ContactsContract.Data} as 4377 * well as the following aliases. 4378 * </p> 4379 * <h2>Column aliases</h2> 4380 * <table class="jd-sumtable"> 4381 * <tr> 4382 * <th>Type</th> 4383 * <th>Alias</th><th colspan='2'>Data column</th> 4384 * </tr> 4385 * <tr> 4386 * <td>String</td> 4387 * <td>{@link #FORMATTED_ADDRESS}</td> 4388 * <td>{@link #DATA1}</td> 4389 * <td></td> 4390 * </tr> 4391 * <tr> 4392 * <td>int</td> 4393 * <td>{@link #TYPE}</td> 4394 * <td>{@link #DATA2}</td> 4395 * <td>Allowed values are: 4396 * <p> 4397 * <ul> 4398 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4399 * <li>{@link #TYPE_HOME}</li> 4400 * <li>{@link #TYPE_WORK}</li> 4401 * <li>{@link #TYPE_OTHER}</li> 4402 * </ul> 4403 * </p> 4404 * </td> 4405 * </tr> 4406 * <tr> 4407 * <td>String</td> 4408 * <td>{@link #LABEL}</td> 4409 * <td>{@link #DATA3}</td> 4410 * <td></td> 4411 * </tr> 4412 * <tr> 4413 * <td>String</td> 4414 * <td>{@link #STREET}</td> 4415 * <td>{@link #DATA4}</td> 4416 * <td></td> 4417 * </tr> 4418 * <tr> 4419 * <td>String</td> 4420 * <td>{@link #POBOX}</td> 4421 * <td>{@link #DATA5}</td> 4422 * <td>Post Office Box number</td> 4423 * </tr> 4424 * <tr> 4425 * <td>String</td> 4426 * <td>{@link #NEIGHBORHOOD}</td> 4427 * <td>{@link #DATA6}</td> 4428 * <td></td> 4429 * </tr> 4430 * <tr> 4431 * <td>String</td> 4432 * <td>{@link #CITY}</td> 4433 * <td>{@link #DATA7}</td> 4434 * <td></td> 4435 * </tr> 4436 * <tr> 4437 * <td>String</td> 4438 * <td>{@link #REGION}</td> 4439 * <td>{@link #DATA8}</td> 4440 * <td></td> 4441 * </tr> 4442 * <tr> 4443 * <td>String</td> 4444 * <td>{@link #POSTCODE}</td> 4445 * <td>{@link #DATA9}</td> 4446 * <td></td> 4447 * </tr> 4448 * <tr> 4449 * <td>String</td> 4450 * <td>{@link #COUNTRY}</td> 4451 * <td>{@link #DATA10}</td> 4452 * <td></td> 4453 * </tr> 4454 * </table> 4455 */ 4456 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns { 4457 /** 4458 * This utility class cannot be instantiated 4459 */ 4460 private StructuredPostal() { 4461 } 4462 4463 /** MIME type used when storing this in data table. */ 4464 public static final String CONTENT_ITEM_TYPE = 4465 "vnd.android.cursor.item/postal-address_v2"; 4466 4467 /** 4468 * The MIME type of {@link #CONTENT_URI} providing a directory of 4469 * postal addresses. 4470 */ 4471 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2"; 4472 4473 /** 4474 * The content:// style URI for all data records of the 4475 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. 4476 */ 4477 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 4478 "postals"); 4479 4480 public static final int TYPE_HOME = 1; 4481 public static final int TYPE_WORK = 2; 4482 public static final int TYPE_OTHER = 3; 4483 4484 /** 4485 * The full, unstructured postal address. <i>This field must be 4486 * consistent with any structured data.</i> 4487 * <p> 4488 * Type: TEXT 4489 */ 4490 public static final String FORMATTED_ADDRESS = DATA; 4491 4492 /** 4493 * Can be street, avenue, road, etc. This element also includes the 4494 * house number and room/apartment/flat/floor number. 4495 * <p> 4496 * Type: TEXT 4497 */ 4498 public static final String STREET = DATA4; 4499 4500 /** 4501 * Covers actual P.O. boxes, drawers, locked bags, etc. This is 4502 * usually but not always mutually exclusive with street. 4503 * <p> 4504 * Type: TEXT 4505 */ 4506 public static final String POBOX = DATA5; 4507 4508 /** 4509 * This is used to disambiguate a street address when a city 4510 * contains more than one street with the same name, or to specify a 4511 * small place whose mail is routed through a larger postal town. In 4512 * China it could be a county or a minor city. 4513 * <p> 4514 * Type: TEXT 4515 */ 4516 public static final String NEIGHBORHOOD = DATA6; 4517 4518 /** 4519 * Can be city, village, town, borough, etc. This is the postal town 4520 * and not necessarily the place of residence or place of business. 4521 * <p> 4522 * Type: TEXT 4523 */ 4524 public static final String CITY = DATA7; 4525 4526 /** 4527 * A state, province, county (in Ireland), Land (in Germany), 4528 * departement (in France), etc. 4529 * <p> 4530 * Type: TEXT 4531 */ 4532 public static final String REGION = DATA8; 4533 4534 /** 4535 * Postal code. Usually country-wide, but sometimes specific to the 4536 * city (e.g. "2" in "Dublin 2, Ireland" addresses). 4537 * <p> 4538 * Type: TEXT 4539 */ 4540 public static final String POSTCODE = DATA9; 4541 4542 /** 4543 * The name or code of the country. 4544 * <p> 4545 * Type: TEXT 4546 */ 4547 public static final String COUNTRY = DATA10; 4548 4549 /** 4550 * Return the string resource that best describes the given 4551 * {@link #TYPE}. Will always return a valid resource. 4552 */ 4553 public static final int getTypeLabelResource(int type) { 4554 switch (type) { 4555 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; 4556 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; 4557 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; 4558 default: return com.android.internal.R.string.postalTypeCustom; 4559 } 4560 } 4561 4562 /** 4563 * Return a {@link CharSequence} that best describes the given type, 4564 * possibly substituting the given {@link #LABEL} value 4565 * for {@link #TYPE_CUSTOM}. 4566 */ 4567 public static final CharSequence getTypeLabel(Resources res, int type, 4568 CharSequence label) { 4569 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 4570 return label; 4571 } else { 4572 final int labelRes = getTypeLabelResource(type); 4573 return res.getText(labelRes); 4574 } 4575 } 4576 } 4577 4578 /** 4579 * <p> 4580 * A data kind representing an IM address 4581 * </p> 4582 * <p> 4583 * You can use all columns defined for {@link ContactsContract.Data} as 4584 * well as the following aliases. 4585 * </p> 4586 * <h2>Column aliases</h2> 4587 * <table class="jd-sumtable"> 4588 * <tr> 4589 * <th>Type</th> 4590 * <th>Alias</th><th colspan='2'>Data column</th> 4591 * </tr> 4592 * <tr> 4593 * <td>String</td> 4594 * <td>{@link #DATA}</td> 4595 * <td>{@link #DATA1}</td> 4596 * <td></td> 4597 * </tr> 4598 * <tr> 4599 * <td>int</td> 4600 * <td>{@link #TYPE}</td> 4601 * <td>{@link #DATA2}</td> 4602 * <td>Allowed values are: 4603 * <p> 4604 * <ul> 4605 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4606 * <li>{@link #TYPE_HOME}</li> 4607 * <li>{@link #TYPE_WORK}</li> 4608 * <li>{@link #TYPE_OTHER}</li> 4609 * </ul> 4610 * </p> 4611 * </td> 4612 * </tr> 4613 * <tr> 4614 * <td>String</td> 4615 * <td>{@link #LABEL}</td> 4616 * <td>{@link #DATA3}</td> 4617 * <td></td> 4618 * </tr> 4619 * <tr> 4620 * <td>String</td> 4621 * <td>{@link #PROTOCOL}</td> 4622 * <td>{@link #DATA5}</td> 4623 * <td> 4624 * <p> 4625 * Allowed values: 4626 * <ul> 4627 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name 4628 * as {@link #CUSTOM_PROTOCOL}.</li> 4629 * <li>{@link #PROTOCOL_AIM}</li> 4630 * <li>{@link #PROTOCOL_MSN}</li> 4631 * <li>{@link #PROTOCOL_YAHOO}</li> 4632 * <li>{@link #PROTOCOL_SKYPE}</li> 4633 * <li>{@link #PROTOCOL_QQ}</li> 4634 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> 4635 * <li>{@link #PROTOCOL_ICQ}</li> 4636 * <li>{@link #PROTOCOL_JABBER}</li> 4637 * <li>{@link #PROTOCOL_NETMEETING}</li> 4638 * </ul> 4639 * </p> 4640 * </td> 4641 * </tr> 4642 * <tr> 4643 * <td>String</td> 4644 * <td>{@link #CUSTOM_PROTOCOL}</td> 4645 * <td>{@link #DATA6}</td> 4646 * <td></td> 4647 * </tr> 4648 * </table> 4649 */ 4650 public static final class Im implements DataColumnsWithJoins, CommonColumns { 4651 /** 4652 * This utility class cannot be instantiated 4653 */ 4654 private Im() {} 4655 4656 /** MIME type used when storing this in data table. */ 4657 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; 4658 4659 public static final int TYPE_HOME = 1; 4660 public static final int TYPE_WORK = 2; 4661 public static final int TYPE_OTHER = 3; 4662 4663 /** 4664 * This column should be populated with one of the defined 4665 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this 4666 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} 4667 * should contain the name of the custom protocol. 4668 */ 4669 public static final String PROTOCOL = DATA5; 4670 4671 public static final String CUSTOM_PROTOCOL = DATA6; 4672 4673 /* 4674 * The predefined IM protocol types. 4675 */ 4676 public static final int PROTOCOL_CUSTOM = -1; 4677 public static final int PROTOCOL_AIM = 0; 4678 public static final int PROTOCOL_MSN = 1; 4679 public static final int PROTOCOL_YAHOO = 2; 4680 public static final int PROTOCOL_SKYPE = 3; 4681 public static final int PROTOCOL_QQ = 4; 4682 public static final int PROTOCOL_GOOGLE_TALK = 5; 4683 public static final int PROTOCOL_ICQ = 6; 4684 public static final int PROTOCOL_JABBER = 7; 4685 public static final int PROTOCOL_NETMEETING = 8; 4686 4687 /** 4688 * Return the string resource that best describes the given 4689 * {@link #TYPE}. Will always return a valid resource. 4690 */ 4691 public static final int getTypeLabelResource(int type) { 4692 switch (type) { 4693 case TYPE_HOME: return com.android.internal.R.string.imTypeHome; 4694 case TYPE_WORK: return com.android.internal.R.string.imTypeWork; 4695 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; 4696 default: return com.android.internal.R.string.imTypeCustom; 4697 } 4698 } 4699 4700 /** 4701 * Return a {@link CharSequence} that best describes the given type, 4702 * possibly substituting the given {@link #LABEL} value 4703 * for {@link #TYPE_CUSTOM}. 4704 */ 4705 public static final CharSequence getTypeLabel(Resources res, int type, 4706 CharSequence label) { 4707 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 4708 return label; 4709 } else { 4710 final int labelRes = getTypeLabelResource(type); 4711 return res.getText(labelRes); 4712 } 4713 } 4714 4715 /** 4716 * Return the string resource that best describes the given 4717 * {@link #PROTOCOL}. Will always return a valid resource. 4718 */ 4719 public static final int getProtocolLabelResource(int type) { 4720 switch (type) { 4721 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; 4722 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; 4723 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; 4724 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; 4725 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; 4726 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; 4727 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; 4728 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; 4729 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; 4730 default: return com.android.internal.R.string.imProtocolCustom; 4731 } 4732 } 4733 4734 /** 4735 * Return a {@link CharSequence} that best describes the given 4736 * protocol, possibly substituting the given 4737 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. 4738 */ 4739 public static final CharSequence getProtocolLabel(Resources res, int type, 4740 CharSequence label) { 4741 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { 4742 return label; 4743 } else { 4744 final int labelRes = getProtocolLabelResource(type); 4745 return res.getText(labelRes); 4746 } 4747 } 4748 } 4749 4750 /** 4751 * <p> 4752 * A data kind representing an organization. 4753 * </p> 4754 * <p> 4755 * You can use all columns defined for {@link ContactsContract.Data} as 4756 * well as the following aliases. 4757 * </p> 4758 * <h2>Column aliases</h2> 4759 * <table class="jd-sumtable"> 4760 * <tr> 4761 * <th>Type</th> 4762 * <th>Alias</th><th colspan='2'>Data column</th> 4763 * </tr> 4764 * <tr> 4765 * <td>String</td> 4766 * <td>{@link #COMPANY}</td> 4767 * <td>{@link #DATA1}</td> 4768 * <td></td> 4769 * </tr> 4770 * <tr> 4771 * <td>int</td> 4772 * <td>{@link #TYPE}</td> 4773 * <td>{@link #DATA2}</td> 4774 * <td>Allowed values are: 4775 * <p> 4776 * <ul> 4777 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4778 * <li>{@link #TYPE_WORK}</li> 4779 * <li>{@link #TYPE_OTHER}</li> 4780 * </ul> 4781 * </p> 4782 * </td> 4783 * </tr> 4784 * <tr> 4785 * <td>String</td> 4786 * <td>{@link #LABEL}</td> 4787 * <td>{@link #DATA3}</td> 4788 * <td></td> 4789 * </tr> 4790 * <tr> 4791 * <td>String</td> 4792 * <td>{@link #TITLE}</td> 4793 * <td>{@link #DATA4}</td> 4794 * <td></td> 4795 * </tr> 4796 * <tr> 4797 * <td>String</td> 4798 * <td>{@link #DEPARTMENT}</td> 4799 * <td>{@link #DATA5}</td> 4800 * <td></td> 4801 * </tr> 4802 * <tr> 4803 * <td>String</td> 4804 * <td>{@link #JOB_DESCRIPTION}</td> 4805 * <td>{@link #DATA6}</td> 4806 * <td></td> 4807 * </tr> 4808 * <tr> 4809 * <td>String</td> 4810 * <td>{@link #SYMBOL}</td> 4811 * <td>{@link #DATA7}</td> 4812 * <td></td> 4813 * </tr> 4814 * <tr> 4815 * <td>String</td> 4816 * <td>{@link #PHONETIC_NAME}</td> 4817 * <td>{@link #DATA8}</td> 4818 * <td></td> 4819 * </tr> 4820 * <tr> 4821 * <td>String</td> 4822 * <td>{@link #OFFICE_LOCATION}</td> 4823 * <td>{@link #DATA9}</td> 4824 * <td></td> 4825 * </tr> 4826 * <tr> 4827 * <td>String</td> 4828 * <td>PHONETIC_NAME_STYLE</td> 4829 * <td>{@link #DATA10}</td> 4830 * <td></td> 4831 * </tr> 4832 * </table> 4833 */ 4834 public static final class Organization implements DataColumnsWithJoins, CommonColumns { 4835 /** 4836 * This utility class cannot be instantiated 4837 */ 4838 private Organization() {} 4839 4840 /** MIME type used when storing this in data table. */ 4841 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; 4842 4843 public static final int TYPE_WORK = 1; 4844 public static final int TYPE_OTHER = 2; 4845 4846 /** 4847 * The company as the user entered it. 4848 * <P>Type: TEXT</P> 4849 */ 4850 public static final String COMPANY = DATA; 4851 4852 /** 4853 * The position title at this company as the user entered it. 4854 * <P>Type: TEXT</P> 4855 */ 4856 public static final String TITLE = DATA4; 4857 4858 /** 4859 * The department at this company as the user entered it. 4860 * <P>Type: TEXT</P> 4861 */ 4862 public static final String DEPARTMENT = DATA5; 4863 4864 /** 4865 * The job description at this company as the user entered it. 4866 * <P>Type: TEXT</P> 4867 */ 4868 public static final String JOB_DESCRIPTION = DATA6; 4869 4870 /** 4871 * The symbol of this company as the user entered it. 4872 * <P>Type: TEXT</P> 4873 */ 4874 public static final String SYMBOL = DATA7; 4875 4876 /** 4877 * The phonetic name of this company as the user entered it. 4878 * <P>Type: TEXT</P> 4879 */ 4880 public static final String PHONETIC_NAME = DATA8; 4881 4882 /** 4883 * The office location of this organization. 4884 * <P>Type: TEXT</P> 4885 */ 4886 public static final String OFFICE_LOCATION = DATA9; 4887 4888 /** 4889 * The alphabet used for capturing the phonetic name. 4890 * See {@link ContactsContract.PhoneticNameStyle}. 4891 * @hide 4892 */ 4893 public static final String PHONETIC_NAME_STYLE = DATA10; 4894 4895 /** 4896 * Return the string resource that best describes the given 4897 * {@link #TYPE}. Will always return a valid resource. 4898 */ 4899 public static final int getTypeLabelResource(int type) { 4900 switch (type) { 4901 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; 4902 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; 4903 default: return com.android.internal.R.string.orgTypeCustom; 4904 } 4905 } 4906 4907 /** 4908 * Return a {@link CharSequence} that best describes the given type, 4909 * possibly substituting the given {@link #LABEL} value 4910 * for {@link #TYPE_CUSTOM}. 4911 */ 4912 public static final CharSequence getTypeLabel(Resources res, int type, 4913 CharSequence label) { 4914 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 4915 return label; 4916 } else { 4917 final int labelRes = getTypeLabelResource(type); 4918 return res.getText(labelRes); 4919 } 4920 } 4921 } 4922 4923 /** 4924 * <p> 4925 * A data kind representing a relation. 4926 * </p> 4927 * <p> 4928 * You can use all columns defined for {@link ContactsContract.Data} as 4929 * well as the following aliases. 4930 * </p> 4931 * <h2>Column aliases</h2> 4932 * <table class="jd-sumtable"> 4933 * <tr> 4934 * <th>Type</th> 4935 * <th>Alias</th><th colspan='2'>Data column</th> 4936 * </tr> 4937 * <tr> 4938 * <td>String</td> 4939 * <td>{@link #NAME}</td> 4940 * <td>{@link #DATA1}</td> 4941 * <td></td> 4942 * </tr> 4943 * <tr> 4944 * <td>int</td> 4945 * <td>{@link #TYPE}</td> 4946 * <td>{@link #DATA2}</td> 4947 * <td>Allowed values are: 4948 * <p> 4949 * <ul> 4950 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4951 * <li>{@link #TYPE_ASSISTANT}</li> 4952 * <li>{@link #TYPE_BROTHER}</li> 4953 * <li>{@link #TYPE_CHILD}</li> 4954 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> 4955 * <li>{@link #TYPE_FATHER}</li> 4956 * <li>{@link #TYPE_FRIEND}</li> 4957 * <li>{@link #TYPE_MANAGER}</li> 4958 * <li>{@link #TYPE_MOTHER}</li> 4959 * <li>{@link #TYPE_PARENT}</li> 4960 * <li>{@link #TYPE_PARTNER}</li> 4961 * <li>{@link #TYPE_REFERRED_BY}</li> 4962 * <li>{@link #TYPE_RELATIVE}</li> 4963 * <li>{@link #TYPE_SISTER}</li> 4964 * <li>{@link #TYPE_SPOUSE}</li> 4965 * </ul> 4966 * </p> 4967 * </td> 4968 * </tr> 4969 * <tr> 4970 * <td>String</td> 4971 * <td>{@link #LABEL}</td> 4972 * <td>{@link #DATA3}</td> 4973 * <td></td> 4974 * </tr> 4975 * </table> 4976 */ 4977 public static final class Relation implements DataColumnsWithJoins, CommonColumns { 4978 /** 4979 * This utility class cannot be instantiated 4980 */ 4981 private Relation() {} 4982 4983 /** MIME type used when storing this in data table. */ 4984 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; 4985 4986 public static final int TYPE_ASSISTANT = 1; 4987 public static final int TYPE_BROTHER = 2; 4988 public static final int TYPE_CHILD = 3; 4989 public static final int TYPE_DOMESTIC_PARTNER = 4; 4990 public static final int TYPE_FATHER = 5; 4991 public static final int TYPE_FRIEND = 6; 4992 public static final int TYPE_MANAGER = 7; 4993 public static final int TYPE_MOTHER = 8; 4994 public static final int TYPE_PARENT = 9; 4995 public static final int TYPE_PARTNER = 10; 4996 public static final int TYPE_REFERRED_BY = 11; 4997 public static final int TYPE_RELATIVE = 12; 4998 public static final int TYPE_SISTER = 13; 4999 public static final int TYPE_SPOUSE = 14; 5000 5001 /** 5002 * The name of the relative as the user entered it. 5003 * <P>Type: TEXT</P> 5004 */ 5005 public static final String NAME = DATA; 5006 } 5007 5008 /** 5009 * <p> 5010 * A data kind representing an event. 5011 * </p> 5012 * <p> 5013 * You can use all columns defined for {@link ContactsContract.Data} as 5014 * well as the following aliases. 5015 * </p> 5016 * <h2>Column aliases</h2> 5017 * <table class="jd-sumtable"> 5018 * <tr> 5019 * <th>Type</th> 5020 * <th>Alias</th><th colspan='2'>Data column</th> 5021 * </tr> 5022 * <tr> 5023 * <td>String</td> 5024 * <td>{@link #START_DATE}</td> 5025 * <td>{@link #DATA1}</td> 5026 * <td></td> 5027 * </tr> 5028 * <tr> 5029 * <td>int</td> 5030 * <td>{@link #TYPE}</td> 5031 * <td>{@link #DATA2}</td> 5032 * <td>Allowed values are: 5033 * <p> 5034 * <ul> 5035 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 5036 * <li>{@link #TYPE_ANNIVERSARY}</li> 5037 * <li>{@link #TYPE_OTHER}</li> 5038 * <li>{@link #TYPE_BIRTHDAY}</li> 5039 * </ul> 5040 * </p> 5041 * </td> 5042 * </tr> 5043 * <tr> 5044 * <td>String</td> 5045 * <td>{@link #LABEL}</td> 5046 * <td>{@link #DATA3}</td> 5047 * <td></td> 5048 * </tr> 5049 * </table> 5050 */ 5051 public static final class Event implements DataColumnsWithJoins, CommonColumns { 5052 /** 5053 * This utility class cannot be instantiated 5054 */ 5055 private Event() {} 5056 5057 /** MIME type used when storing this in data table. */ 5058 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event"; 5059 5060 public static final int TYPE_ANNIVERSARY = 1; 5061 public static final int TYPE_OTHER = 2; 5062 public static final int TYPE_BIRTHDAY = 3; 5063 5064 /** 5065 * The event start date as the user entered it. 5066 * <P>Type: TEXT</P> 5067 */ 5068 public static final String START_DATE = DATA; 5069 5070 /** 5071 * Return the string resource that best describes the given 5072 * {@link #TYPE}. Will always return a valid resource. 5073 */ 5074 public static int getTypeResource(Integer type) { 5075 if (type == null) { 5076 return com.android.internal.R.string.eventTypeOther; 5077 } 5078 switch (type) { 5079 case TYPE_ANNIVERSARY: 5080 return com.android.internal.R.string.eventTypeAnniversary; 5081 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; 5082 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; 5083 default: return com.android.internal.R.string.eventTypeOther; 5084 } 5085 } 5086 } 5087 5088 /** 5089 * <p> 5090 * A data kind representing an photo for the contact. 5091 * </p> 5092 * <p> 5093 * Some sync adapters will choose to download photos in a separate 5094 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} 5095 * through {@link ContactsContract.Data#SYNC4} to store temporary 5096 * data, e.g. the image URL or ID, state of download, server-side version 5097 * of the image. It is allowed for the {@link #PHOTO} to be null. 5098 * </p> 5099 * <p> 5100 * You can use all columns defined for {@link ContactsContract.Data} as 5101 * well as the following aliases. 5102 * </p> 5103 * <h2>Column aliases</h2> 5104 * <table class="jd-sumtable"> 5105 * <tr> 5106 * <th>Type</th> 5107 * <th>Alias</th><th colspan='2'>Data column</th> 5108 * </tr> 5109 * <tr> 5110 * <td>BLOB</td> 5111 * <td>{@link #PHOTO}</td> 5112 * <td>{@link #DATA15}</td> 5113 * <td>By convention, binary data is stored in DATA15.</td> 5114 * </tr> 5115 * </table> 5116 */ 5117 public static final class Photo implements DataColumnsWithJoins { 5118 /** 5119 * This utility class cannot be instantiated 5120 */ 5121 private Photo() {} 5122 5123 /** MIME type used when storing this in data table. */ 5124 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; 5125 5126 /** 5127 * Thumbnail photo of the raw contact. This is the raw bytes of an image 5128 * that could be inflated using {@link android.graphics.BitmapFactory}. 5129 * <p> 5130 * Type: BLOB 5131 */ 5132 public static final String PHOTO = DATA15; 5133 } 5134 5135 /** 5136 * <p> 5137 * Notes about the contact. 5138 * </p> 5139 * <p> 5140 * You can use all columns defined for {@link ContactsContract.Data} as 5141 * well as the following aliases. 5142 * </p> 5143 * <h2>Column aliases</h2> 5144 * <table class="jd-sumtable"> 5145 * <tr> 5146 * <th>Type</th> 5147 * <th>Alias</th><th colspan='2'>Data column</th> 5148 * </tr> 5149 * <tr> 5150 * <td>String</td> 5151 * <td>{@link #NOTE}</td> 5152 * <td>{@link #DATA1}</td> 5153 * <td></td> 5154 * </tr> 5155 * </table> 5156 */ 5157 public static final class Note implements DataColumnsWithJoins { 5158 /** 5159 * This utility class cannot be instantiated 5160 */ 5161 private Note() {} 5162 5163 /** MIME type used when storing this in data table. */ 5164 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; 5165 5166 /** 5167 * The note text. 5168 * <P>Type: TEXT</P> 5169 */ 5170 public static final String NOTE = DATA1; 5171 } 5172 5173 /** 5174 * <p> 5175 * Group Membership. 5176 * </p> 5177 * <p> 5178 * You can use all columns defined for {@link ContactsContract.Data} as 5179 * well as the following aliases. 5180 * </p> 5181 * <h2>Column aliases</h2> 5182 * <table class="jd-sumtable"> 5183 * <tr> 5184 * <th>Type</th> 5185 * <th>Alias</th><th colspan='2'>Data column</th> 5186 * </tr> 5187 * <tr> 5188 * <td>long</td> 5189 * <td>{@link #GROUP_ROW_ID}</td> 5190 * <td>{@link #DATA1}</td> 5191 * <td></td> 5192 * </tr> 5193 * <tr> 5194 * <td>String</td> 5195 * <td>{@link #GROUP_SOURCE_ID}</td> 5196 * <td>none</td> 5197 * <td> 5198 * <p> 5199 * The sourceid of the group that this group membership refers to. 5200 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when 5201 * inserting a row. 5202 * </p> 5203 * <p> 5204 * If this field is specified, the provider will first try to 5205 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group 5206 * is found, it will use the corresponding row id. If the group is not 5207 * found, it will create one. 5208 * </td> 5209 * </tr> 5210 * </table> 5211 */ 5212 public static final class GroupMembership implements DataColumnsWithJoins { 5213 /** 5214 * This utility class cannot be instantiated 5215 */ 5216 private GroupMembership() {} 5217 5218 /** MIME type used when storing this in data table. */ 5219 public static final String CONTENT_ITEM_TYPE = 5220 "vnd.android.cursor.item/group_membership"; 5221 5222 /** 5223 * The row id of the group that this group membership refers to. Exactly one of 5224 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. 5225 * <P>Type: INTEGER</P> 5226 */ 5227 public static final String GROUP_ROW_ID = DATA1; 5228 5229 /** 5230 * The sourceid of the group that this group membership refers to. Exactly one of 5231 * this or {@link #GROUP_ROW_ID} must be set when inserting a row. 5232 * <P>Type: TEXT</P> 5233 */ 5234 public static final String GROUP_SOURCE_ID = "group_sourceid"; 5235 } 5236 5237 /** 5238 * <p> 5239 * A data kind representing a website related to the contact. 5240 * </p> 5241 * <p> 5242 * You can use all columns defined for {@link ContactsContract.Data} as 5243 * well as the following aliases. 5244 * </p> 5245 * <h2>Column aliases</h2> 5246 * <table class="jd-sumtable"> 5247 * <tr> 5248 * <th>Type</th> 5249 * <th>Alias</th><th colspan='2'>Data column</th> 5250 * </tr> 5251 * <tr> 5252 * <td>String</td> 5253 * <td>{@link #URL}</td> 5254 * <td>{@link #DATA1}</td> 5255 * <td></td> 5256 * </tr> 5257 * <tr> 5258 * <td>int</td> 5259 * <td>{@link #TYPE}</td> 5260 * <td>{@link #DATA2}</td> 5261 * <td>Allowed values are: 5262 * <p> 5263 * <ul> 5264 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 5265 * <li>{@link #TYPE_HOMEPAGE}</li> 5266 * <li>{@link #TYPE_BLOG}</li> 5267 * <li>{@link #TYPE_PROFILE}</li> 5268 * <li>{@link #TYPE_HOME}</li> 5269 * <li>{@link #TYPE_WORK}</li> 5270 * <li>{@link #TYPE_FTP}</li> 5271 * <li>{@link #TYPE_OTHER}</li> 5272 * </ul> 5273 * </p> 5274 * </td> 5275 * </tr> 5276 * <tr> 5277 * <td>String</td> 5278 * <td>{@link #LABEL}</td> 5279 * <td>{@link #DATA3}</td> 5280 * <td></td> 5281 * </tr> 5282 * </table> 5283 */ 5284 public static final class Website implements DataColumnsWithJoins, CommonColumns { 5285 /** 5286 * This utility class cannot be instantiated 5287 */ 5288 private Website() {} 5289 5290 /** MIME type used when storing this in data table. */ 5291 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; 5292 5293 public static final int TYPE_HOMEPAGE = 1; 5294 public static final int TYPE_BLOG = 2; 5295 public static final int TYPE_PROFILE = 3; 5296 public static final int TYPE_HOME = 4; 5297 public static final int TYPE_WORK = 5; 5298 public static final int TYPE_FTP = 6; 5299 public static final int TYPE_OTHER = 7; 5300 5301 /** 5302 * The website URL string. 5303 * <P>Type: TEXT</P> 5304 */ 5305 public static final String URL = DATA; 5306 } 5307 } 5308 5309 /** 5310 * @see Groups 5311 */ 5312 protected interface GroupsColumns { 5313 /** 5314 * The display title of this group. 5315 * <p> 5316 * Type: TEXT 5317 */ 5318 public static final String TITLE = "title"; 5319 5320 /** 5321 * The package name to use when creating {@link Resources} objects for 5322 * this group. This value is only designed for use when building user 5323 * interfaces, and should not be used to infer the owner. 5324 * 5325 * @hide 5326 */ 5327 public static final String RES_PACKAGE = "res_package"; 5328 5329 /** 5330 * The display title of this group to load as a resource from 5331 * {@link #RES_PACKAGE}, which may be localized. 5332 * <P>Type: TEXT</P> 5333 * 5334 * @hide 5335 */ 5336 public static final String TITLE_RES = "title_res"; 5337 5338 /** 5339 * Notes about the group. 5340 * <p> 5341 * Type: TEXT 5342 */ 5343 public static final String NOTES = "notes"; 5344 5345 /** 5346 * The ID of this group if it is a System Group, i.e. a group that has a special meaning 5347 * to the sync adapter, null otherwise. 5348 * <P>Type: TEXT</P> 5349 */ 5350 public static final String SYSTEM_ID = "system_id"; 5351 5352 /** 5353 * The total number of {@link Contacts} that have 5354 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only 5355 * present when querying {@link Groups#CONTENT_SUMMARY_URI}. 5356 * <p> 5357 * Type: INTEGER 5358 */ 5359 public static final String SUMMARY_COUNT = "summ_count"; 5360 5361 /** 5362 * The total number of {@link Contacts} that have both 5363 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. 5364 * Read-only value that is only present when querying 5365 * {@link Groups#CONTENT_SUMMARY_URI}. 5366 * <p> 5367 * Type: INTEGER 5368 */ 5369 public static final String SUMMARY_WITH_PHONES = "summ_phones"; 5370 5371 /** 5372 * Flag indicating if the contacts belonging to this group should be 5373 * visible in any user interface. 5374 * <p> 5375 * Type: INTEGER (boolean) 5376 */ 5377 public static final String GROUP_VISIBLE = "group_visible"; 5378 5379 /** 5380 * The "deleted" flag: "0" by default, "1" if the row has been marked 5381 * for deletion. When {@link android.content.ContentResolver#delete} is 5382 * called on a group, it is marked for deletion. The sync adaptor 5383 * deletes the group on the server and then calls ContactResolver.delete 5384 * once more, this time setting the the 5385 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to 5386 * finalize the data removal. 5387 * <P>Type: INTEGER</P> 5388 */ 5389 public static final String DELETED = "deleted"; 5390 5391 /** 5392 * Whether this group should be synced if the SYNC_EVERYTHING settings 5393 * is false for this group's account. 5394 * <p> 5395 * Type: INTEGER (boolean) 5396 */ 5397 public static final String SHOULD_SYNC = "should_sync"; 5398 5399 /** 5400 * Any newly created contacts will automatically be added to groups that have this 5401 * flag set to true. 5402 * <p> 5403 * Type: INTEGER (boolean) 5404 */ 5405 public static final String AUTO_ADD = "auto_add"; 5406 5407 /** 5408 * When a contacts is marked as a favorites it will be automatically added 5409 * to the groups that have this flag set, and when it is removed from favorites 5410 * it will be removed from these groups. 5411 * <p> 5412 * Type: INTEGER (boolean) 5413 */ 5414 public static final String FAVORITES = "favorites"; 5415 } 5416 5417 /** 5418 * Constants for the groups table. Only per-account groups are supported. 5419 * <h2>Columns</h2> 5420 * <table class="jd-sumtable"> 5421 * <tr> 5422 * <th colspan='4'>Groups</th> 5423 * </tr> 5424 * <tr> 5425 * <td>long</td> 5426 * <td>{@link #_ID}</td> 5427 * <td>read-only</td> 5428 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. 5429 * In other words, it would be a really bad idea to delete and reinsert a 5430 * group. A sync adapter should always do an update instead.</td> 5431 * </tr> 5432 * <tr> 5433 * <td>String</td> 5434 * <td>{@link #TITLE}</td> 5435 * <td>read/write</td> 5436 * <td>The display title of this group.</td> 5437 * </tr> 5438 * <tr> 5439 * <td>String</td> 5440 * <td>{@link #NOTES}</td> 5441 * <td>read/write</td> 5442 * <td>Notes about the group.</td> 5443 * </tr> 5444 * <tr> 5445 * <td>String</td> 5446 * <td>{@link #SYSTEM_ID}</td> 5447 * <td>read/write</td> 5448 * <td>The ID of this group if it is a System Group, i.e. a group that has a 5449 * special meaning to the sync adapter, null otherwise.</td> 5450 * </tr> 5451 * <tr> 5452 * <td>int</td> 5453 * <td>{@link #SUMMARY_COUNT}</td> 5454 * <td>read-only</td> 5455 * <td>The total number of {@link Contacts} that have 5456 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value 5457 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> 5458 * </tr> 5459 * <tr> 5460 * <td>int</td> 5461 * <td>{@link #SUMMARY_WITH_PHONES}</td> 5462 * <td>read-only</td> 5463 * <td>The total number of {@link Contacts} that have both 5464 * {@link CommonDataKinds.GroupMembership} in this group, and also have 5465 * phone numbers. Read-only value that is only present when querying 5466 * {@link Groups#CONTENT_SUMMARY_URI}.</td> 5467 * </tr> 5468 * <tr> 5469 * <td>int</td> 5470 * <td>{@link #GROUP_VISIBLE}</td> 5471 * <td>read-only</td> 5472 * <td>Flag indicating if the contacts belonging to this group should be 5473 * visible in any user interface. Allowed values: 0 and 1.</td> 5474 * </tr> 5475 * <tr> 5476 * <td>int</td> 5477 * <td>{@link #DELETED}</td> 5478 * <td>read/write</td> 5479 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked 5480 * for deletion. When {@link android.content.ContentResolver#delete} is 5481 * called on a group, it is marked for deletion. The sync adaptor deletes 5482 * the group on the server and then calls ContactResolver.delete once more, 5483 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} 5484 * query parameter to finalize the data removal.</td> 5485 * </tr> 5486 * <tr> 5487 * <td>int</td> 5488 * <td>{@link #SHOULD_SYNC}</td> 5489 * <td>read/write</td> 5490 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings 5491 * is false for this group's account.</td> 5492 * </tr> 5493 * </table> 5494 */ 5495 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { 5496 /** 5497 * This utility class cannot be instantiated 5498 */ 5499 private Groups() { 5500 } 5501 5502 /** 5503 * The content:// style URI for this table 5504 */ 5505 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); 5506 5507 /** 5508 * The content:// style URI for this table joined with details data from 5509 * {@link ContactsContract.Data}. 5510 */ 5511 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, 5512 "groups_summary"); 5513 5514 /** 5515 * The MIME type of a directory of groups. 5516 */ 5517 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; 5518 5519 /** 5520 * The MIME type of a single group. 5521 */ 5522 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; 5523 5524 public static EntityIterator newEntityIterator(Cursor cursor) { 5525 return new EntityIteratorImpl(cursor); 5526 } 5527 5528 private static class EntityIteratorImpl extends CursorEntityIterator { 5529 public EntityIteratorImpl(Cursor cursor) { 5530 super(cursor); 5531 } 5532 5533 @Override 5534 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { 5535 // we expect the cursor is already at the row we need to read from 5536 final ContentValues values = new ContentValues(); 5537 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); 5538 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); 5539 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); 5540 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); 5541 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); 5542 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); 5543 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); 5544 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); 5545 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); 5546 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); 5547 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); 5548 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); 5549 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); 5550 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); 5551 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); 5552 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); 5553 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); 5554 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); 5555 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); 5556 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); 5557 cursor.moveToNext(); 5558 return new Entity(values); 5559 } 5560 } 5561 } 5562 5563 /** 5564 * <p> 5565 * Constants for the contact aggregation exceptions table, which contains 5566 * aggregation rules overriding those used by automatic aggregation. This 5567 * type only supports query and update. Neither insert nor delete are 5568 * supported. 5569 * </p> 5570 * <h2>Columns</h2> 5571 * <table class="jd-sumtable"> 5572 * <tr> 5573 * <th colspan='4'>AggregationExceptions</th> 5574 * </tr> 5575 * <tr> 5576 * <td>int</td> 5577 * <td>{@link #TYPE}</td> 5578 * <td>read/write</td> 5579 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, 5580 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> 5581 * </tr> 5582 * <tr> 5583 * <td>long</td> 5584 * <td>{@link #RAW_CONTACT_ID1}</td> 5585 * <td>read/write</td> 5586 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that 5587 * the rule applies to.</td> 5588 * </tr> 5589 * <tr> 5590 * <td>long</td> 5591 * <td>{@link #RAW_CONTACT_ID2}</td> 5592 * <td>read/write</td> 5593 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact 5594 * that the rule applies to.</td> 5595 * </tr> 5596 * </table> 5597 */ 5598 public static final class AggregationExceptions implements BaseColumns { 5599 /** 5600 * This utility class cannot be instantiated 5601 */ 5602 private AggregationExceptions() {} 5603 5604 /** 5605 * The content:// style URI for this table 5606 */ 5607 public static final Uri CONTENT_URI = 5608 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); 5609 5610 /** 5611 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 5612 */ 5613 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; 5614 5615 /** 5616 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception 5617 */ 5618 public static final String CONTENT_ITEM_TYPE = 5619 "vnd.android.cursor.item/aggregation_exception"; 5620 5621 /** 5622 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or 5623 * {@link #TYPE_AUTOMATIC}. 5624 * 5625 * <P>Type: INTEGER</P> 5626 */ 5627 public static final String TYPE = "type"; 5628 5629 /** 5630 * Allows the provider to automatically decide whether the specified raw contacts should 5631 * be included in the same aggregate contact or not. 5632 */ 5633 public static final int TYPE_AUTOMATIC = 0; 5634 5635 /** 5636 * Makes sure that the specified raw contacts are included in the same 5637 * aggregate contact. 5638 */ 5639 public static final int TYPE_KEEP_TOGETHER = 1; 5640 5641 /** 5642 * Makes sure that the specified raw contacts are NOT included in the same 5643 * aggregate contact. 5644 */ 5645 public static final int TYPE_KEEP_SEPARATE = 2; 5646 5647 /** 5648 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. 5649 */ 5650 public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; 5651 5652 /** 5653 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule 5654 * applies to. 5655 */ 5656 public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; 5657 } 5658 5659 /** 5660 * @see Settings 5661 */ 5662 protected interface SettingsColumns { 5663 /** 5664 * The name of the account instance to which this row belongs. 5665 * <P>Type: TEXT</P> 5666 */ 5667 public static final String ACCOUNT_NAME = "account_name"; 5668 5669 /** 5670 * The type of account to which this row belongs, which when paired with 5671 * {@link #ACCOUNT_NAME} identifies a specific account. 5672 * <P>Type: TEXT</P> 5673 */ 5674 public static final String ACCOUNT_TYPE = "account_type"; 5675 5676 /** 5677 * Depending on the mode defined by the sync-adapter, this flag controls 5678 * the top-level sync behavior for this data source. 5679 * <p> 5680 * Type: INTEGER (boolean) 5681 */ 5682 public static final String SHOULD_SYNC = "should_sync"; 5683 5684 /** 5685 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} 5686 * entries should be visible in any user interface. 5687 * <p> 5688 * Type: INTEGER (boolean) 5689 */ 5690 public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; 5691 5692 /** 5693 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any 5694 * {@link Groups#SHOULD_SYNC} under this account have been marked as 5695 * unsynced. 5696 */ 5697 public static final String ANY_UNSYNCED = "any_unsynced"; 5698 5699 /** 5700 * Read-only count of {@link Contacts} from a specific source that have 5701 * no {@link CommonDataKinds.GroupMembership} entries. 5702 * <p> 5703 * Type: INTEGER 5704 */ 5705 public static final String UNGROUPED_COUNT = "summ_count"; 5706 5707 /** 5708 * Read-only count of {@link Contacts} from a specific source that have 5709 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. 5710 * <p> 5711 * Type: INTEGER 5712 */ 5713 public static final String UNGROUPED_WITH_PHONES = "summ_phones"; 5714 } 5715 5716 /** 5717 * <p> 5718 * Contacts-specific settings for various {@link Account}'s. 5719 * </p> 5720 * <h2>Columns</h2> 5721 * <table class="jd-sumtable"> 5722 * <tr> 5723 * <th colspan='4'>Settings</th> 5724 * </tr> 5725 * <tr> 5726 * <td>String</td> 5727 * <td>{@link #ACCOUNT_NAME}</td> 5728 * <td>read/write-once</td> 5729 * <td>The name of the account instance to which this row belongs.</td> 5730 * </tr> 5731 * <tr> 5732 * <td>String</td> 5733 * <td>{@link #ACCOUNT_TYPE}</td> 5734 * <td>read/write-once</td> 5735 * <td>The type of account to which this row belongs, which when paired with 5736 * {@link #ACCOUNT_NAME} identifies a specific account.</td> 5737 * </tr> 5738 * <tr> 5739 * <td>int</td> 5740 * <td>{@link #SHOULD_SYNC}</td> 5741 * <td>read/write</td> 5742 * <td>Depending on the mode defined by the sync-adapter, this flag controls 5743 * the top-level sync behavior for this data source.</td> 5744 * </tr> 5745 * <tr> 5746 * <td>int</td> 5747 * <td>{@link #UNGROUPED_VISIBLE}</td> 5748 * <td>read/write</td> 5749 * <td>Flag indicating if contacts without any 5750 * {@link CommonDataKinds.GroupMembership} entries should be visible in any 5751 * user interface.</td> 5752 * </tr> 5753 * <tr> 5754 * <td>int</td> 5755 * <td>{@link #ANY_UNSYNCED}</td> 5756 * <td>read-only</td> 5757 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any 5758 * {@link Groups#SHOULD_SYNC} under this account have been marked as 5759 * unsynced.</td> 5760 * </tr> 5761 * <tr> 5762 * <td>int</td> 5763 * <td>{@link #UNGROUPED_COUNT}</td> 5764 * <td>read-only</td> 5765 * <td>Read-only count of {@link Contacts} from a specific source that have 5766 * no {@link CommonDataKinds.GroupMembership} entries.</td> 5767 * </tr> 5768 * <tr> 5769 * <td>int</td> 5770 * <td>{@link #UNGROUPED_WITH_PHONES}</td> 5771 * <td>read-only</td> 5772 * <td>Read-only count of {@link Contacts} from a specific source that have 5773 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone 5774 * numbers.</td> 5775 * </tr> 5776 * </table> 5777 */ 5778 public static final class Settings implements SettingsColumns { 5779 /** 5780 * This utility class cannot be instantiated 5781 */ 5782 private Settings() { 5783 } 5784 5785 /** 5786 * The content:// style URI for this table 5787 */ 5788 public static final Uri CONTENT_URI = 5789 Uri.withAppendedPath(AUTHORITY_URI, "settings"); 5790 5791 /** 5792 * The MIME-type of {@link #CONTENT_URI} providing a directory of 5793 * settings. 5794 */ 5795 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; 5796 5797 /** 5798 * The MIME-type of {@link #CONTENT_URI} providing a single setting. 5799 */ 5800 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; 5801 } 5802 5803 /** 5804 * Private API for inquiring about the general status of the provider. 5805 * 5806 * @hide 5807 */ 5808 public static final class ProviderStatus { 5809 5810 /** 5811 * Not instantiable. 5812 */ 5813 private ProviderStatus() { 5814 } 5815 5816 /** 5817 * The content:// style URI for this table. Requests to this URI can be 5818 * performed on the UI thread because they are always unblocking. 5819 * 5820 * @hide 5821 */ 5822 public static final Uri CONTENT_URI = 5823 Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); 5824 5825 /** 5826 * The MIME-type of {@link #CONTENT_URI} providing a directory of 5827 * settings. 5828 * 5829 * @hide 5830 */ 5831 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; 5832 5833 /** 5834 * An integer representing the current status of the provider. 5835 * 5836 * @hide 5837 */ 5838 public static final String STATUS = "status"; 5839 5840 /** 5841 * Default status of the provider. 5842 * 5843 * @hide 5844 */ 5845 public static final int STATUS_NORMAL = 0; 5846 5847 /** 5848 * The status used when the provider is in the process of upgrading. Contacts 5849 * are temporarily unaccessible. 5850 * 5851 * @hide 5852 */ 5853 public static final int STATUS_UPGRADING = 1; 5854 5855 /** 5856 * The status used if the provider was in the process of upgrading but ran 5857 * out of storage. The DATA1 column will contain the estimated amount of 5858 * storage required (in bytes). Update status to STATUS_NORMAL to force 5859 * the provider to retry the upgrade. 5860 * 5861 * @hide 5862 */ 5863 public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2; 5864 5865 /** 5866 * The status used during a locale change. 5867 * 5868 * @hide 5869 */ 5870 public static final int STATUS_CHANGING_LOCALE = 3; 5871 5872 /** 5873 * Additional data associated with the status. 5874 * 5875 * @hide 5876 */ 5877 public static final String DATA1 = "data1"; 5878 } 5879 5880 /** 5881 * Helper methods to display QuickContact dialogs that allow users to pivot on 5882 * a specific {@link Contacts} entry. 5883 */ 5884 public static final class QuickContact { 5885 /** 5886 * Action used to trigger person pivot dialog. 5887 * @hide 5888 */ 5889 public static final String ACTION_QUICK_CONTACT = 5890 "com.android.contacts.action.QUICK_CONTACT"; 5891 5892 /** 5893 * Extra used to specify pivot dialog location in screen coordinates. 5894 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. 5895 * @hide 5896 */ 5897 @Deprecated 5898 public static final String EXTRA_TARGET_RECT = "target_rect"; 5899 5900 /** 5901 * Extra used to specify size of pivot dialog. 5902 * @hide 5903 */ 5904 public static final String EXTRA_MODE = "mode"; 5905 5906 /** 5907 * Extra used to indicate a list of specific MIME-types to exclude and 5908 * not display. Stored as a {@link String} array. 5909 * @hide 5910 */ 5911 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; 5912 5913 /** 5914 * Small QuickContact mode, usually presented with minimal actions. 5915 */ 5916 public static final int MODE_SMALL = 1; 5917 5918 /** 5919 * Medium QuickContact mode, includes actions and light summary describing 5920 * the {@link Contacts} entry being shown. This may include social 5921 * status and presence details. 5922 */ 5923 public static final int MODE_MEDIUM = 2; 5924 5925 /** 5926 * Large QuickContact mode, includes actions and larger, card-like summary 5927 * of the {@link Contacts} entry being shown. This may include detailed 5928 * information, such as a photo. 5929 */ 5930 public static final int MODE_LARGE = 3; 5931 5932 /** 5933 * Trigger a dialog that lists the various methods of interacting with 5934 * the requested {@link Contacts} entry. This may be based on available 5935 * {@link ContactsContract.Data} rows under that contact, and may also 5936 * include social status and presence details. 5937 * 5938 * @param context The parent {@link Context} that may be used as the 5939 * parent for this dialog. 5940 * @param target Specific {@link View} from your layout that this dialog 5941 * should be centered around. In particular, if the dialog 5942 * has a "callout" arrow, it will be pointed and centered 5943 * around this {@link View}. 5944 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 5945 * {@link Uri} that describes a specific contact to feature 5946 * in this dialog. 5947 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 5948 * {@link #MODE_LARGE}, indicating the desired dialog size, 5949 * when supported. 5950 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 5951 * to exclude when showing this dialog. For example, when 5952 * already viewing the contact details card, this can be used 5953 * to omit the details entry from the dialog. 5954 */ 5955 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, 5956 String[] excludeMimes) { 5957 // Find location and bounds of target view, adjusting based on the 5958 // assumed local density. 5959 final float appScale = context.getResources().getCompatibilityInfo().applicationScale; 5960 final int[] pos = new int[2]; 5961 target.getLocationOnScreen(pos); 5962 5963 final Rect rect = new Rect(); 5964 rect.left = (int) (pos[0] * appScale + 0.5f); 5965 rect.top = (int) (pos[1] * appScale + 0.5f); 5966 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); 5967 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); 5968 5969 // Trigger with obtained rectangle 5970 showQuickContact(context, rect, lookupUri, mode, excludeMimes); 5971 } 5972 5973 /** 5974 * Trigger a dialog that lists the various methods of interacting with 5975 * the requested {@link Contacts} entry. This may be based on available 5976 * {@link ContactsContract.Data} rows under that contact, and may also 5977 * include social status and presence details. 5978 * 5979 * @param context The parent {@link Context} that may be used as the 5980 * parent for this dialog. 5981 * @param target Specific {@link Rect} that this dialog should be 5982 * centered around, in screen coordinates. In particular, if 5983 * the dialog has a "callout" arrow, it will be pointed and 5984 * centered around this {@link Rect}. If you are running at a 5985 * non-native density, you need to manually adjust using 5986 * {@link DisplayMetrics#density} before calling. 5987 * @param lookupUri A 5988 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 5989 * {@link Uri} that describes a specific contact to feature 5990 * in this dialog. 5991 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 5992 * {@link #MODE_LARGE}, indicating the desired dialog size, 5993 * when supported. 5994 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 5995 * to exclude when showing this dialog. For example, when 5996 * already viewing the contact details card, this can be used 5997 * to omit the details entry from the dialog. 5998 */ 5999 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, 6000 String[] excludeMimes) { 6001 // Launch pivot dialog through intent for now 6002 final Intent intent = new Intent(ACTION_QUICK_CONTACT); 6003 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP 6004 | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 6005 6006 intent.setData(lookupUri); 6007 intent.setSourceBounds(target); 6008 intent.putExtra(EXTRA_MODE, mode); 6009 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); 6010 context.startActivity(intent); 6011 } 6012 } 6013 6014 /** 6015 * Contains helper classes used to create or manage {@link android.content.Intent Intents} 6016 * that involve contacts. 6017 */ 6018 public static final class Intents { 6019 /** 6020 * This is the intent that is fired when a search suggestion is clicked on. 6021 */ 6022 public static final String SEARCH_SUGGESTION_CLICKED = 6023 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; 6024 6025 /** 6026 * This is the intent that is fired when a search suggestion for dialing a number 6027 * is clicked on. 6028 */ 6029 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = 6030 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; 6031 6032 /** 6033 * This is the intent that is fired when a search suggestion for creating a contact 6034 * is clicked on. 6035 */ 6036 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = 6037 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; 6038 6039 /** 6040 * Starts an Activity that lets the user pick a contact to attach an image to. 6041 * After picking the contact it launches the image cropper in face detection mode. 6042 */ 6043 public static final String ATTACH_IMAGE = 6044 "com.android.contacts.action.ATTACH_IMAGE"; 6045 6046 /** 6047 * Takes as input a data URI with a mailto: or tel: scheme. If a single 6048 * contact exists with the given data it will be shown. If no contact 6049 * exists, a dialog will ask the user if they want to create a new 6050 * contact with the provided details filled in. If multiple contacts 6051 * share the data the user will be prompted to pick which contact they 6052 * want to view. 6053 * <p> 6054 * For <code>mailto:</code> URIs, the scheme specific portion must be a 6055 * raw email address, such as one built using 6056 * {@link Uri#fromParts(String, String, String)}. 6057 * <p> 6058 * For <code>tel:</code> URIs, the scheme specific portion is compared 6059 * to existing numbers using the standard caller ID lookup algorithm. 6060 * The number must be properly encoded, for example using 6061 * {@link Uri#fromParts(String, String, String)}. 6062 * <p> 6063 * Any extras from the {@link Insert} class will be passed along to the 6064 * create activity if there are no contacts to show. 6065 * <p> 6066 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip 6067 * prompting the user when the contact doesn't exist. 6068 */ 6069 public static final String SHOW_OR_CREATE_CONTACT = 6070 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; 6071 6072 /** 6073 * Starts an Activity that lets the user select the multiple phones from a 6074 * list of phone numbers which come from the contacts or 6075 * {@link #EXTRA_PHONE_URIS}. 6076 * <p> 6077 * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} 6078 * could belong to the contacts or not, and will be selected by default. 6079 * <p> 6080 * The user's selection will be returned from 6081 * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} 6082 * if the resultCode is 6083 * {@link android.app.Activity#RESULT_OK}, the array of picked phone 6084 * numbers are in the Intent's 6085 * {@link #EXTRA_PHONE_URIS}; otherwise, the 6086 * {@link android.app.Activity#RESULT_CANCELED} is returned if the user 6087 * left the Activity without changing the selection. 6088 * 6089 * @hide 6090 */ 6091 public static final String ACTION_GET_MULTIPLE_PHONES = 6092 "com.android.contacts.action.GET_MULTIPLE_PHONES"; 6093 6094 /** 6095 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new 6096 * contact if no matching contact found. Otherwise, default behavior is 6097 * to prompt user with dialog before creating. 6098 * <p> 6099 * Type: BOOLEAN 6100 */ 6101 public static final String EXTRA_FORCE_CREATE = 6102 "com.android.contacts.action.FORCE_CREATE"; 6103 6104 /** 6105 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact 6106 * description to be shown when prompting user about creating a new 6107 * contact. 6108 * <p> 6109 * Type: STRING 6110 */ 6111 public static final String EXTRA_CREATE_DESCRIPTION = 6112 "com.android.contacts.action.CREATE_DESCRIPTION"; 6113 6114 /** 6115 * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. 6116 * <p> 6117 * The phone numbers want to be picked by default should be passed in as 6118 * input value. These phone numbers could belong to the contacts or not. 6119 * <p> 6120 * The phone numbers which were picked by the user are returned as output 6121 * value. 6122 * <p> 6123 * Type: array of URIs, the tel URI is used for the phone numbers which don't 6124 * belong to any contact, the content URI is used for phone id in contacts. 6125 * 6126 * @hide 6127 */ 6128 public static final String EXTRA_PHONE_URIS = 6129 "com.android.contacts.extra.PHONE_URIS"; 6130 6131 /** 6132 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 6133 * dialog location using screen coordinates. When not specified, the 6134 * dialog will be centered. 6135 * 6136 * @hide 6137 */ 6138 @Deprecated 6139 public static final String EXTRA_TARGET_RECT = "target_rect"; 6140 6141 /** 6142 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 6143 * desired dialog style, usually a variation on size. One of 6144 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. 6145 * 6146 * @hide 6147 */ 6148 @Deprecated 6149 public static final String EXTRA_MODE = "mode"; 6150 6151 /** 6152 * Value for {@link #EXTRA_MODE} to show a small-sized dialog. 6153 * 6154 * @hide 6155 */ 6156 @Deprecated 6157 public static final int MODE_SMALL = 1; 6158 6159 /** 6160 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. 6161 * 6162 * @hide 6163 */ 6164 @Deprecated 6165 public static final int MODE_MEDIUM = 2; 6166 6167 /** 6168 * Value for {@link #EXTRA_MODE} to show a large-sized dialog. 6169 * 6170 * @hide 6171 */ 6172 @Deprecated 6173 public static final int MODE_LARGE = 3; 6174 6175 /** 6176 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate 6177 * a list of specific MIME-types to exclude and not display. Stored as a 6178 * {@link String} array. 6179 * 6180 * @hide 6181 */ 6182 @Deprecated 6183 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; 6184 6185 /** 6186 * Intents related to the Contacts app UI. 6187 * 6188 * @hide 6189 */ 6190 public static final class UI { 6191 /** 6192 * The action for the default contacts list tab. 6193 */ 6194 public static final String LIST_DEFAULT = 6195 "com.android.contacts.action.LIST_DEFAULT"; 6196 6197 /** 6198 * The action for the contacts list tab. 6199 */ 6200 public static final String LIST_GROUP_ACTION = 6201 "com.android.contacts.action.LIST_GROUP"; 6202 6203 /** 6204 * When in LIST_GROUP_ACTION mode, this is the group to display. 6205 */ 6206 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; 6207 6208 /** 6209 * The action for the all contacts list tab. 6210 */ 6211 public static final String LIST_ALL_CONTACTS_ACTION = 6212 "com.android.contacts.action.LIST_ALL_CONTACTS"; 6213 6214 /** 6215 * The action for the contacts with phone numbers list tab. 6216 */ 6217 public static final String LIST_CONTACTS_WITH_PHONES_ACTION = 6218 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; 6219 6220 /** 6221 * The action for the starred contacts list tab. 6222 */ 6223 public static final String LIST_STARRED_ACTION = 6224 "com.android.contacts.action.LIST_STARRED"; 6225 6226 /** 6227 * The action for the frequent contacts list tab. 6228 */ 6229 public static final String LIST_FREQUENT_ACTION = 6230 "com.android.contacts.action.LIST_FREQUENT"; 6231 6232 /** 6233 * The action for the "strequent" contacts list tab. It first lists the starred 6234 * contacts in alphabetical order and then the frequent contacts in descending 6235 * order of the number of times they have been contacted. 6236 */ 6237 public static final String LIST_STREQUENT_ACTION = 6238 "com.android.contacts.action.LIST_STREQUENT"; 6239 6240 /** 6241 * A key for to be used as an intent extra to set the activity 6242 * title to a custom String value. 6243 */ 6244 public static final String TITLE_EXTRA_KEY = 6245 "com.android.contacts.extra.TITLE_EXTRA"; 6246 6247 /** 6248 * Activity Action: Display a filtered list of contacts 6249 * <p> 6250 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for 6251 * filtering 6252 * <p> 6253 * Output: Nothing. 6254 */ 6255 public static final String FILTER_CONTACTS_ACTION = 6256 "com.android.contacts.action.FILTER_CONTACTS"; 6257 6258 /** 6259 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} 6260 * intents to supply the text on which to filter. 6261 */ 6262 public static final String FILTER_TEXT_EXTRA_KEY = 6263 "com.android.contacts.extra.FILTER_TEXT"; 6264 } 6265 6266 /** 6267 * Convenience class that contains string constants used 6268 * to create contact {@link android.content.Intent Intents}. 6269 */ 6270 public static final class Insert { 6271 /** The action code to use when adding a contact */ 6272 public static final String ACTION = Intent.ACTION_INSERT; 6273 6274 /** 6275 * If present, forces a bypass of quick insert mode. 6276 */ 6277 public static final String FULL_MODE = "full_mode"; 6278 6279 /** 6280 * The extra field for the contact name. 6281 * <P>Type: String</P> 6282 */ 6283 public static final String NAME = "name"; 6284 6285 // TODO add structured name values here. 6286 6287 /** 6288 * The extra field for the contact phonetic name. 6289 * <P>Type: String</P> 6290 */ 6291 public static final String PHONETIC_NAME = "phonetic_name"; 6292 6293 /** 6294 * The extra field for the contact company. 6295 * <P>Type: String</P> 6296 */ 6297 public static final String COMPANY = "company"; 6298 6299 /** 6300 * The extra field for the contact job title. 6301 * <P>Type: String</P> 6302 */ 6303 public static final String JOB_TITLE = "job_title"; 6304 6305 /** 6306 * The extra field for the contact notes. 6307 * <P>Type: String</P> 6308 */ 6309 public static final String NOTES = "notes"; 6310 6311 /** 6312 * The extra field for the contact phone number. 6313 * <P>Type: String</P> 6314 */ 6315 public static final String PHONE = "phone"; 6316 6317 /** 6318 * The extra field for the contact phone number type. 6319 * <P>Type: Either an integer value from 6320 * {@link CommonDataKinds.Phone}, 6321 * or a string specifying a custom label.</P> 6322 */ 6323 public static final String PHONE_TYPE = "phone_type"; 6324 6325 /** 6326 * The extra field for the phone isprimary flag. 6327 * <P>Type: boolean</P> 6328 */ 6329 public static final String PHONE_ISPRIMARY = "phone_isprimary"; 6330 6331 /** 6332 * The extra field for an optional second contact phone number. 6333 * <P>Type: String</P> 6334 */ 6335 public static final String SECONDARY_PHONE = "secondary_phone"; 6336 6337 /** 6338 * The extra field for an optional second contact phone number type. 6339 * <P>Type: Either an integer value from 6340 * {@link CommonDataKinds.Phone}, 6341 * or a string specifying a custom label.</P> 6342 */ 6343 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; 6344 6345 /** 6346 * The extra field for an optional third contact phone number. 6347 * <P>Type: String</P> 6348 */ 6349 public static final String TERTIARY_PHONE = "tertiary_phone"; 6350 6351 /** 6352 * The extra field for an optional third contact phone number type. 6353 * <P>Type: Either an integer value from 6354 * {@link CommonDataKinds.Phone}, 6355 * or a string specifying a custom label.</P> 6356 */ 6357 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; 6358 6359 /** 6360 * The extra field for the contact email address. 6361 * <P>Type: String</P> 6362 */ 6363 public static final String EMAIL = "email"; 6364 6365 /** 6366 * The extra field for the contact email type. 6367 * <P>Type: Either an integer value from 6368 * {@link CommonDataKinds.Email} 6369 * or a string specifying a custom label.</P> 6370 */ 6371 public static final String EMAIL_TYPE = "email_type"; 6372 6373 /** 6374 * The extra field for the email isprimary flag. 6375 * <P>Type: boolean</P> 6376 */ 6377 public static final String EMAIL_ISPRIMARY = "email_isprimary"; 6378 6379 /** 6380 * The extra field for an optional second contact email address. 6381 * <P>Type: String</P> 6382 */ 6383 public static final String SECONDARY_EMAIL = "secondary_email"; 6384 6385 /** 6386 * The extra field for an optional second contact email type. 6387 * <P>Type: Either an integer value from 6388 * {@link CommonDataKinds.Email} 6389 * or a string specifying a custom label.</P> 6390 */ 6391 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; 6392 6393 /** 6394 * The extra field for an optional third contact email address. 6395 * <P>Type: String</P> 6396 */ 6397 public static final String TERTIARY_EMAIL = "tertiary_email"; 6398 6399 /** 6400 * The extra field for an optional third contact email type. 6401 * <P>Type: Either an integer value from 6402 * {@link CommonDataKinds.Email} 6403 * or a string specifying a custom label.</P> 6404 */ 6405 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; 6406 6407 /** 6408 * The extra field for the contact postal address. 6409 * <P>Type: String</P> 6410 */ 6411 public static final String POSTAL = "postal"; 6412 6413 /** 6414 * The extra field for the contact postal address type. 6415 * <P>Type: Either an integer value from 6416 * {@link CommonDataKinds.StructuredPostal} 6417 * or a string specifying a custom label.</P> 6418 */ 6419 public static final String POSTAL_TYPE = "postal_type"; 6420 6421 /** 6422 * The extra field for the postal isprimary flag. 6423 * <P>Type: boolean</P> 6424 */ 6425 public static final String POSTAL_ISPRIMARY = "postal_isprimary"; 6426 6427 /** 6428 * The extra field for an IM handle. 6429 * <P>Type: String</P> 6430 */ 6431 public static final String IM_HANDLE = "im_handle"; 6432 6433 /** 6434 * The extra field for the IM protocol 6435 */ 6436 public static final String IM_PROTOCOL = "im_protocol"; 6437 6438 /** 6439 * The extra field for the IM isprimary flag. 6440 * <P>Type: boolean</P> 6441 */ 6442 public static final String IM_ISPRIMARY = "im_isprimary"; 6443 } 6444 } 6445} 6446