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