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