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