ContactsContract.java revision f9fb60a592fb2cc7b68084843648a7bee020eddf
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 "name_verified" flag: "1" means that the name fields on this raw 2252 * contact can be trusted and therefore should be used for the entire 2253 * aggregated contact. 2254 * <p> 2255 * If an aggregated contact contains more than one raw contact with a 2256 * verified name, one of those verified names is chosen at random. 2257 * If an aggregated contact contains no verified names, the 2258 * name is chosen randomly from the constituent raw contacts. 2259 * </p> 2260 * <p> 2261 * Updating this flag from "0" to "1" automatically resets it to "0" on 2262 * all other raw contacts in the same aggregated contact. 2263 * </p> 2264 * <p> 2265 * Sync adapters should only specify a value for this column when 2266 * inserting a raw contact and leave it out when doing an update. 2267 * </p> 2268 * <p> 2269 * The default value is "0" 2270 * </p> 2271 * <p>Type: INTEGER</p> 2272 * 2273 * @hide 2274 */ 2275 public static final String NAME_VERIFIED = "name_verified"; 2276 2277 /** 2278 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or 2279 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. 2280 * <P>Type: INTEGER</P> 2281 */ 2282 public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only"; 2283 2284 /** 2285 * Flag that reflects whether this raw contact belongs to the user's 2286 * personal profile entry. 2287 */ 2288 public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile"; 2289 } 2290 2291 /** 2292 * Constants for the raw contacts table, which contains one row of contact 2293 * information for each person in each synced account. Sync adapters and 2294 * contact management apps 2295 * are the primary consumers of this API. 2296 * 2297 * <h3>Aggregation</h3> 2298 * <p> 2299 * As soon as a raw contact is inserted or whenever its constituent data 2300 * changes, the provider will check if the raw contact matches other 2301 * existing raw contacts and if so will aggregate it with those. The 2302 * aggregation is reflected in the {@link RawContacts} table by the change of the 2303 * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. 2304 * </p> 2305 * <p> 2306 * Changes to the structured name, organization, phone number, email address, 2307 * or nickname trigger a re-aggregation. 2308 * </p> 2309 * <p> 2310 * See also {@link AggregationExceptions} for a mechanism to control 2311 * aggregation programmatically. 2312 * </p> 2313 * 2314 * <h3>Operations</h3> 2315 * <dl> 2316 * <dt><b>Insert</b></dt> 2317 * <dd> 2318 * <p> 2319 * Raw contacts can be inserted incrementally or in a batch. 2320 * The incremental method is more traditional but less efficient. 2321 * It should be used 2322 * only if no {@link Data} values are available at the time the raw contact is created: 2323 * <pre> 2324 * ContentValues values = new ContentValues(); 2325 * values.put(RawContacts.ACCOUNT_TYPE, accountType); 2326 * values.put(RawContacts.ACCOUNT_NAME, accountName); 2327 * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); 2328 * long rawContactId = ContentUris.parseId(rawContactUri); 2329 * </pre> 2330 * </p> 2331 * <p> 2332 * Once {@link Data} values become available, insert those. 2333 * For example, here's how you would insert a name: 2334 * 2335 * <pre> 2336 * values.clear(); 2337 * values.put(Data.RAW_CONTACT_ID, rawContactId); 2338 * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); 2339 * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); 2340 * getContentResolver().insert(Data.CONTENT_URI, values); 2341 * </pre> 2342 * </p> 2343 * <p> 2344 * The batch method is by far preferred. It inserts the raw contact and its 2345 * constituent data rows in a single database transaction 2346 * and causes at most one aggregation pass. 2347 * <pre> 2348 * ArrayList<ContentProviderOperation> ops = 2349 * new ArrayList<ContentProviderOperation>(); 2350 * ... 2351 * int rawContactInsertIndex = ops.size(); 2352 * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) 2353 * .withValue(RawContacts.ACCOUNT_TYPE, accountType) 2354 * .withValue(RawContacts.ACCOUNT_NAME, accountName) 2355 * .build()); 2356 * 2357 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 2358 * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) 2359 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 2360 * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") 2361 * .build()); 2362 * 2363 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 2364 * </pre> 2365 * </p> 2366 * <p> 2367 * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} 2368 * to refer to the as-yet-unknown index value of the raw contact inserted in the 2369 * first operation. 2370 * </p> 2371 * 2372 * <dt><b>Update</b></dt> 2373 * <dd><p> 2374 * Raw contacts can be updated incrementally or in a batch. 2375 * Batch mode should be used whenever possible. 2376 * The procedures and considerations are analogous to those documented above for inserts. 2377 * </p></dd> 2378 * <dt><b>Delete</b></dt> 2379 * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, 2380 * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw 2381 * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row 2382 * itself is also deleted automatically. 2383 * </p> 2384 * <p> 2385 * The invocation of {@code resolver.delete(...)}, does not immediately delete 2386 * a raw contacts row. 2387 * Instead, it sets the {@link #DELETED} flag on the raw contact and 2388 * removes the raw contact from its aggregate contact. 2389 * The sync adapter then deletes the raw contact from the server and 2390 * finalizes phone-side deletion by calling {@code resolver.delete(...)} 2391 * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> 2392 * <p>Some sync adapters are read-only, meaning that they only sync server-side 2393 * changes to the phone, but not the reverse. If one of those raw contacts 2394 * is marked for deletion, it will remain on the phone. However it will be 2395 * effectively invisible, because it will not be part of any aggregate contact. 2396 * </dd> 2397 * 2398 * <dt><b>Query</b></dt> 2399 * <dd> 2400 * <p> 2401 * It is easy to find all raw contacts in a Contact: 2402 * <pre> 2403 * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, 2404 * new String[]{RawContacts._ID}, 2405 * RawContacts.CONTACT_ID + "=?", 2406 * new String[]{String.valueOf(contactId)}, null); 2407 * </pre> 2408 * </p> 2409 * <p> 2410 * To find raw contacts within a specific account, 2411 * you can either put the account name and type in the selection or pass them as query 2412 * parameters. The latter approach is preferable, especially when you can reuse the 2413 * URI: 2414 * <pre> 2415 * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon() 2416 * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) 2417 * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) 2418 * .build(); 2419 * Cursor c1 = getContentResolver().query(rawContactUri, 2420 * RawContacts.STARRED + "<>0", null, null, null); 2421 * ... 2422 * Cursor c2 = getContentResolver().query(rawContactUri, 2423 * RawContacts.DELETED + "<>0", null, null, null); 2424 * </pre> 2425 * </p> 2426 * <p>The best way to read a raw contact along with all the data associated with it is 2427 * by using the {@link Entity} directory. If the raw contact has data rows, 2428 * the Entity cursor will contain a row for each data row. If the raw contact has no 2429 * data rows, the cursor will still contain one row with the raw contact-level information. 2430 * <pre> 2431 * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); 2432 * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); 2433 * Cursor c = getContentResolver().query(entityUri, 2434 * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, 2435 * null, null, null); 2436 * try { 2437 * while (c.moveToNext()) { 2438 * String sourceId = c.getString(0); 2439 * if (!c.isNull(1)) { 2440 * String mimeType = c.getString(2); 2441 * String data = c.getString(3); 2442 * ... 2443 * } 2444 * } 2445 * } finally { 2446 * c.close(); 2447 * } 2448 * </pre> 2449 * </p> 2450 * </dd> 2451 * </dl> 2452 * <h2>Columns</h2> 2453 * 2454 * <table class="jd-sumtable"> 2455 * <tr> 2456 * <th colspan='4'>RawContacts</th> 2457 * </tr> 2458 * <tr> 2459 * <td>long</td> 2460 * <td>{@link #_ID}</td> 2461 * <td>read-only</td> 2462 * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, 2463 * it is much better for a sync adapter to update a raw contact rather than to delete and 2464 * re-insert it.</td> 2465 * </tr> 2466 * <tr> 2467 * <td>long</td> 2468 * <td>{@link #CONTACT_ID}</td> 2469 * <td>read-only</td> 2470 * <td>The ID of the row in the {@link ContactsContract.Contacts} table 2471 * that this raw contact belongs 2472 * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled 2473 * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> 2474 * </tr> 2475 * <tr> 2476 * <td>int</td> 2477 * <td>{@link #AGGREGATION_MODE}</td> 2478 * <td>read/write</td> 2479 * <td>A mechanism that allows programmatic control of the aggregation process. The allowed 2480 * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} 2481 * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> 2482 * </tr> 2483 * <tr> 2484 * <td>int</td> 2485 * <td>{@link #DELETED}</td> 2486 * <td>read/write</td> 2487 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked 2488 * for deletion. When {@link android.content.ContentResolver#delete} is 2489 * called on a raw contact, it is marked for deletion and removed from its 2490 * aggregate contact. The sync adaptor deletes the raw contact on the server and 2491 * then calls ContactResolver.delete once more, this time passing the 2492 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize 2493 * the data removal.</td> 2494 * </tr> 2495 * <tr> 2496 * <td>int</td> 2497 * <td>{@link #TIMES_CONTACTED}</td> 2498 * <td>read/write</td> 2499 * <td>The number of times the contact has been contacted. To have an effect 2500 * on the corresponding value of the aggregate contact, this field 2501 * should be set at the time the raw contact is inserted. 2502 * After that, this value is typically updated via 2503 * {@link ContactsContract.Contacts#markAsContacted}.</td> 2504 * </tr> 2505 * <tr> 2506 * <td>long</td> 2507 * <td>{@link #LAST_TIME_CONTACTED}</td> 2508 * <td>read/write</td> 2509 * <td>The timestamp of the last time the contact was contacted. To have an effect 2510 * on the corresponding value of the aggregate contact, this field 2511 * should be set at the time the raw contact is inserted. 2512 * After that, this value is typically updated via 2513 * {@link ContactsContract.Contacts#markAsContacted}. 2514 * </td> 2515 * </tr> 2516 * <tr> 2517 * <td>int</td> 2518 * <td>{@link #STARRED}</td> 2519 * <td>read/write</td> 2520 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. 2521 * Changing this field immediately affects the corresponding aggregate contact: 2522 * if any raw contacts in that aggregate contact are starred, then the contact 2523 * itself is marked as starred.</td> 2524 * </tr> 2525 * <tr> 2526 * <td>String</td> 2527 * <td>{@link #CUSTOM_RINGTONE}</td> 2528 * <td>read/write</td> 2529 * <td>A custom ringtone associated with a raw contact. Typically this is the 2530 * URI returned by an activity launched with the 2531 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. 2532 * To have an effect on the corresponding value of the aggregate contact, this field 2533 * should be set at the time the raw contact is inserted. To set a custom 2534 * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE 2535 * Contacts.CUSTOM_RINGTONE} 2536 * instead.</td> 2537 * </tr> 2538 * <tr> 2539 * <td>int</td> 2540 * <td>{@link #SEND_TO_VOICEMAIL}</td> 2541 * <td>read/write</td> 2542 * <td>An indicator of whether calls from this raw contact should be forwarded 2543 * directly to voice mail ('1') or not ('0'). To have an effect 2544 * on the corresponding value of the aggregate contact, this field 2545 * should be set at the time the raw contact is inserted.</td> 2546 * </tr> 2547 * <tr> 2548 * <td>String</td> 2549 * <td>{@link #ACCOUNT_NAME}</td> 2550 * <td>read/write-once</td> 2551 * <td>The name of the account instance to which this row belongs, which when paired with 2552 * {@link #ACCOUNT_TYPE} identifies a specific account. 2553 * For example, this will be the Gmail address if it is a Google account. 2554 * It should be set at the time the raw contact is inserted and never 2555 * changed afterwards.</td> 2556 * </tr> 2557 * <tr> 2558 * <td>String</td> 2559 * <td>{@link #ACCOUNT_TYPE}</td> 2560 * <td>read/write-once</td> 2561 * <td> 2562 * <p> 2563 * The type of account to which this row belongs, which when paired with 2564 * {@link #ACCOUNT_NAME} identifies a specific account. 2565 * It should be set at the time the raw contact is inserted and never 2566 * changed afterwards. 2567 * </p> 2568 * <p> 2569 * To ensure uniqueness, new account types should be chosen according to the 2570 * Java package naming convention. Thus a Google account is of type "com.google". 2571 * </p> 2572 * </td> 2573 * </tr> 2574 * <tr> 2575 * <td>String</td> 2576 * <td>{@link #DATA_SET}</td> 2577 * <td>read/write-once</td> 2578 * <td> 2579 * <p> 2580 * The data set within the account that this row belongs to. This allows 2581 * multiple sync adapters for the same account type to distinguish between 2582 * each others' data. The combination of {@link #ACCOUNT_TYPE}, 2583 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data 2584 * that is associated with a single sync adapter. 2585 * </p> 2586 * <p> 2587 * This is empty by default, and is completely optional. It only needs to 2588 * be populated if multiple sync adapters are entering distinct data for 2589 * the same account type and account name. 2590 * </p> 2591 * <p> 2592 * It should be set at the time the raw contact is inserted and never 2593 * changed afterwards. 2594 * </p> 2595 * </td> 2596 * </tr> 2597 * <tr> 2598 * <td>String</td> 2599 * <td>{@link #SOURCE_ID}</td> 2600 * <td>read/write</td> 2601 * <td>String that uniquely identifies this row to its source account. 2602 * Typically it is set at the time the raw contact is inserted and never 2603 * changed afterwards. The one notable exception is a new raw contact: it 2604 * will have an account name and type (and possibly a data set), but no 2605 * source id. This indicates to the sync adapter that a new contact needs 2606 * to be created server-side and its ID stored in the corresponding 2607 * SOURCE_ID field on the phone. 2608 * </td> 2609 * </tr> 2610 * <tr> 2611 * <td>int</td> 2612 * <td>{@link #VERSION}</td> 2613 * <td>read-only</td> 2614 * <td>Version number that is updated whenever this row or its related data 2615 * changes. This field can be used for optimistic locking of a raw contact. 2616 * </td> 2617 * </tr> 2618 * <tr> 2619 * <td>int</td> 2620 * <td>{@link #DIRTY}</td> 2621 * <td>read/write</td> 2622 * <td>Flag indicating that {@link #VERSION} has changed, and this row needs 2623 * to be synchronized by its owning account. The value is set to "1" automatically 2624 * whenever the raw contact changes, unless the URI has the 2625 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. 2626 * The sync adapter should always supply this query parameter to prevent 2627 * unnecessary synchronization: user changes some data on the server, 2628 * the sync adapter updates the contact on the phone (without the 2629 * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, 2630 * which triggers a sync to bring the changes to the server. 2631 * </td> 2632 * </tr> 2633 * <tr> 2634 * <td>String</td> 2635 * <td>{@link #SYNC1}</td> 2636 * <td>read/write</td> 2637 * <td>Generic column provided for arbitrary use by sync adapters. 2638 * The content provider 2639 * stores this information on behalf of the sync adapter but does not 2640 * interpret it in any way. 2641 * </td> 2642 * </tr> 2643 * <tr> 2644 * <td>String</td> 2645 * <td>{@link #SYNC2}</td> 2646 * <td>read/write</td> 2647 * <td>Generic column for use by sync adapters. 2648 * </td> 2649 * </tr> 2650 * <tr> 2651 * <td>String</td> 2652 * <td>{@link #SYNC3}</td> 2653 * <td>read/write</td> 2654 * <td>Generic column for use by sync adapters. 2655 * </td> 2656 * </tr> 2657 * <tr> 2658 * <td>String</td> 2659 * <td>{@link #SYNC4}</td> 2660 * <td>read/write</td> 2661 * <td>Generic column for use by sync adapters. 2662 * </td> 2663 * </tr> 2664 * </table> 2665 */ 2666 public static final class RawContacts implements BaseColumns, RawContactsColumns, 2667 ContactOptionsColumns, ContactNameColumns, SyncColumns { 2668 /** 2669 * This utility class cannot be instantiated 2670 */ 2671 private RawContacts() { 2672 } 2673 2674 /** 2675 * The content:// style URI for this table, which requests a directory of 2676 * raw contact rows matching the selection criteria. 2677 */ 2678 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); 2679 2680 /** 2681 * The MIME type of the results from {@link #CONTENT_URI} when a specific 2682 * ID value is not provided, and multiple raw contacts may be returned. 2683 */ 2684 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; 2685 2686 /** 2687 * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, 2688 * yielding a subdirectory of a single person. 2689 */ 2690 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact"; 2691 2692 /** 2693 * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. 2694 */ 2695 public static final int AGGREGATION_MODE_DEFAULT = 0; 2696 2697 /** 2698 * Aggregation mode: aggregate at the time the raw contact is inserted/updated. 2699 * @deprecated Aggregation is synchronous, this historic value is a no-op 2700 */ 2701 @Deprecated 2702 public static final int AGGREGATION_MODE_IMMEDIATE = 1; 2703 2704 /** 2705 * <p> 2706 * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. 2707 * Changes to the raw contact will update the associated aggregate contact but will not 2708 * result in any change in how the contact is aggregated. Similar to 2709 * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding 2710 * {@link Contacts} aggregate. 2711 * </p> 2712 * <p> 2713 * This can be used to postpone aggregation until after a series of updates, for better 2714 * performance and/or user experience. 2715 * </p> 2716 * <p> 2717 * Note that changing 2718 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to 2719 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any 2720 * subsequent 2721 * change to the raw contact's data will. 2722 * </p> 2723 */ 2724 public static final int AGGREGATION_MODE_SUSPENDED = 2; 2725 2726 /** 2727 * <p> 2728 * Aggregation mode: never aggregate this raw contact. The raw contact will not 2729 * have a corresponding {@link Contacts} aggregate and therefore will not be included in 2730 * {@link Contacts} query results. 2731 * </p> 2732 * <p> 2733 * For example, this mode can be used for a raw contact that is marked for deletion while 2734 * waiting for the deletion to occur on the server side. 2735 * </p> 2736 * 2737 * @see #AGGREGATION_MODE_SUSPENDED 2738 */ 2739 public static final int AGGREGATION_MODE_DISABLED = 3; 2740 2741 /** 2742 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} 2743 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} 2744 * entry of the given {@link RawContacts} entry. 2745 */ 2746 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { 2747 // TODO: use a lighter query by joining rawcontacts with contacts in provider 2748 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); 2749 final Cursor cursor = resolver.query(dataUri, new String[] { 2750 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY 2751 }, null, null, null); 2752 2753 Uri lookupUri = null; 2754 try { 2755 if (cursor != null && cursor.moveToFirst()) { 2756 final long contactId = cursor.getLong(0); 2757 final String lookupKey = cursor.getString(1); 2758 return Contacts.getLookupUri(contactId, lookupKey); 2759 } 2760 } finally { 2761 if (cursor != null) cursor.close(); 2762 } 2763 return lookupUri; 2764 } 2765 2766 /** 2767 * A sub-directory of a single raw contact that contains all of its 2768 * {@link ContactsContract.Data} rows. To access this directory 2769 * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. 2770 */ 2771 public static final class Data implements BaseColumns, DataColumns { 2772 /** 2773 * no public constructor since this is a utility class 2774 */ 2775 private Data() { 2776 } 2777 2778 /** 2779 * The directory twig for this sub-table 2780 */ 2781 public static final String CONTENT_DIRECTORY = "data"; 2782 } 2783 2784 /** 2785 * <p> 2786 * A sub-directory of a single raw contact that contains all of its 2787 * {@link ContactsContract.Data} rows. To access this directory append 2788 * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See 2789 * {@link RawContactsEntity} for a stand-alone table containing the same 2790 * data. 2791 * </p> 2792 * <p> 2793 * Entity has two ID fields: {@link #_ID} for the raw contact 2794 * and {@link #DATA_ID} for the data rows. 2795 * Entity always contains at least one row, even if there are no 2796 * actual data rows. In this case the {@link #DATA_ID} field will be 2797 * null. 2798 * </p> 2799 * <p> 2800 * Using Entity should be preferred to using two separate queries: 2801 * RawContacts followed by Data. The reason is that Entity reads all 2802 * data for a raw contact in one transaction, so there is no possibility 2803 * of the data changing between the two queries. 2804 */ 2805 public static final class Entity implements BaseColumns, DataColumns { 2806 /** 2807 * no public constructor since this is a utility class 2808 */ 2809 private Entity() { 2810 } 2811 2812 /** 2813 * The directory twig for this sub-table 2814 */ 2815 public static final String CONTENT_DIRECTORY = "entity"; 2816 2817 /** 2818 * The ID of the data row. The value will be null if this raw contact has no 2819 * data rows. 2820 * <P>Type: INTEGER</P> 2821 */ 2822 public static final String DATA_ID = "data_id"; 2823 } 2824 2825 /** 2826 * <p> 2827 * A sub-directory of a single raw contact that contains all of its 2828 * {@link ContactsContract.StreamItems} rows. To access this directory append 2829 * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See 2830 * {@link ContactsContract.StreamItems} for a stand-alone table containing the 2831 * same data. 2832 * </p> 2833 * <p> 2834 * Access to the social stream through this sub-directory requires additional permissions 2835 * beyond the read/write contact permissions required by the provider. Querying for 2836 * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and 2837 * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM 2838 * permission. 2839 * </p> 2840 * 2841 * @deprecated - Do not use. This will not be supported in the future. In the future, 2842 * cursors returned from related queries will be empty. 2843 */ 2844 @Deprecated 2845 public static final class StreamItems implements BaseColumns, StreamItemsColumns { 2846 /** 2847 * No public constructor since this is a utility class 2848 * 2849 * @deprecated - Do not use. This will not be supported in the future. In the future, 2850 * cursors returned from related queries will be empty. 2851 */ 2852 @Deprecated 2853 private StreamItems() { 2854 } 2855 2856 /** 2857 * The directory twig for this sub-table 2858 * 2859 * @deprecated - Do not use. This will not be supported in the future. In the future, 2860 * cursors returned from related queries will be empty. 2861 */ 2862 @Deprecated 2863 public static final String CONTENT_DIRECTORY = "stream_items"; 2864 } 2865 2866 /** 2867 * <p> 2868 * A sub-directory of a single raw contact that represents its primary 2869 * display photo. To access this directory append 2870 * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI. 2871 * The resulting URI represents an image file, and should be interacted with 2872 * using ContentResolver.openAssetFileDescriptor. 2873 * <p> 2874 * <p> 2875 * Note that this sub-directory also supports opening the photo as an asset file 2876 * in write mode. Callers can create or replace the primary photo associated 2877 * with this raw contact by opening the asset file and writing the full-size 2878 * photo contents into it. When the file is closed, the image will be parsed, 2879 * sized down if necessary for the full-size display photo and thumbnail 2880 * dimensions, and stored. 2881 * </p> 2882 * <p> 2883 * Usage example: 2884 * <pre> 2885 * public void writeDisplayPhoto(long rawContactId, byte[] photo) { 2886 * Uri rawContactPhotoUri = Uri.withAppendedPath( 2887 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), 2888 * RawContacts.DisplayPhoto.CONTENT_DIRECTORY); 2889 * try { 2890 * AssetFileDescriptor fd = 2891 * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw"); 2892 * OutputStream os = fd.createOutputStream(); 2893 * os.write(photo); 2894 * os.close(); 2895 * fd.close(); 2896 * } catch (IOException e) { 2897 * // Handle error cases. 2898 * } 2899 * } 2900 * </pre> 2901 * </p> 2902 */ 2903 public static final class DisplayPhoto { 2904 /** 2905 * No public constructor since this is a utility class 2906 */ 2907 private DisplayPhoto() { 2908 } 2909 2910 /** 2911 * The directory twig for this sub-table 2912 */ 2913 public static final String CONTENT_DIRECTORY = "display_photo"; 2914 } 2915 2916 /** 2917 * TODO: javadoc 2918 * @param cursor 2919 * @return 2920 */ 2921 public static EntityIterator newEntityIterator(Cursor cursor) { 2922 return new EntityIteratorImpl(cursor); 2923 } 2924 2925 private static class EntityIteratorImpl extends CursorEntityIterator { 2926 private static final String[] DATA_KEYS = new String[]{ 2927 Data.DATA1, 2928 Data.DATA2, 2929 Data.DATA3, 2930 Data.DATA4, 2931 Data.DATA5, 2932 Data.DATA6, 2933 Data.DATA7, 2934 Data.DATA8, 2935 Data.DATA9, 2936 Data.DATA10, 2937 Data.DATA11, 2938 Data.DATA12, 2939 Data.DATA13, 2940 Data.DATA14, 2941 Data.DATA15, 2942 Data.SYNC1, 2943 Data.SYNC2, 2944 Data.SYNC3, 2945 Data.SYNC4}; 2946 2947 public EntityIteratorImpl(Cursor cursor) { 2948 super(cursor); 2949 } 2950 2951 @Override 2952 public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) 2953 throws RemoteException { 2954 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); 2955 final long rawContactId = cursor.getLong(columnRawContactId); 2956 2957 // we expect the cursor is already at the row we need to read from 2958 ContentValues cv = new ContentValues(); 2959 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); 2960 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); 2961 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET); 2962 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); 2963 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); 2964 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); 2965 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); 2966 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); 2967 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); 2968 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); 2969 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); 2970 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); 2971 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); 2972 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); 2973 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED); 2974 android.content.Entity contact = new android.content.Entity(cv); 2975 2976 // read data rows until the contact id changes 2977 do { 2978 if (rawContactId != cursor.getLong(columnRawContactId)) { 2979 break; 2980 } 2981 // add the data to to the contact 2982 cv = new ContentValues(); 2983 cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); 2984 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 2985 Data.RES_PACKAGE); 2986 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); 2987 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); 2988 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, 2989 Data.IS_SUPER_PRIMARY); 2990 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); 2991 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 2992 CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); 2993 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 2994 Data.DATA_VERSION); 2995 for (String key : DATA_KEYS) { 2996 final int columnIndex = cursor.getColumnIndexOrThrow(key); 2997 switch (cursor.getType(columnIndex)) { 2998 case Cursor.FIELD_TYPE_NULL: 2999 // don't put anything 3000 break; 3001 case Cursor.FIELD_TYPE_INTEGER: 3002 case Cursor.FIELD_TYPE_FLOAT: 3003 case Cursor.FIELD_TYPE_STRING: 3004 cv.put(key, cursor.getString(columnIndex)); 3005 break; 3006 case Cursor.FIELD_TYPE_BLOB: 3007 cv.put(key, cursor.getBlob(columnIndex)); 3008 break; 3009 default: 3010 throw new IllegalStateException("Invalid or unhandled data type"); 3011 } 3012 } 3013 contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); 3014 } while (cursor.moveToNext()); 3015 3016 return contact; 3017 } 3018 3019 } 3020 } 3021 3022 /** 3023 * Social status update columns. 3024 * 3025 * @see StatusUpdates 3026 * @see ContactsContract.Data 3027 */ 3028 protected interface StatusColumns { 3029 /** 3030 * Contact's latest presence level. 3031 * <P>Type: INTEGER (one of the values below)</P> 3032 */ 3033 public static final String PRESENCE = "mode"; 3034 3035 /** 3036 * @deprecated use {@link #PRESENCE} 3037 */ 3038 @Deprecated 3039 public static final String PRESENCE_STATUS = PRESENCE; 3040 3041 /** 3042 * An allowed value of {@link #PRESENCE}. 3043 */ 3044 int OFFLINE = 0; 3045 3046 /** 3047 * An allowed value of {@link #PRESENCE}. 3048 */ 3049 int INVISIBLE = 1; 3050 3051 /** 3052 * An allowed value of {@link #PRESENCE}. 3053 */ 3054 int AWAY = 2; 3055 3056 /** 3057 * An allowed value of {@link #PRESENCE}. 3058 */ 3059 int IDLE = 3; 3060 3061 /** 3062 * An allowed value of {@link #PRESENCE}. 3063 */ 3064 int DO_NOT_DISTURB = 4; 3065 3066 /** 3067 * An allowed value of {@link #PRESENCE}. 3068 */ 3069 int AVAILABLE = 5; 3070 3071 /** 3072 * Contact latest status update. 3073 * <p>Type: TEXT</p> 3074 */ 3075 public static final String STATUS = "status"; 3076 3077 /** 3078 * @deprecated use {@link #STATUS} 3079 */ 3080 @Deprecated 3081 public static final String PRESENCE_CUSTOM_STATUS = STATUS; 3082 3083 /** 3084 * The absolute time in milliseconds when the latest status was inserted/updated. 3085 * <p>Type: NUMBER</p> 3086 */ 3087 public static final String STATUS_TIMESTAMP = "status_ts"; 3088 3089 /** 3090 * The package containing resources for this status: label and icon. 3091 * <p>Type: TEXT</p> 3092 */ 3093 public static final String STATUS_RES_PACKAGE = "status_res_package"; 3094 3095 /** 3096 * The resource ID of the label describing the source of the status update, e.g. "Google 3097 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. 3098 * <p>Type: NUMBER</p> 3099 */ 3100 public static final String STATUS_LABEL = "status_label"; 3101 3102 /** 3103 * The resource ID of the icon for the source of the status update. 3104 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. 3105 * <p>Type: NUMBER</p> 3106 */ 3107 public static final String STATUS_ICON = "status_icon"; 3108 3109 /** 3110 * Contact's audio/video chat capability level. 3111 * <P>Type: INTEGER (one of the values below)</P> 3112 */ 3113 public static final String CHAT_CAPABILITY = "chat_capability"; 3114 3115 /** 3116 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone 3117 * and speaker) 3118 */ 3119 public static final int CAPABILITY_HAS_VOICE = 1; 3120 3121 /** 3122 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can 3123 * display a video feed. 3124 */ 3125 public static final int CAPABILITY_HAS_VIDEO = 2; 3126 3127 /** 3128 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a 3129 * camera that can be used for video chat (e.g. a front-facing camera on a phone). 3130 */ 3131 public static final int CAPABILITY_HAS_CAMERA = 4; 3132 } 3133 3134 /** 3135 * <p> 3136 * Constants for the stream_items table, which contains social stream updates from 3137 * the user's contact list. 3138 * </p> 3139 * <p> 3140 * Only a certain number of stream items will ever be stored under a given raw contact. 3141 * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to 3142 * determine this limit, and should restrict the number of items inserted in any given 3143 * transaction correspondingly. Insertion of more items beyond the limit will 3144 * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}. 3145 * </p> 3146 * <p> 3147 * Access to the social stream through these URIs requires additional permissions beyond the 3148 * read/write contact permissions required by the provider. Querying for social stream data 3149 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social 3150 * stream items requires android.permission.WRITE_SOCIAL_STREAM permission. 3151 * </p> 3152 * <h3>Account check</h3> 3153 * <p> 3154 * The content URIs to the insert, update and delete operations are required to have the account 3155 * information matching that of the owning raw contact as query parameters, namely 3156 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. 3157 * {@link RawContacts#DATA_SET} isn't required. 3158 * </p> 3159 * <h3>Operations</h3> 3160 * <dl> 3161 * <dt><b>Insert</b></dt> 3162 * <dd> 3163 * <p>Social stream updates are always associated with a raw contact. There are a couple 3164 * of ways to insert these entries. 3165 * <dl> 3166 * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> 3167 * <dd> 3168 * <pre> 3169 * ContentValues values = new ContentValues(); 3170 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); 3171 * values.put(StreamItems.TIMESTAMP, timestamp); 3172 * values.put(StreamItems.COMMENTS, "3 people reshared this"); 3173 * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); 3174 * ContentUris.appendId(builder, rawContactId); 3175 * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); 3176 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); 3177 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); 3178 * Uri streamItemUri = getContentResolver().insert(builder.build(), values); 3179 * long streamItemId = ContentUris.parseId(streamItemUri); 3180 * </pre> 3181 * </dd> 3182 * <dt>Via {@link StreamItems#CONTENT_URI}:</dt> 3183 * <dd> 3184 *<pre> 3185 * ContentValues values = new ContentValues(); 3186 * values.put(StreamItems.RAW_CONTACT_ID, rawContactId); 3187 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); 3188 * values.put(StreamItems.TIMESTAMP, timestamp); 3189 * values.put(StreamItems.COMMENTS, "3 people reshared this"); 3190 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); 3191 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); 3192 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); 3193 * Uri streamItemUri = getContentResolver().insert(builder.build(), values); 3194 * long streamItemId = ContentUris.parseId(streamItemUri); 3195 *</pre> 3196 * </dd> 3197 * </dl> 3198 * </dd> 3199 * </p> 3200 * <p> 3201 * Once a {@link StreamItems} entry has been inserted, photos associated with that 3202 * social update can be inserted. For example, after one of the insertions above, 3203 * photos could be added to the stream item in one of the following ways: 3204 * <dl> 3205 * <dt>Via a URI including the stream item ID:</dt> 3206 * <dd> 3207 * <pre> 3208 * values.clear(); 3209 * values.put(StreamItemPhotos.SORT_INDEX, 1); 3210 * values.put(StreamItemPhotos.PHOTO, photoData); 3211 * getContentResolver().insert(Uri.withAppendedPath( 3212 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), 3213 * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values); 3214 * </pre> 3215 * </dd> 3216 * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> 3217 * <dd> 3218 * <pre> 3219 * values.clear(); 3220 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); 3221 * values.put(StreamItemPhotos.SORT_INDEX, 1); 3222 * values.put(StreamItemPhotos.PHOTO, photoData); 3223 * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values); 3224 * </pre> 3225 * <p>Note that this latter form allows the insertion of a stream item and its 3226 * photos in a single transaction, by using {@link ContentProviderOperation} with 3227 * back references to populate the stream item ID in the {@link ContentValues}. 3228 * </dd> 3229 * </dl> 3230 * </p> 3231 * </dd> 3232 * <dt><b>Update</b></dt> 3233 * <dd>Updates can be performed by appending the stream item ID to the 3234 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were 3235 * created by the calling package can be updated.</dd> 3236 * <dt><b>Delete</b></dt> 3237 * <dd>Deletes can be performed by appending the stream item ID to the 3238 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were 3239 * created by the calling package can be deleted.</dd> 3240 * <dt><b>Query</b></dt> 3241 * <dl> 3242 * <dt>Finding all social stream updates for a given contact</dt> 3243 * <dd>By Contact ID: 3244 * <pre> 3245 * Cursor c = getContentResolver().query(Uri.withAppendedPath( 3246 * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), 3247 * Contacts.StreamItems.CONTENT_DIRECTORY), 3248 * null, null, null, null); 3249 * </pre> 3250 * </dd> 3251 * <dd>By lookup key: 3252 * <pre> 3253 * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() 3254 * .appendPath(lookupKey) 3255 * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), 3256 * null, null, null, null); 3257 * </pre> 3258 * </dd> 3259 * <dt>Finding all social stream updates for a given raw contact</dt> 3260 * <dd> 3261 * <pre> 3262 * Cursor c = getContentResolver().query(Uri.withAppendedPath( 3263 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), 3264 * RawContacts.StreamItems.CONTENT_DIRECTORY)), 3265 * null, null, null, null); 3266 * </pre> 3267 * </dd> 3268 * <dt>Querying for a specific stream item by ID</dt> 3269 * <dd> 3270 * <pre> 3271 * Cursor c = getContentResolver().query(ContentUris.withAppendedId( 3272 * StreamItems.CONTENT_URI, streamItemId), 3273 * null, null, null, null); 3274 * </pre> 3275 * </dd> 3276 * </dl> 3277 * 3278 * @deprecated - Do not use. This will not be supported in the future. In the future, 3279 * cursors returned from related queries will be empty. 3280 */ 3281 @Deprecated 3282 public static final class StreamItems implements BaseColumns, StreamItemsColumns { 3283 /** 3284 * This utility class cannot be instantiated 3285 * 3286 * @deprecated - Do not use. This will not be supported in the future. In the future, 3287 * cursors returned from related queries will be empty. 3288 */ 3289 @Deprecated 3290 private StreamItems() { 3291 } 3292 3293 /** 3294 * The content:// style URI for this table, which handles social network stream 3295 * updates for the user's contacts. 3296 * 3297 * @deprecated - Do not use. This will not be supported in the future. In the future, 3298 * cursors returned from related queries will be empty. 3299 */ 3300 @Deprecated 3301 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items"); 3302 3303 /** 3304 * <p> 3305 * A content:// style URI for the photos stored in a sub-table underneath 3306 * stream items. This is only used for inserts, and updates - queries and deletes 3307 * for photos should be performed by appending 3308 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a 3309 * specific stream item. 3310 * </p> 3311 * <p> 3312 * When using this URI, the stream item ID for the photo(s) must be identified 3313 * in the {@link ContentValues} passed in. 3314 * </p> 3315 * 3316 * @deprecated - Do not use. This will not be supported in the future. In the future, 3317 * cursors returned from related queries will be empty. 3318 */ 3319 @Deprecated 3320 public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo"); 3321 3322 /** 3323 * This URI allows the caller to query for the maximum number of stream items 3324 * that will be stored under any single raw contact. 3325 * 3326 * @deprecated - Do not use. This will not be supported in the future. In the future, 3327 * cursors returned from related queries will be empty. 3328 */ 3329 @Deprecated 3330 public static final Uri CONTENT_LIMIT_URI = 3331 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit"); 3332 3333 /** 3334 * The MIME type of a directory of stream items. 3335 * 3336 * @deprecated - Do not use. This will not be supported in the future. In the future, 3337 * cursors returned from related queries will be empty. 3338 */ 3339 @Deprecated 3340 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item"; 3341 3342 /** 3343 * The MIME type of a single stream item. 3344 * 3345 * @deprecated - Do not use. This will not be supported in the future. In the future, 3346 * cursors returned from related queries will be empty. 3347 */ 3348 @Deprecated 3349 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item"; 3350 3351 /** 3352 * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will 3353 * contain this column, with the value indicating the maximum number of 3354 * stream items that will be stored under any single raw contact. 3355 * 3356 * @deprecated - Do not use. This will not be supported in the future. In the future, 3357 * cursors returned from related queries will be empty. 3358 */ 3359 @Deprecated 3360 public static final String MAX_ITEMS = "max_items"; 3361 3362 /** 3363 * <p> 3364 * A sub-directory of a single stream item entry that contains all of its 3365 * photo rows. To access this 3366 * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to 3367 * an individual stream item URI. 3368 * </p> 3369 * <p> 3370 * Access to social stream photos requires additional permissions beyond the read/write 3371 * contact permissions required by the provider. Querying for social stream photos 3372 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating 3373 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. 3374 * </p> 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 class StreamItemPhotos 3381 implements BaseColumns, StreamItemPhotosColumns { 3382 /** 3383 * No public constructor since this is a utility class 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 private StreamItemPhotos() { 3390 } 3391 3392 /** 3393 * The directory twig for this sub-table 3394 * 3395 * @deprecated - Do not use. This will not be supported in the future. In the future, 3396 * cursors returned from related queries will be empty. 3397 */ 3398 @Deprecated 3399 public static final String CONTENT_DIRECTORY = "photo"; 3400 3401 /** 3402 * The MIME type of a directory of stream item photos. 3403 * 3404 * @deprecated - Do not use. This will not be supported in the future. In the future, 3405 * cursors returned from related queries will be empty. 3406 */ 3407 @Deprecated 3408 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo"; 3409 3410 /** 3411 * The MIME type of a single stream item photo. 3412 * 3413 * @deprecated - Do not use. This will not be supported in the future. In the future, 3414 * cursors returned from related queries will be empty. 3415 */ 3416 @Deprecated 3417 public static final String CONTENT_ITEM_TYPE 3418 = "vnd.android.cursor.item/stream_item_photo"; 3419 } 3420 } 3421 3422 /** 3423 * Columns in the StreamItems table. 3424 * 3425 * @see ContactsContract.StreamItems 3426 * @deprecated - Do not use. This will not be supported in the future. In the future, 3427 * cursors returned from related queries will be empty. 3428 */ 3429 @Deprecated 3430 protected interface StreamItemsColumns { 3431 /** 3432 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} 3433 * that this stream item belongs to. 3434 * 3435 * <p>Type: INTEGER</p> 3436 * <p>read-only</p> 3437 * 3438 * @deprecated - Do not use. This will not be supported in the future. In the future, 3439 * cursors returned from related queries will be empty. 3440 */ 3441 @Deprecated 3442 public static final String CONTACT_ID = "contact_id"; 3443 3444 /** 3445 * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} 3446 * that this stream item belongs to. 3447 * 3448 * <p>Type: TEXT</p> 3449 * <p>read-only</p> 3450 * 3451 * @deprecated - Do not use. This will not be supported in the future. In the future, 3452 * cursors returned from related queries will be empty. 3453 */ 3454 @Deprecated 3455 public static final String CONTACT_LOOKUP_KEY = "contact_lookup"; 3456 3457 /** 3458 * A reference to the {@link RawContacts#_ID} 3459 * that this stream item belongs to. 3460 * <p>Type: INTEGER</p> 3461 * 3462 * @deprecated - Do not use. This will not be supported in the future. In the future, 3463 * cursors returned from related queries will be empty. 3464 */ 3465 @Deprecated 3466 public static final String RAW_CONTACT_ID = "raw_contact_id"; 3467 3468 /** 3469 * The package name to use when creating {@link Resources} objects for 3470 * this stream item. This value is only designed for use when building 3471 * user interfaces, and should not be used to infer the owner. 3472 * <P>Type: TEXT</P> 3473 * 3474 * @deprecated - Do not use. This will not be supported in the future. In the future, 3475 * cursors returned from related queries will be empty. 3476 */ 3477 @Deprecated 3478 public static final String RES_PACKAGE = "res_package"; 3479 3480 /** 3481 * The account type to which the raw_contact of this item is associated. See 3482 * {@link RawContacts#ACCOUNT_TYPE} 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 ACCOUNT_TYPE = "account_type"; 3492 3493 /** 3494 * The account name to which the raw_contact of this item is associated. See 3495 * {@link RawContacts#ACCOUNT_NAME} 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 ACCOUNT_NAME = "account_name"; 3505 3506 /** 3507 * The data set within the account that the raw_contact of this row belongs to. This allows 3508 * multiple sync adapters for the same account type to distinguish between 3509 * each others' data. 3510 * {@link RawContacts#DATA_SET} 3511 * 3512 * <P>Type: TEXT</P> 3513 * <p>read-only</p> 3514 * 3515 * @deprecated - Do not use. This will not be supported in the future. In the future, 3516 * cursors returned from related queries will be empty. 3517 */ 3518 @Deprecated 3519 public static final String DATA_SET = "data_set"; 3520 3521 /** 3522 * The source_id of the raw_contact that this row belongs to. 3523 * {@link RawContacts#SOURCE_ID} 3524 * 3525 * <P>Type: TEXT</P> 3526 * <p>read-only</p> 3527 * 3528 * @deprecated - Do not use. This will not be supported in the future. In the future, 3529 * cursors returned from related queries will be empty. 3530 */ 3531 @Deprecated 3532 public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id"; 3533 3534 /** 3535 * The resource name of the icon for the source of the stream item. 3536 * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference 3537 * drawables, the "@drawable/" prefix must be omitted. 3538 * <P>Type: TEXT</P> 3539 * 3540 * @deprecated - Do not use. This will not be supported in the future. In the future, 3541 * cursors returned from related queries will be empty. 3542 */ 3543 @Deprecated 3544 public static final String RES_ICON = "icon"; 3545 3546 /** 3547 * The resource name of the label describing the source of the status update, e.g. "Google 3548 * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only 3549 * reference strings, the "@string/" prefix must be omitted. 3550 * <p>Type: TEXT</p> 3551 * 3552 * @deprecated - Do not use. This will not be supported in the future. In the future, 3553 * cursors returned from related queries will be empty. 3554 */ 3555 @Deprecated 3556 public static final String RES_LABEL = "label"; 3557 3558 /** 3559 * <P> 3560 * The main textual contents of the item. Typically this is content 3561 * that was posted by the source of this stream item, but it can also 3562 * be a textual representation of an action (e.g. ”Checked in at Joe's”). 3563 * This text is displayed to the user and allows formatting and embedded 3564 * resource images via HTML (as parseable via 3565 * {@link android.text.Html#fromHtml}). 3566 * </P> 3567 * <P> 3568 * Long content may be truncated and/or ellipsized - the exact behavior 3569 * is unspecified, but it should not break tags. 3570 * </P> 3571 * <P>Type: TEXT</P> 3572 * 3573 * @deprecated - Do not use. This will not be supported in the future. In the future, 3574 * cursors returned from related queries will be empty. 3575 */ 3576 @Deprecated 3577 public static final String TEXT = "text"; 3578 3579 /** 3580 * The absolute time (milliseconds since epoch) when this stream item was 3581 * inserted/updated. 3582 * <P>Type: NUMBER</P> 3583 * 3584 * @deprecated - Do not use. This will not be supported in the future. In the future, 3585 * cursors returned from related queries will be empty. 3586 */ 3587 @Deprecated 3588 public static final String TIMESTAMP = "timestamp"; 3589 3590 /** 3591 * <P> 3592 * Summary information about the stream item, for example to indicate how 3593 * many people have reshared it, how many have liked it, how many thumbs 3594 * up and/or thumbs down it has, what the original source was, etc. 3595 * </P> 3596 * <P> 3597 * This text is displayed to the user and allows simple formatting via 3598 * HTML, in the same manner as {@link #TEXT} allows. 3599 * </P> 3600 * <P> 3601 * Long content may be truncated and/or ellipsized - the exact behavior 3602 * is unspecified, but it should not break tags. 3603 * </P> 3604 * <P>Type: TEXT</P> 3605 * 3606 * @deprecated - Do not use. This will not be supported in the future. In the future, 3607 * cursors returned from related queries will be empty. 3608 */ 3609 @Deprecated 3610 public static final String COMMENTS = "comments"; 3611 3612 /** 3613 * Generic column for use by sync adapters. 3614 * 3615 * @deprecated - Do not use. This will not be supported in the future. In the future, 3616 * cursors returned from related queries will be empty. 3617 */ 3618 @Deprecated 3619 public static final String SYNC1 = "stream_item_sync1"; 3620 /** 3621 * Generic column for use by sync adapters. 3622 * 3623 * @deprecated - Do not use. This will not be supported in the future. In the future, 3624 * cursors returned from related queries will be empty. 3625 */ 3626 @Deprecated 3627 public static final String SYNC2 = "stream_item_sync2"; 3628 /** 3629 * Generic column for use by sync adapters. 3630 * 3631 * @deprecated - Do not use. This will not be supported in the future. In the future, 3632 * cursors returned from related queries will be empty. 3633 */ 3634 @Deprecated 3635 public static final String SYNC3 = "stream_item_sync3"; 3636 /** 3637 * Generic column for use by sync adapters. 3638 * 3639 * @deprecated - Do not use. This will not be supported in the future. In the future, 3640 * cursors returned from related queries will be empty. 3641 */ 3642 @Deprecated 3643 public static final String SYNC4 = "stream_item_sync4"; 3644 } 3645 3646 /** 3647 * <p> 3648 * Constants for the stream_item_photos table, which contains photos associated with 3649 * social stream updates. 3650 * </p> 3651 * <p> 3652 * Access to social stream photos requires additional permissions beyond the read/write 3653 * contact permissions required by the provider. Querying for social stream photos 3654 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating 3655 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. 3656 * </p> 3657 * <h3>Account check</h3> 3658 * <p> 3659 * The content URIs to the insert, update and delete operations are required to have the account 3660 * information matching that of the owning raw contact as query parameters, namely 3661 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. 3662 * {@link RawContacts#DATA_SET} isn't required. 3663 * </p> 3664 * <h3>Operations</h3> 3665 * <dl> 3666 * <dt><b>Insert</b></dt> 3667 * <dd> 3668 * <p>Social stream photo entries are associated with a social stream item. Photos 3669 * can be inserted into a social stream item in a couple of ways: 3670 * <dl> 3671 * <dt> 3672 * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a 3673 * stream item: 3674 * </dt> 3675 * <dd> 3676 * <pre> 3677 * ContentValues values = new ContentValues(); 3678 * values.put(StreamItemPhotos.SORT_INDEX, 1); 3679 * values.put(StreamItemPhotos.PHOTO, photoData); 3680 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); 3681 * ContentUris.appendId(builder, streamItemId); 3682 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); 3683 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); 3684 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); 3685 * Uri photoUri = getContentResolver().insert(builder.build(), values); 3686 * long photoId = ContentUris.parseId(photoUri); 3687 * </pre> 3688 * </dd> 3689 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> 3690 * <dd> 3691 * <pre> 3692 * ContentValues values = new ContentValues(); 3693 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); 3694 * values.put(StreamItemPhotos.SORT_INDEX, 1); 3695 * values.put(StreamItemPhotos.PHOTO, photoData); 3696 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); 3697 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); 3698 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); 3699 * Uri photoUri = getContentResolver().insert(builder.build(), values); 3700 * long photoId = ContentUris.parseId(photoUri); 3701 * </pre> 3702 * </dd> 3703 * </dl> 3704 * </p> 3705 * </dd> 3706 * <dt><b>Update</b></dt> 3707 * <dd> 3708 * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry, 3709 * identified by both the stream item ID it belongs to and the stream item photo ID. 3710 * This can be specified in two ways. 3711 * <dl> 3712 * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a 3713 * stream item: 3714 * </dt> 3715 * <dd> 3716 * <pre> 3717 * ContentValues values = new ContentValues(); 3718 * values.put(StreamItemPhotos.PHOTO, newPhotoData); 3719 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); 3720 * ContentUris.appendId(builder, streamItemId); 3721 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); 3722 * ContentUris.appendId(builder, streamItemPhotoId); 3723 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); 3724 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); 3725 * getContentResolver().update(builder.build(), values, null, null); 3726 * </pre> 3727 * </dd> 3728 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> 3729 * <dd> 3730 * <pre> 3731 * ContentValues values = new ContentValues(); 3732 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); 3733 * values.put(StreamItemPhotos.PHOTO, newPhotoData); 3734 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); 3735 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); 3736 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); 3737 * getContentResolver().update(builder.build(), values); 3738 * </pre> 3739 * </dd> 3740 * </dl> 3741 * </p> 3742 * </dd> 3743 * <dt><b>Delete</b></dt> 3744 * <dd>Deletes can be made against either a specific photo item in a stream item, or 3745 * against all or a selected subset of photo items under a stream item. 3746 * For example: 3747 * <dl> 3748 * <dt>Deleting a single photo via the 3749 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item: 3750 * </dt> 3751 * <dd> 3752 * <pre> 3753 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); 3754 * ContentUris.appendId(builder, streamItemId); 3755 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); 3756 * ContentUris.appendId(builder, streamItemPhotoId); 3757 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); 3758 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); 3759 * getContentResolver().delete(builder.build(), null, null); 3760 * </pre> 3761 * </dd> 3762 * <dt>Deleting all photos under a stream item</dt> 3763 * <dd> 3764 * <pre> 3765 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); 3766 * ContentUris.appendId(builder, streamItemId); 3767 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); 3768 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); 3769 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); 3770 * getContentResolver().delete(builder.build(), null, null); 3771 * </pre> 3772 * </dd> 3773 * </dl> 3774 * </dd> 3775 * <dt><b>Query</b></dt> 3776 * <dl> 3777 * <dt>Querying for a specific photo in a stream item</dt> 3778 * <dd> 3779 * <pre> 3780 * Cursor c = getContentResolver().query( 3781 * ContentUris.withAppendedId( 3782 * Uri.withAppendedPath( 3783 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) 3784 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), 3785 * streamItemPhotoId), null, null, null, null); 3786 * </pre> 3787 * </dd> 3788 * <dt>Querying for all photos in a stream item</dt> 3789 * <dd> 3790 * <pre> 3791 * Cursor c = getContentResolver().query( 3792 * Uri.withAppendedPath( 3793 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) 3794 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), 3795 * null, null, null, StreamItemPhotos.SORT_INDEX); 3796 * </pre> 3797 * </dl> 3798 * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a 3799 * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID} 3800 * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to 3801 * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as 3802 * an asset file, as follows: 3803 * <pre> 3804 * public InputStream openDisplayPhoto(String photoUri) { 3805 * try { 3806 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r"); 3807 * return fd.createInputStream(); 3808 * } catch (IOException e) { 3809 * return null; 3810 * } 3811 * } 3812 * <pre> 3813 * </dd> 3814 * </dl> 3815 * 3816 * @deprecated - Do not use. This will not be supported in the future. In the future, 3817 * cursors returned from related queries will be empty. 3818 */ 3819 @Deprecated 3820 public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { 3821 /** 3822 * No public constructor since this is a utility class 3823 * 3824 * @deprecated - Do not use. This will not be supported in the future. In the future, 3825 * cursors returned from related queries will be empty. 3826 */ 3827 @Deprecated 3828 private StreamItemPhotos() { 3829 } 3830 3831 /** 3832 * <p> 3833 * The binary representation of the photo. Any size photo can be inserted; 3834 * the provider will resize it appropriately for storage and display. 3835 * </p> 3836 * <p> 3837 * This is only intended for use when inserting or updating a stream item photo. 3838 * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI} 3839 * as an asset file. 3840 * </p> 3841 * <P>Type: BLOB</P> 3842 * 3843 * @deprecated - Do not use. This will not be supported in the future. In the future, 3844 * cursors returned from related queries will be empty. 3845 */ 3846 @Deprecated 3847 public static final String PHOTO = "photo"; 3848 } 3849 3850 /** 3851 * Columns in the StreamItemPhotos table. 3852 * 3853 * @see ContactsContract.StreamItemPhotos 3854 * @deprecated - Do not use. This will not be supported in the future. In the future, 3855 * cursors returned from related queries will be empty. 3856 */ 3857 @Deprecated 3858 protected interface StreamItemPhotosColumns { 3859 /** 3860 * A reference to the {@link StreamItems#_ID} this photo is associated with. 3861 * <P>Type: NUMBER</P> 3862 * 3863 * @deprecated - Do not use. This will not be supported in the future. In the future, 3864 * cursors returned from related queries will be empty. 3865 */ 3866 @Deprecated 3867 public static final String STREAM_ITEM_ID = "stream_item_id"; 3868 3869 /** 3870 * An integer to use for sort order for photos in the stream item. If not 3871 * specified, the {@link StreamItemPhotos#_ID} will be used for sorting. 3872 * <P>Type: NUMBER</P> 3873 * 3874 * @deprecated - Do not use. This will not be supported in the future. In the future, 3875 * cursors returned from related queries will be empty. 3876 */ 3877 @Deprecated 3878 public static final String SORT_INDEX = "sort_index"; 3879 3880 /** 3881 * Photo file ID for the photo. 3882 * See {@link ContactsContract.DisplayPhoto}. 3883 * <P>Type: NUMBER</P> 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 PHOTO_FILE_ID = "photo_file_id"; 3890 3891 /** 3892 * URI for retrieving the photo content, automatically populated. Callers 3893 * may retrieve the photo content by opening this URI as an asset file. 3894 * <P>Type: TEXT</P> 3895 * 3896 * @deprecated - Do not use. This will not be supported in the future. In the future, 3897 * cursors returned from related queries will be empty. 3898 */ 3899 @Deprecated 3900 public static final String PHOTO_URI = "photo_uri"; 3901 3902 /** 3903 * Generic column for use by sync adapters. 3904 * 3905 * @deprecated - Do not use. This will not be supported in the future. In the future, 3906 * cursors returned from related queries will be empty. 3907 */ 3908 @Deprecated 3909 public static final String SYNC1 = "stream_item_photo_sync1"; 3910 /** 3911 * Generic column for use by sync adapters. 3912 * 3913 * @deprecated - Do not use. This will not be supported in the future. In the future, 3914 * cursors returned from related queries will be empty. 3915 */ 3916 @Deprecated 3917 public static final String SYNC2 = "stream_item_photo_sync2"; 3918 /** 3919 * Generic column for use by sync adapters. 3920 * 3921 * @deprecated - Do not use. This will not be supported in the future. In the future, 3922 * cursors returned from related queries will be empty. 3923 */ 3924 @Deprecated 3925 public static final String SYNC3 = "stream_item_photo_sync3"; 3926 /** 3927 * Generic column for use by sync adapters. 3928 * 3929 * @deprecated - Do not use. This will not be supported in the future. In the future, 3930 * cursors returned from related queries will be empty. 3931 */ 3932 @Deprecated 3933 public static final String SYNC4 = "stream_item_photo_sync4"; 3934 } 3935 3936 /** 3937 * <p> 3938 * Constants for the photo files table, which tracks metadata for hi-res photos 3939 * stored in the file system. 3940 * </p> 3941 * 3942 * @hide 3943 */ 3944 public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns { 3945 /** 3946 * No public constructor since this is a utility class 3947 */ 3948 private PhotoFiles() { 3949 } 3950 } 3951 3952 /** 3953 * Columns in the PhotoFiles table. 3954 * 3955 * @see ContactsContract.PhotoFiles 3956 * 3957 * @hide 3958 */ 3959 protected interface PhotoFilesColumns { 3960 3961 /** 3962 * The height, in pixels, of the photo this entry is associated with. 3963 * <P>Type: NUMBER</P> 3964 */ 3965 public static final String HEIGHT = "height"; 3966 3967 /** 3968 * The width, in pixels, of the photo this entry is associated with. 3969 * <P>Type: NUMBER</P> 3970 */ 3971 public static final String WIDTH = "width"; 3972 3973 /** 3974 * The size, in bytes, of the photo stored on disk. 3975 * <P>Type: NUMBER</P> 3976 */ 3977 public static final String FILESIZE = "filesize"; 3978 } 3979 3980 /** 3981 * Columns in the Data table. 3982 * 3983 * @see ContactsContract.Data 3984 */ 3985 protected interface DataColumns { 3986 /** 3987 * The package name to use when creating {@link Resources} objects for 3988 * this data row. This value is only designed for use when building user 3989 * interfaces, and should not be used to infer the owner. 3990 */ 3991 public static final String RES_PACKAGE = "res_package"; 3992 3993 /** 3994 * The MIME type of the item represented by this row. 3995 */ 3996 public static final String MIMETYPE = "mimetype"; 3997 3998 /** 3999 * Hash id on the data fields, used for backup and restore. 4000 * 4001 * @hide 4002 */ 4003 public static final String HASH_ID = "hash_id"; 4004 4005 /** 4006 * A reference to the {@link RawContacts#_ID} 4007 * that this data belongs to. 4008 */ 4009 public static final String RAW_CONTACT_ID = "raw_contact_id"; 4010 4011 /** 4012 * Whether this is the primary entry of its kind for the raw contact it belongs to. 4013 * <P>Type: INTEGER (if set, non-0 means true)</P> 4014 */ 4015 public static final String IS_PRIMARY = "is_primary"; 4016 4017 /** 4018 * Whether this is the primary entry of its kind for the aggregate 4019 * contact it belongs to. Any data record that is "super primary" must 4020 * also be "primary". 4021 * <P>Type: INTEGER (if set, non-0 means true)</P> 4022 */ 4023 public static final String IS_SUPER_PRIMARY = "is_super_primary"; 4024 4025 /** 4026 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or 4027 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. 4028 * <P>Type: INTEGER</P> 4029 */ 4030 public static final String IS_READ_ONLY = "is_read_only"; 4031 4032 /** 4033 * The version of this data record. This is a read-only value. The data column is 4034 * guaranteed to not change without the version going up. This value is monotonically 4035 * increasing. 4036 * <P>Type: INTEGER</P> 4037 */ 4038 public static final String DATA_VERSION = "data_version"; 4039 4040 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4041 public static final String DATA1 = "data1"; 4042 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4043 public static final String DATA2 = "data2"; 4044 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4045 public static final String DATA3 = "data3"; 4046 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4047 public static final String DATA4 = "data4"; 4048 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4049 public static final String DATA5 = "data5"; 4050 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4051 public static final String DATA6 = "data6"; 4052 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4053 public static final String DATA7 = "data7"; 4054 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4055 public static final String DATA8 = "data8"; 4056 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4057 public static final String DATA9 = "data9"; 4058 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4059 public static final String DATA10 = "data10"; 4060 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4061 public static final String DATA11 = "data11"; 4062 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4063 public static final String DATA12 = "data12"; 4064 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4065 public static final String DATA13 = "data13"; 4066 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 4067 public static final String DATA14 = "data14"; 4068 /** 4069 * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, 4070 * this field is used to store BLOBs (binary data). 4071 */ 4072 public static final String DATA15 = "data15"; 4073 4074 /** Generic column for use by sync adapters. */ 4075 public static final String SYNC1 = "data_sync1"; 4076 /** Generic column for use by sync adapters. */ 4077 public static final String SYNC2 = "data_sync2"; 4078 /** Generic column for use by sync adapters. */ 4079 public static final String SYNC3 = "data_sync3"; 4080 /** Generic column for use by sync adapters. */ 4081 public static final String SYNC4 = "data_sync4"; 4082 } 4083 4084 /** 4085 * Columns in the Data_Usage_Stat table 4086 */ 4087 protected interface DataUsageStatColumns { 4088 /** The last time (in milliseconds) this {@link Data} was used. */ 4089 public static final String LAST_TIME_USED = "last_time_used"; 4090 4091 /** The number of times the referenced {@link Data} has been used. */ 4092 public static final String TIMES_USED = "times_used"; 4093 } 4094 4095 /** 4096 * Combines all columns returned by {@link ContactsContract.Data} table queries. 4097 * 4098 * @see ContactsContract.Data 4099 */ 4100 protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, 4101 RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, 4102 ContactStatusColumns, DataUsageStatColumns { 4103 } 4104 4105 /** 4106 * <p> 4107 * Constants for the data table, which contains data points tied to a raw 4108 * contact. Each row of the data table is typically used to store a single 4109 * piece of contact 4110 * information (such as a phone number) and its 4111 * associated metadata (such as whether it is a work or home number). 4112 * </p> 4113 * <h3>Data kinds</h3> 4114 * <p> 4115 * Data is a generic table that can hold any kind of contact data. 4116 * The kind of data stored in a given row is specified by the row's 4117 * {@link #MIMETYPE} value, which determines the meaning of the 4118 * generic columns {@link #DATA1} through 4119 * {@link #DATA15}. 4120 * For example, if the data kind is 4121 * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column 4122 * {@link #DATA1} stores the 4123 * phone number, but if the data kind is 4124 * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} 4125 * stores the email address. 4126 * Sync adapters and applications can introduce their own data kinds. 4127 * </p> 4128 * <p> 4129 * ContactsContract defines a small number of pre-defined data kinds, e.g. 4130 * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a 4131 * convenience, these classes define data kind specific aliases for DATA1 etc. 4132 * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as 4133 * {@link ContactsContract.Data Data.DATA1}. 4134 * </p> 4135 * <p> 4136 * {@link #DATA1} is an indexed column and should be used for the data element that is 4137 * expected to be most frequently used in query selections. For example, in the 4138 * case of a row representing email addresses {@link #DATA1} should probably 4139 * be used for the email address itself, while {@link #DATA2} etc can be 4140 * used for auxiliary information like type of email address. 4141 * <p> 4142 * <p> 4143 * By convention, {@link #DATA15} is used for storing BLOBs (binary data). 4144 * </p> 4145 * <p> 4146 * The sync adapter for a given account type must correctly handle every data type 4147 * used in the corresponding raw contacts. Otherwise it could result in lost or 4148 * corrupted data. 4149 * </p> 4150 * <p> 4151 * Similarly, you should refrain from introducing new kinds of data for an other 4152 * party's account types. For example, if you add a data row for 4153 * "favorite song" to a raw contact owned by a Google account, it will not 4154 * get synced to the server, because the Google sync adapter does not know 4155 * how to handle this data kind. Thus new data kinds are typically 4156 * introduced along with new account types, i.e. new sync adapters. 4157 * </p> 4158 * <h3>Batch operations</h3> 4159 * <p> 4160 * Data rows can be inserted/updated/deleted using the traditional 4161 * {@link ContentResolver#insert}, {@link ContentResolver#update} and 4162 * {@link ContentResolver#delete} methods, however the newer mechanism based 4163 * on a batch of {@link ContentProviderOperation} will prove to be a better 4164 * choice in almost all cases. All operations in a batch are executed in a 4165 * single transaction, which ensures that the phone-side and server-side 4166 * state of a raw contact are always consistent. Also, the batch-based 4167 * approach is far more efficient: not only are the database operations 4168 * faster when executed in a single transaction, but also sending a batch of 4169 * commands to the content provider saves a lot of time on context switching 4170 * between your process and the process in which the content provider runs. 4171 * </p> 4172 * <p> 4173 * The flip side of using batched operations is that a large batch may lock 4174 * up the database for a long time preventing other applications from 4175 * accessing data and potentially causing ANRs ("Application Not Responding" 4176 * dialogs.) 4177 * </p> 4178 * <p> 4179 * To avoid such lockups of the database, make sure to insert "yield points" 4180 * in the batch. A yield point indicates to the content provider that before 4181 * executing the next operation it can commit the changes that have already 4182 * been made, yield to other requests, open another transaction and continue 4183 * processing operations. A yield point will not automatically commit the 4184 * transaction, but only if there is another request waiting on the 4185 * database. Normally a sync adapter should insert a yield point at the 4186 * beginning of each raw contact operation sequence in the batch. See 4187 * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. 4188 * </p> 4189 * <h3>Operations</h3> 4190 * <dl> 4191 * <dt><b>Insert</b></dt> 4192 * <dd> 4193 * <p> 4194 * An individual data row can be inserted using the traditional 4195 * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows 4196 * should always be inserted as a batch. 4197 * </p> 4198 * <p> 4199 * An example of a traditional insert: 4200 * <pre> 4201 * ContentValues values = new ContentValues(); 4202 * values.put(Data.RAW_CONTACT_ID, rawContactId); 4203 * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); 4204 * values.put(Phone.NUMBER, "1-800-GOOG-411"); 4205 * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); 4206 * values.put(Phone.LABEL, "free directory assistance"); 4207 * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); 4208 * </pre> 4209 * <p> 4210 * The same done using ContentProviderOperations: 4211 * <pre> 4212 * ArrayList<ContentProviderOperation> ops = 4213 * new ArrayList<ContentProviderOperation>(); 4214 * 4215 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 4216 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 4217 * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) 4218 * .withValue(Phone.NUMBER, "1-800-GOOG-411") 4219 * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) 4220 * .withValue(Phone.LABEL, "free directory assistance") 4221 * .build()); 4222 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 4223 * </pre> 4224 * </p> 4225 * <dt><b>Update</b></dt> 4226 * <dd> 4227 * <p> 4228 * Just as with insert, update can be done incrementally or as a batch, 4229 * the batch mode being the preferred method: 4230 * <pre> 4231 * ArrayList<ContentProviderOperation> ops = 4232 * new ArrayList<ContentProviderOperation>(); 4233 * 4234 * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) 4235 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) 4236 * .withValue(Email.DATA, "somebody@android.com") 4237 * .build()); 4238 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 4239 * </pre> 4240 * </p> 4241 * </dd> 4242 * <dt><b>Delete</b></dt> 4243 * <dd> 4244 * <p> 4245 * Just as with insert and update, deletion can be done either using the 4246 * {@link ContentResolver#delete} method or using a ContentProviderOperation: 4247 * <pre> 4248 * ArrayList<ContentProviderOperation> ops = 4249 * new ArrayList<ContentProviderOperation>(); 4250 * 4251 * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) 4252 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) 4253 * .build()); 4254 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 4255 * </pre> 4256 * </p> 4257 * </dd> 4258 * <dt><b>Query</b></dt> 4259 * <dd> 4260 * <p> 4261 * <dl> 4262 * <dt>Finding all Data of a given type for a given contact</dt> 4263 * <dd> 4264 * <pre> 4265 * Cursor c = getContentResolver().query(Data.CONTENT_URI, 4266 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, 4267 * Data.CONTACT_ID + "=?" + " AND " 4268 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", 4269 * new String[] {String.valueOf(contactId)}, null); 4270 * </pre> 4271 * </p> 4272 * <p> 4273 * </dd> 4274 * <dt>Finding all Data of a given type for a given raw contact</dt> 4275 * <dd> 4276 * <pre> 4277 * Cursor c = getContentResolver().query(Data.CONTENT_URI, 4278 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, 4279 * Data.RAW_CONTACT_ID + "=?" + " AND " 4280 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", 4281 * new String[] {String.valueOf(rawContactId)}, null); 4282 * </pre> 4283 * </dd> 4284 * <dt>Finding all Data for a given raw contact</dt> 4285 * <dd> 4286 * Most sync adapters will want to read all data rows for a raw contact 4287 * along with the raw contact itself. For that you should use the 4288 * {@link RawContactsEntity}. See also {@link RawContacts}. 4289 * </dd> 4290 * </dl> 4291 * </p> 4292 * </dd> 4293 * </dl> 4294 * <h2>Columns</h2> 4295 * <p> 4296 * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you 4297 * should explicitly specify a projection to only those columns that you need. 4298 * </p> 4299 * <table class="jd-sumtable"> 4300 * <tr> 4301 * <th colspan='4'>Data</th> 4302 * </tr> 4303 * <tr> 4304 * <td style="width: 7em;">long</td> 4305 * <td style="width: 20em;">{@link #_ID}</td> 4306 * <td style="width: 5em;">read-only</td> 4307 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words, 4308 * it would be a bad idea to delete and reinsert a data row. A sync adapter should 4309 * always do an update instead.</td> 4310 * </tr> 4311 * <tr> 4312 * <td>String</td> 4313 * <td>{@link #MIMETYPE}</td> 4314 * <td>read/write-once</td> 4315 * <td> 4316 * <p>The MIME type of the item represented by this row. Examples of common 4317 * MIME types are: 4318 * <ul> 4319 * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> 4320 * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> 4321 * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> 4322 * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> 4323 * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> 4324 * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> 4325 * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> 4326 * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> 4327 * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> 4328 * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> 4329 * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> 4330 * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> 4331 * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> 4332 * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> 4333 * </ul> 4334 * </p> 4335 * </td> 4336 * </tr> 4337 * <tr> 4338 * <td>long</td> 4339 * <td>{@link #RAW_CONTACT_ID}</td> 4340 * <td>read/write-once</td> 4341 * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td> 4342 * </tr> 4343 * <tr> 4344 * <td>int</td> 4345 * <td>{@link #IS_PRIMARY}</td> 4346 * <td>read/write</td> 4347 * <td>Whether this is the primary entry of its kind for the raw contact it belongs to. 4348 * "1" if true, "0" if false. 4349 * </td> 4350 * </tr> 4351 * <tr> 4352 * <td>int</td> 4353 * <td>{@link #IS_SUPER_PRIMARY}</td> 4354 * <td>read/write</td> 4355 * <td>Whether this is the primary entry of its kind for the aggregate 4356 * contact it belongs to. Any data record that is "super primary" must 4357 * also be "primary". For example, the super-primary entry may be 4358 * interpreted as the default contact value of its kind (for example, 4359 * the default phone number to use for the contact).</td> 4360 * </tr> 4361 * <tr> 4362 * <td>int</td> 4363 * <td>{@link #DATA_VERSION}</td> 4364 * <td>read-only</td> 4365 * <td>The version of this data record. Whenever the data row changes 4366 * the version goes up. This value is monotonically increasing.</td> 4367 * </tr> 4368 * <tr> 4369 * <td>Any type</td> 4370 * <td> 4371 * {@link #DATA1}<br> 4372 * {@link #DATA2}<br> 4373 * {@link #DATA3}<br> 4374 * {@link #DATA4}<br> 4375 * {@link #DATA5}<br> 4376 * {@link #DATA6}<br> 4377 * {@link #DATA7}<br> 4378 * {@link #DATA8}<br> 4379 * {@link #DATA9}<br> 4380 * {@link #DATA10}<br> 4381 * {@link #DATA11}<br> 4382 * {@link #DATA12}<br> 4383 * {@link #DATA13}<br> 4384 * {@link #DATA14}<br> 4385 * {@link #DATA15} 4386 * </td> 4387 * <td>read/write</td> 4388 * <td> 4389 * <p> 4390 * Generic data columns. The meaning of each column is determined by the 4391 * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing 4392 * BLOBs (binary data). 4393 * </p> 4394 * <p> 4395 * Data columns whose meaning is not explicitly defined for a given MIMETYPE 4396 * should not be used. There is no guarantee that any sync adapter will 4397 * preserve them. Sync adapters themselves should not use such columns either, 4398 * but should instead use {@link #SYNC1}-{@link #SYNC4}. 4399 * </p> 4400 * </td> 4401 * </tr> 4402 * <tr> 4403 * <td>Any type</td> 4404 * <td> 4405 * {@link #SYNC1}<br> 4406 * {@link #SYNC2}<br> 4407 * {@link #SYNC3}<br> 4408 * {@link #SYNC4} 4409 * </td> 4410 * <td>read/write</td> 4411 * <td>Generic columns for use by sync adapters. For example, a Photo row 4412 * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) 4413 * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> 4414 * </tr> 4415 * </table> 4416 * 4417 * <p> 4418 * Some columns from the most recent associated status update are also available 4419 * through an implicit join. 4420 * </p> 4421 * <table class="jd-sumtable"> 4422 * <tr> 4423 * <th colspan='4'>Join with {@link StatusUpdates}</th> 4424 * </tr> 4425 * <tr> 4426 * <td style="width: 7em;">int</td> 4427 * <td style="width: 20em;">{@link #PRESENCE}</td> 4428 * <td style="width: 5em;">read-only</td> 4429 * <td>IM presence status linked to this data row. Compare with 4430 * {@link #CONTACT_PRESENCE}, which contains the contact's presence across 4431 * all IM rows. See {@link StatusUpdates} for individual status definitions. 4432 * The provider may choose not to store this value 4433 * in persistent storage. The expectation is that presence status will be 4434 * updated on a regular basis. 4435 * </td> 4436 * </tr> 4437 * <tr> 4438 * <td>String</td> 4439 * <td>{@link #STATUS}</td> 4440 * <td>read-only</td> 4441 * <td>Latest status update linked with this data row.</td> 4442 * </tr> 4443 * <tr> 4444 * <td>long</td> 4445 * <td>{@link #STATUS_TIMESTAMP}</td> 4446 * <td>read-only</td> 4447 * <td>The absolute time in milliseconds when the latest status was 4448 * inserted/updated for this data row.</td> 4449 * </tr> 4450 * <tr> 4451 * <td>String</td> 4452 * <td>{@link #STATUS_RES_PACKAGE}</td> 4453 * <td>read-only</td> 4454 * <td>The package containing resources for this status: label and icon.</td> 4455 * </tr> 4456 * <tr> 4457 * <td>long</td> 4458 * <td>{@link #STATUS_LABEL}</td> 4459 * <td>read-only</td> 4460 * <td>The resource ID of the label describing the source of status update linked 4461 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 4462 * </tr> 4463 * <tr> 4464 * <td>long</td> 4465 * <td>{@link #STATUS_ICON}</td> 4466 * <td>read-only</td> 4467 * <td>The resource ID of the icon for the source of the status update linked 4468 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 4469 * </tr> 4470 * </table> 4471 * 4472 * <p> 4473 * Some columns from the associated raw contact are also available through an 4474 * implicit join. The other columns are excluded as uninteresting in this 4475 * context. 4476 * </p> 4477 * 4478 * <table class="jd-sumtable"> 4479 * <tr> 4480 * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> 4481 * </tr> 4482 * <tr> 4483 * <td style="width: 7em;">long</td> 4484 * <td style="width: 20em;">{@link #CONTACT_ID}</td> 4485 * <td style="width: 5em;">read-only</td> 4486 * <td>The id of the row in the {@link Contacts} table that this data belongs 4487 * to.</td> 4488 * </tr> 4489 * <tr> 4490 * <td>int</td> 4491 * <td>{@link #AGGREGATION_MODE}</td> 4492 * <td>read-only</td> 4493 * <td>See {@link RawContacts}.</td> 4494 * </tr> 4495 * <tr> 4496 * <td>int</td> 4497 * <td>{@link #DELETED}</td> 4498 * <td>read-only</td> 4499 * <td>See {@link RawContacts}.</td> 4500 * </tr> 4501 * </table> 4502 * 4503 * <p> 4504 * The ID column for the associated aggregated contact table 4505 * {@link ContactsContract.Contacts} is available 4506 * via the implicit join to the {@link RawContacts} table, see above. 4507 * The remaining columns from this table are also 4508 * available, through an implicit join. This 4509 * facilitates lookup by 4510 * the value of a single data element, such as the email address. 4511 * </p> 4512 * 4513 * <table class="jd-sumtable"> 4514 * <tr> 4515 * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> 4516 * </tr> 4517 * <tr> 4518 * <td style="width: 7em;">String</td> 4519 * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> 4520 * <td style="width: 5em;">read-only</td> 4521 * <td>See {@link ContactsContract.Contacts}</td> 4522 * </tr> 4523 * <tr> 4524 * <td>String</td> 4525 * <td>{@link #DISPLAY_NAME}</td> 4526 * <td>read-only</td> 4527 * <td>See {@link ContactsContract.Contacts}</td> 4528 * </tr> 4529 * <tr> 4530 * <td>long</td> 4531 * <td>{@link #PHOTO_ID}</td> 4532 * <td>read-only</td> 4533 * <td>See {@link ContactsContract.Contacts}.</td> 4534 * </tr> 4535 * <tr> 4536 * <td>int</td> 4537 * <td>{@link #IN_VISIBLE_GROUP}</td> 4538 * <td>read-only</td> 4539 * <td>See {@link ContactsContract.Contacts}.</td> 4540 * </tr> 4541 * <tr> 4542 * <td>int</td> 4543 * <td>{@link #HAS_PHONE_NUMBER}</td> 4544 * <td>read-only</td> 4545 * <td>See {@link ContactsContract.Contacts}.</td> 4546 * </tr> 4547 * <tr> 4548 * <td>int</td> 4549 * <td>{@link #TIMES_CONTACTED}</td> 4550 * <td>read-only</td> 4551 * <td>See {@link ContactsContract.Contacts}.</td> 4552 * </tr> 4553 * <tr> 4554 * <td>long</td> 4555 * <td>{@link #LAST_TIME_CONTACTED}</td> 4556 * <td>read-only</td> 4557 * <td>See {@link ContactsContract.Contacts}.</td> 4558 * </tr> 4559 * <tr> 4560 * <td>int</td> 4561 * <td>{@link #STARRED}</td> 4562 * <td>read-only</td> 4563 * <td>See {@link ContactsContract.Contacts}.</td> 4564 * </tr> 4565 * <tr> 4566 * <td>String</td> 4567 * <td>{@link #CUSTOM_RINGTONE}</td> 4568 * <td>read-only</td> 4569 * <td>See {@link ContactsContract.Contacts}.</td> 4570 * </tr> 4571 * <tr> 4572 * <td>int</td> 4573 * <td>{@link #SEND_TO_VOICEMAIL}</td> 4574 * <td>read-only</td> 4575 * <td>See {@link ContactsContract.Contacts}.</td> 4576 * </tr> 4577 * <tr> 4578 * <td>int</td> 4579 * <td>{@link #CONTACT_PRESENCE}</td> 4580 * <td>read-only</td> 4581 * <td>See {@link ContactsContract.Contacts}.</td> 4582 * </tr> 4583 * <tr> 4584 * <td>String</td> 4585 * <td>{@link #CONTACT_STATUS}</td> 4586 * <td>read-only</td> 4587 * <td>See {@link ContactsContract.Contacts}.</td> 4588 * </tr> 4589 * <tr> 4590 * <td>long</td> 4591 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> 4592 * <td>read-only</td> 4593 * <td>See {@link ContactsContract.Contacts}.</td> 4594 * </tr> 4595 * <tr> 4596 * <td>String</td> 4597 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> 4598 * <td>read-only</td> 4599 * <td>See {@link ContactsContract.Contacts}.</td> 4600 * </tr> 4601 * <tr> 4602 * <td>long</td> 4603 * <td>{@link #CONTACT_STATUS_LABEL}</td> 4604 * <td>read-only</td> 4605 * <td>See {@link ContactsContract.Contacts}.</td> 4606 * </tr> 4607 * <tr> 4608 * <td>long</td> 4609 * <td>{@link #CONTACT_STATUS_ICON}</td> 4610 * <td>read-only</td> 4611 * <td>See {@link ContactsContract.Contacts}.</td> 4612 * </tr> 4613 * </table> 4614 */ 4615 public final static class Data implements DataColumnsWithJoins, ContactCounts { 4616 /** 4617 * This utility class cannot be instantiated 4618 */ 4619 private Data() {} 4620 4621 /** 4622 * The content:// style URI for this table, which requests a directory 4623 * of data rows matching the selection criteria. 4624 */ 4625 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); 4626 4627 /** 4628 * A boolean parameter for {@link Data#CONTENT_URI}. 4629 * This specifies whether or not the returned data items should be filtered to show 4630 * data items belonging to visible contacts only. 4631 */ 4632 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; 4633 4634 /** 4635 * The MIME type of the results from {@link #CONTENT_URI}. 4636 */ 4637 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; 4638 4639 /** 4640 * <p> 4641 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} 4642 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} 4643 * entry of the given {@link ContactsContract.Data} entry. 4644 * </p> 4645 * <p> 4646 * Returns the Uri for the contact in the first entry returned by 4647 * {@link ContentResolver#query(Uri, String[], String, String[], String)} 4648 * for the provided {@code dataUri}. If the query returns null or empty 4649 * results, silently returns null. 4650 * </p> 4651 */ 4652 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { 4653 final Cursor cursor = resolver.query(dataUri, new String[] { 4654 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY 4655 }, null, null, null); 4656 4657 Uri lookupUri = null; 4658 try { 4659 if (cursor != null && cursor.moveToFirst()) { 4660 final long contactId = cursor.getLong(0); 4661 final String lookupKey = cursor.getString(1); 4662 return Contacts.getLookupUri(contactId, lookupKey); 4663 } 4664 } finally { 4665 if (cursor != null) cursor.close(); 4666 } 4667 return lookupUri; 4668 } 4669 } 4670 4671 /** 4672 * <p> 4673 * Constants for the raw contacts entities table, which can be thought of as 4674 * an outer join of the raw_contacts table with the data table. It is a strictly 4675 * read-only table. 4676 * </p> 4677 * <p> 4678 * If a raw contact has data rows, the RawContactsEntity cursor will contain 4679 * a one row for each data row. If the raw contact has no data rows, the 4680 * cursor will still contain one row with the raw contact-level information 4681 * and nulls for data columns. 4682 * 4683 * <pre> 4684 * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); 4685 * Cursor c = getContentResolver().query(entityUri, 4686 * new String[]{ 4687 * RawContactsEntity.SOURCE_ID, 4688 * RawContactsEntity.DATA_ID, 4689 * RawContactsEntity.MIMETYPE, 4690 * RawContactsEntity.DATA1 4691 * }, null, null, null); 4692 * try { 4693 * while (c.moveToNext()) { 4694 * String sourceId = c.getString(0); 4695 * if (!c.isNull(1)) { 4696 * String mimeType = c.getString(2); 4697 * String data = c.getString(3); 4698 * ... 4699 * } 4700 * } 4701 * } finally { 4702 * c.close(); 4703 * } 4704 * </pre> 4705 * 4706 * <h3>Columns</h3> 4707 * RawContactsEntity has a combination of RawContact and Data columns. 4708 * 4709 * <table class="jd-sumtable"> 4710 * <tr> 4711 * <th colspan='4'>RawContacts</th> 4712 * </tr> 4713 * <tr> 4714 * <td style="width: 7em;">long</td> 4715 * <td style="width: 20em;">{@link #_ID}</td> 4716 * <td style="width: 5em;">read-only</td> 4717 * <td>Raw contact row ID. See {@link RawContacts}.</td> 4718 * </tr> 4719 * <tr> 4720 * <td>long</td> 4721 * <td>{@link #CONTACT_ID}</td> 4722 * <td>read-only</td> 4723 * <td>See {@link RawContacts}.</td> 4724 * </tr> 4725 * <tr> 4726 * <td>int</td> 4727 * <td>{@link #AGGREGATION_MODE}</td> 4728 * <td>read-only</td> 4729 * <td>See {@link RawContacts}.</td> 4730 * </tr> 4731 * <tr> 4732 * <td>int</td> 4733 * <td>{@link #DELETED}</td> 4734 * <td>read-only</td> 4735 * <td>See {@link RawContacts}.</td> 4736 * </tr> 4737 * </table> 4738 * 4739 * <table class="jd-sumtable"> 4740 * <tr> 4741 * <th colspan='4'>Data</th> 4742 * </tr> 4743 * <tr> 4744 * <td style="width: 7em;">long</td> 4745 * <td style="width: 20em;">{@link #DATA_ID}</td> 4746 * <td style="width: 5em;">read-only</td> 4747 * <td>Data row ID. It will be null if the raw contact has no data rows.</td> 4748 * </tr> 4749 * <tr> 4750 * <td>String</td> 4751 * <td>{@link #MIMETYPE}</td> 4752 * <td>read-only</td> 4753 * <td>See {@link ContactsContract.Data}.</td> 4754 * </tr> 4755 * <tr> 4756 * <td>int</td> 4757 * <td>{@link #IS_PRIMARY}</td> 4758 * <td>read-only</td> 4759 * <td>See {@link ContactsContract.Data}.</td> 4760 * </tr> 4761 * <tr> 4762 * <td>int</td> 4763 * <td>{@link #IS_SUPER_PRIMARY}</td> 4764 * <td>read-only</td> 4765 * <td>See {@link ContactsContract.Data}.</td> 4766 * </tr> 4767 * <tr> 4768 * <td>int</td> 4769 * <td>{@link #DATA_VERSION}</td> 4770 * <td>read-only</td> 4771 * <td>See {@link ContactsContract.Data}.</td> 4772 * </tr> 4773 * <tr> 4774 * <td>Any type</td> 4775 * <td> 4776 * {@link #DATA1}<br> 4777 * {@link #DATA2}<br> 4778 * {@link #DATA3}<br> 4779 * {@link #DATA4}<br> 4780 * {@link #DATA5}<br> 4781 * {@link #DATA6}<br> 4782 * {@link #DATA7}<br> 4783 * {@link #DATA8}<br> 4784 * {@link #DATA9}<br> 4785 * {@link #DATA10}<br> 4786 * {@link #DATA11}<br> 4787 * {@link #DATA12}<br> 4788 * {@link #DATA13}<br> 4789 * {@link #DATA14}<br> 4790 * {@link #DATA15} 4791 * </td> 4792 * <td>read-only</td> 4793 * <td>See {@link ContactsContract.Data}.</td> 4794 * </tr> 4795 * <tr> 4796 * <td>Any type</td> 4797 * <td> 4798 * {@link #SYNC1}<br> 4799 * {@link #SYNC2}<br> 4800 * {@link #SYNC3}<br> 4801 * {@link #SYNC4} 4802 * </td> 4803 * <td>read-only</td> 4804 * <td>See {@link ContactsContract.Data}.</td> 4805 * </tr> 4806 * </table> 4807 */ 4808 public final static class RawContactsEntity 4809 implements BaseColumns, DataColumns, RawContactsColumns { 4810 /** 4811 * This utility class cannot be instantiated 4812 */ 4813 private RawContactsEntity() {} 4814 4815 /** 4816 * The content:// style URI for this table 4817 */ 4818 public static final Uri CONTENT_URI = 4819 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); 4820 4821 /** 4822 * The content:// style URI for this table, specific to the user's profile. 4823 */ 4824 public static final Uri PROFILE_CONTENT_URI = 4825 Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities"); 4826 4827 /** 4828 * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. 4829 */ 4830 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; 4831 4832 /** 4833 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward 4834 * Data.CONTENT_URI contains only exportable data. 4835 * 4836 * This flag is useful (currently) only for vCard exporter in Contacts app, which 4837 * needs to exclude "un-exportable" data from available data to export, while 4838 * Contacts app itself has priviledge to access all data including "un-expotable" 4839 * ones and providers return all of them regardless of the callers' intention. 4840 * <P>Type: INTEGER</p> 4841 * 4842 * @hide Maybe available only in Eclair and not really ready for public use. 4843 * TODO: remove, or implement this feature completely. As of now (Eclair), 4844 * we only use this flag in queryEntities(), not query(). 4845 */ 4846 public static final String FOR_EXPORT_ONLY = "for_export_only"; 4847 4848 /** 4849 * The ID of the data column. The value will be null if this raw contact has no data rows. 4850 * <P>Type: INTEGER</P> 4851 */ 4852 public static final String DATA_ID = "data_id"; 4853 } 4854 4855 /** 4856 * @see PhoneLookup 4857 */ 4858 protected interface PhoneLookupColumns { 4859 /** 4860 * The phone number as the user entered it. 4861 * <P>Type: TEXT</P> 4862 */ 4863 public static final String NUMBER = "number"; 4864 4865 /** 4866 * The type of phone number, for example Home or Work. 4867 * <P>Type: INTEGER</P> 4868 */ 4869 public static final String TYPE = "type"; 4870 4871 /** 4872 * The user defined label for the phone number. 4873 * <P>Type: TEXT</P> 4874 */ 4875 public static final String LABEL = "label"; 4876 4877 /** 4878 * The phone number's E164 representation. 4879 * <P>Type: TEXT</P> 4880 */ 4881 public static final String NORMALIZED_NUMBER = "normalized_number"; 4882 } 4883 4884 /** 4885 * A table that represents the result of looking up a phone number, for 4886 * example for caller ID. To perform a lookup you must append the number you 4887 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly 4888 * optimized. 4889 * <pre> 4890 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); 4891 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... 4892 * </pre> 4893 * 4894 * <h3>Columns</h3> 4895 * 4896 * <table class="jd-sumtable"> 4897 * <tr> 4898 * <th colspan='4'>PhoneLookup</th> 4899 * </tr> 4900 * <tr> 4901 * <td>String</td> 4902 * <td>{@link #NUMBER}</td> 4903 * <td>read-only</td> 4904 * <td>Phone number.</td> 4905 * </tr> 4906 * <tr> 4907 * <td>String</td> 4908 * <td>{@link #TYPE}</td> 4909 * <td>read-only</td> 4910 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> 4911 * </tr> 4912 * <tr> 4913 * <td>String</td> 4914 * <td>{@link #LABEL}</td> 4915 * <td>read-only</td> 4916 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> 4917 * </tr> 4918 * </table> 4919 * <p> 4920 * Columns from the Contacts table are also available through a join. 4921 * </p> 4922 * <table class="jd-sumtable"> 4923 * <tr> 4924 * <th colspan='4'>Join with {@link Contacts}</th> 4925 * </tr> 4926 * <tr> 4927 * <td>long</td> 4928 * <td>{@link #_ID}</td> 4929 * <td>read-only</td> 4930 * <td>Contact ID.</td> 4931 * </tr> 4932 * <tr> 4933 * <td>String</td> 4934 * <td>{@link #LOOKUP_KEY}</td> 4935 * <td>read-only</td> 4936 * <td>See {@link ContactsContract.Contacts}</td> 4937 * </tr> 4938 * <tr> 4939 * <td>String</td> 4940 * <td>{@link #DISPLAY_NAME}</td> 4941 * <td>read-only</td> 4942 * <td>See {@link ContactsContract.Contacts}</td> 4943 * </tr> 4944 * <tr> 4945 * <td>long</td> 4946 * <td>{@link #PHOTO_ID}</td> 4947 * <td>read-only</td> 4948 * <td>See {@link ContactsContract.Contacts}.</td> 4949 * </tr> 4950 * <tr> 4951 * <td>int</td> 4952 * <td>{@link #IN_VISIBLE_GROUP}</td> 4953 * <td>read-only</td> 4954 * <td>See {@link ContactsContract.Contacts}.</td> 4955 * </tr> 4956 * <tr> 4957 * <td>int</td> 4958 * <td>{@link #HAS_PHONE_NUMBER}</td> 4959 * <td>read-only</td> 4960 * <td>See {@link ContactsContract.Contacts}.</td> 4961 * </tr> 4962 * <tr> 4963 * <td>int</td> 4964 * <td>{@link #TIMES_CONTACTED}</td> 4965 * <td>read-only</td> 4966 * <td>See {@link ContactsContract.Contacts}.</td> 4967 * </tr> 4968 * <tr> 4969 * <td>long</td> 4970 * <td>{@link #LAST_TIME_CONTACTED}</td> 4971 * <td>read-only</td> 4972 * <td>See {@link ContactsContract.Contacts}.</td> 4973 * </tr> 4974 * <tr> 4975 * <td>int</td> 4976 * <td>{@link #STARRED}</td> 4977 * <td>read-only</td> 4978 * <td>See {@link ContactsContract.Contacts}.</td> 4979 * </tr> 4980 * <tr> 4981 * <td>String</td> 4982 * <td>{@link #CUSTOM_RINGTONE}</td> 4983 * <td>read-only</td> 4984 * <td>See {@link ContactsContract.Contacts}.</td> 4985 * </tr> 4986 * <tr> 4987 * <td>int</td> 4988 * <td>{@link #SEND_TO_VOICEMAIL}</td> 4989 * <td>read-only</td> 4990 * <td>See {@link ContactsContract.Contacts}.</td> 4991 * </tr> 4992 * </table> 4993 */ 4994 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, 4995 ContactsColumns, ContactOptionsColumns { 4996 /** 4997 * This utility class cannot be instantiated 4998 */ 4999 private PhoneLookup() {} 5000 5001 /** 5002 * The content:// style URI for this table. Append the phone number you want to lookup 5003 * to this URI and query it to perform a lookup. For example: 5004 * <pre> 5005 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, 5006 * Uri.encode(phoneNumber)); 5007 * </pre> 5008 */ 5009 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, 5010 "phone_lookup"); 5011 5012 /** 5013 * URI used for the "enterprise caller-id". 5014 * 5015 * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same 5016 * columns. If the device has no corp profile that is linked to the current profile, it 5017 * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile 5018 * linked to the current profile, it first queries against the personal contact database, 5019 * and if no matching contacts are found there, then queries against the 5020 * corp contacts database. 5021 * <p> 5022 * If a result is from the corp profile, it makes the following changes to the data: 5023 * <ul> 5024 * <li> 5025 * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special 5026 * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to 5027 * load pictures from them. 5028 * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them. 5029 * </li> 5030 * <li> 5031 * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact 5032 * is from the corp profile, use 5033 * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. 5034 * </li> 5035 * </ul> 5036 * <p> 5037 * This URI does NOT support selection nor order-by. 5038 * 5039 * <pre> 5040 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, 5041 * Uri.encode(phoneNumber)); 5042 * </pre> 5043 */ 5044 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, 5045 "phone_lookup_enterprise"); 5046 5047 /** 5048 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. 5049 * 5050 * @hide 5051 */ 5052 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; 5053 5054 /** 5055 * If this boolean parameter is set to true, then the appended query is treated as a 5056 * SIP address and the lookup will be performed against SIP addresses in the user's 5057 * contacts. 5058 */ 5059 public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; 5060 } 5061 5062 /** 5063 * Additional data mixed in with {@link StatusColumns} to link 5064 * back to specific {@link ContactsContract.Data#_ID} entries. 5065 * 5066 * @see StatusUpdates 5067 */ 5068 protected interface PresenceColumns { 5069 5070 /** 5071 * Reference to the {@link Data#_ID} entry that owns this presence. 5072 * <P>Type: INTEGER</P> 5073 */ 5074 public static final String DATA_ID = "presence_data_id"; 5075 5076 /** 5077 * See {@link CommonDataKinds.Im} for a list of defined protocol constants. 5078 * <p>Type: NUMBER</p> 5079 */ 5080 public static final String PROTOCOL = "protocol"; 5081 5082 /** 5083 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 5084 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 5085 * omitted if {@link #PROTOCOL} value is not 5086 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. 5087 * 5088 * <p>Type: NUMBER</p> 5089 */ 5090 public static final String CUSTOM_PROTOCOL = "custom_protocol"; 5091 5092 /** 5093 * The IM handle the presence item is for. The handle is scoped to 5094 * {@link #PROTOCOL}. 5095 * <P>Type: TEXT</P> 5096 */ 5097 public static final String IM_HANDLE = "im_handle"; 5098 5099 /** 5100 * The IM account for the local user that the presence data came from. 5101 * <P>Type: TEXT</P> 5102 */ 5103 public static final String IM_ACCOUNT = "im_account"; 5104 } 5105 5106 /** 5107 * <p> 5108 * A status update is linked to a {@link ContactsContract.Data} row and captures 5109 * the user's latest status update via the corresponding source, e.g. 5110 * "Having lunch" via "Google Talk". 5111 * </p> 5112 * <p> 5113 * There are two ways a status update can be inserted: by explicitly linking 5114 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row 5115 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 5116 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use 5117 * either. 5118 * </p> 5119 * <p> 5120 * Inserting or updating a status update for the user's profile requires either using 5121 * the {@link #DATA_ID} to identify the data row to attach the update to, or 5122 * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the 5123 * profile. 5124 * </p> 5125 * <p> 5126 * You cannot use {@link ContentResolver#update} to change a status, but 5127 * {@link ContentResolver#insert} will replace the latests status if it already 5128 * exists. 5129 * </p> 5130 * <p> 5131 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses 5132 * for multiple contacts at once. 5133 * </p> 5134 * 5135 * <h3>Columns</h3> 5136 * <table class="jd-sumtable"> 5137 * <tr> 5138 * <th colspan='4'>StatusUpdates</th> 5139 * </tr> 5140 * <tr> 5141 * <td>long</td> 5142 * <td>{@link #DATA_ID}</td> 5143 * <td>read/write</td> 5144 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this 5145 * field is <i>not</i> specified, the provider will attempt to find a data row 5146 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 5147 * {@link #IM_HANDLE} columns. 5148 * </td> 5149 * </tr> 5150 * <tr> 5151 * <td>long</td> 5152 * <td>{@link #PROTOCOL}</td> 5153 * <td>read/write</td> 5154 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> 5155 * </tr> 5156 * <tr> 5157 * <td>String</td> 5158 * <td>{@link #CUSTOM_PROTOCOL}</td> 5159 * <td>read/write</td> 5160 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 5161 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 5162 * omitted if {@link #PROTOCOL} value is not 5163 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> 5164 * </tr> 5165 * <tr> 5166 * <td>String</td> 5167 * <td>{@link #IM_HANDLE}</td> 5168 * <td>read/write</td> 5169 * <td> The IM handle the presence item is for. The handle is scoped to 5170 * {@link #PROTOCOL}.</td> 5171 * </tr> 5172 * <tr> 5173 * <td>String</td> 5174 * <td>{@link #IM_ACCOUNT}</td> 5175 * <td>read/write</td> 5176 * <td>The IM account for the local user that the presence data came from.</td> 5177 * </tr> 5178 * <tr> 5179 * <td>int</td> 5180 * <td>{@link #PRESENCE}</td> 5181 * <td>read/write</td> 5182 * <td>Contact IM presence status. The allowed values are: 5183 * <p> 5184 * <ul> 5185 * <li>{@link #OFFLINE}</li> 5186 * <li>{@link #INVISIBLE}</li> 5187 * <li>{@link #AWAY}</li> 5188 * <li>{@link #IDLE}</li> 5189 * <li>{@link #DO_NOT_DISTURB}</li> 5190 * <li>{@link #AVAILABLE}</li> 5191 * </ul> 5192 * </p> 5193 * <p> 5194 * Since presence status is inherently volatile, the content provider 5195 * may choose not to store this field in long-term storage. 5196 * </p> 5197 * </td> 5198 * </tr> 5199 * <tr> 5200 * <td>int</td> 5201 * <td>{@link #CHAT_CAPABILITY}</td> 5202 * <td>read/write</td> 5203 * <td>Contact IM chat compatibility value. The allowed values combinations of the following 5204 * flags. If None of these flags is set, the device can only do text messaging. 5205 * <p> 5206 * <ul> 5207 * <li>{@link #CAPABILITY_HAS_VIDEO}</li> 5208 * <li>{@link #CAPABILITY_HAS_VOICE}</li> 5209 * <li>{@link #CAPABILITY_HAS_CAMERA}</li> 5210 * </ul> 5211 * </p> 5212 * <p> 5213 * Since chat compatibility is inherently volatile as the contact's availability moves from 5214 * one device to another, the content provider may choose not to store this field in long-term 5215 * storage. 5216 * </p> 5217 * </td> 5218 * </tr> 5219 * <tr> 5220 * <td>String</td> 5221 * <td>{@link #STATUS}</td> 5222 * <td>read/write</td> 5223 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> 5224 * </tr> 5225 * <tr> 5226 * <td>long</td> 5227 * <td>{@link #STATUS_TIMESTAMP}</td> 5228 * <td>read/write</td> 5229 * <td>The absolute time in milliseconds when the status was 5230 * entered by the user. If this value is not provided, the provider will follow 5231 * this logic: if there was no prior status update, the value will be left as null. 5232 * If there was a prior status update, the provider will default this field 5233 * to the current time.</td> 5234 * </tr> 5235 * <tr> 5236 * <td>String</td> 5237 * <td>{@link #STATUS_RES_PACKAGE}</td> 5238 * <td>read/write</td> 5239 * <td> The package containing resources for this status: label and icon.</td> 5240 * </tr> 5241 * <tr> 5242 * <td>long</td> 5243 * <td>{@link #STATUS_LABEL}</td> 5244 * <td>read/write</td> 5245 * <td>The resource ID of the label describing the source of contact status, 5246 * e.g. "Google Talk". This resource is scoped by the 5247 * {@link #STATUS_RES_PACKAGE}.</td> 5248 * </tr> 5249 * <tr> 5250 * <td>long</td> 5251 * <td>{@link #STATUS_ICON}</td> 5252 * <td>read/write</td> 5253 * <td>The resource ID of the icon for the source of contact status. This 5254 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 5255 * </tr> 5256 * </table> 5257 */ 5258 public static class StatusUpdates implements StatusColumns, PresenceColumns { 5259 5260 /** 5261 * This utility class cannot be instantiated 5262 */ 5263 private StatusUpdates() {} 5264 5265 /** 5266 * The content:// style URI for this table 5267 */ 5268 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); 5269 5270 /** 5271 * The content:// style URI for this table, specific to the user's profile. 5272 */ 5273 public static final Uri PROFILE_CONTENT_URI = 5274 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); 5275 5276 /** 5277 * Gets the resource ID for the proper presence icon. 5278 * 5279 * @param status the status to get the icon for 5280 * @return the resource ID for the proper presence icon 5281 */ 5282 public static final int getPresenceIconResourceId(int status) { 5283 switch (status) { 5284 case AVAILABLE: 5285 return android.R.drawable.presence_online; 5286 case IDLE: 5287 case AWAY: 5288 return android.R.drawable.presence_away; 5289 case DO_NOT_DISTURB: 5290 return android.R.drawable.presence_busy; 5291 case INVISIBLE: 5292 return android.R.drawable.presence_invisible; 5293 case OFFLINE: 5294 default: 5295 return android.R.drawable.presence_offline; 5296 } 5297 } 5298 5299 /** 5300 * Returns the precedence of the status code the higher number being the higher precedence. 5301 * 5302 * @param status The status code. 5303 * @return An integer representing the precedence, 0 being the lowest. 5304 */ 5305 public static final int getPresencePrecedence(int status) { 5306 // Keep this function here incase we want to enforce a different precedence than the 5307 // natural order of the status constants. 5308 return status; 5309 } 5310 5311 /** 5312 * The MIME type of {@link #CONTENT_URI} providing a directory of 5313 * status update details. 5314 */ 5315 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; 5316 5317 /** 5318 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 5319 * status update detail. 5320 */ 5321 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; 5322 } 5323 5324 /** 5325 * @deprecated This old name was never meant to be made public. Do not use. 5326 */ 5327 @Deprecated 5328 public static final class Presence extends StatusUpdates { 5329 5330 } 5331 5332 /** 5333 * Additional column returned by 5334 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining 5335 * why the filter matched the contact. This column will contain extracts from the contact's 5336 * constituent {@link Data Data} items, formatted in a way that indicates the section of the 5337 * snippet that matched the filter. 5338 * 5339 * <p> 5340 * The following example searches for all contacts that match the query "presi" and requests 5341 * the snippet column as well. 5342 * <pre> 5343 * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon(); 5344 * builder.appendPath("presi"); 5345 * // Defer snippeting to the client side if possible, for performance reasons. 5346 * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1"); 5347 * 5348 * Cursor cursor = getContentResolver().query(builder.build()); 5349 * 5350 * Bundle extras = cursor.getExtras(); 5351 * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { 5352 * // Do our own snippet formatting. 5353 * // For a contact with the email address (president@organization.com), the snippet 5354 * // column will contain the string "president@organization.com". 5355 * } else { 5356 * // The snippet has already been pre-formatted, we can display it as is. 5357 * // For a contact with the email address (president@organization.com), the snippet 5358 * // column will contain the string "[presi]dent@organization.com". 5359 * } 5360 * </pre> 5361 * </p> 5362 */ 5363 public static class SearchSnippets { 5364 5365 /** 5366 * The search snippet constructed by SQLite snippeting functionality. 5367 * <p> 5368 * The snippet may contain (parts of) several data elements belonging to the contact, 5369 * with the matching parts optionally surrounded by special characters that indicate the 5370 * start and end of matching text. 5371 * 5372 * For example, if a contact has an address "123 Main Street", using a filter "mai" would 5373 * return the formatted snippet "123 [Mai]n street". 5374 * 5375 * @see <a href="http://www.sqlite.org/fts3.html#snippet"> 5376 * http://www.sqlite.org/fts3.html#snippet</a> 5377 */ 5378 public static final String SNIPPET = "snippet"; 5379 5380 /** 5381 * Comma-separated parameters for the generation of the snippet: 5382 * <ul> 5383 * <li>The "start match" text. Default is '['</li> 5384 * <li>The "end match" text. Default is ']'</li> 5385 * <li>The "ellipsis" text. Default is "..."</li> 5386 * <li>Maximum number of tokens to include in the snippet. Can be either 5387 * a positive or a negative number: A positive number indicates how many 5388 * tokens can be returned in total. A negative number indicates how many 5389 * tokens can be returned per occurrence of the search terms.</li> 5390 * </ul> 5391 * 5392 * @hide 5393 */ 5394 public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; 5395 5396 /** 5397 * The key to ask the provider to defer the formatting of the snippet to the client if 5398 * possible, for performance reasons. 5399 * A value of 1 indicates true, 0 indicates false. False is the default. 5400 * When a cursor is returned to the client, it should check for an extra with the name 5401 * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client 5402 * should do its own formatting of the snippet. If it doesn't exist, the snippet column 5403 * in the cursor should already contain a formatted snippet. 5404 */ 5405 public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; 5406 } 5407 5408 /** 5409 * Container for definitions of common data types stored in the {@link ContactsContract.Data} 5410 * table. 5411 */ 5412 public static final class CommonDataKinds { 5413 /** 5414 * This utility class cannot be instantiated 5415 */ 5416 private CommonDataKinds() {} 5417 5418 /** 5419 * The {@link Data#RES_PACKAGE} value for common data that should be 5420 * shown using a default style. 5421 * 5422 * @hide RES_PACKAGE is hidden 5423 */ 5424 public static final String PACKAGE_COMMON = "common"; 5425 5426 /** 5427 * The base types that all "Typed" data kinds support. 5428 */ 5429 public interface BaseTypes { 5430 /** 5431 * A custom type. The custom label should be supplied by user. 5432 */ 5433 public static int TYPE_CUSTOM = 0; 5434 } 5435 5436 /** 5437 * Columns common across the specific types. 5438 */ 5439 protected interface CommonColumns extends BaseTypes { 5440 /** 5441 * The data for the contact method. 5442 * <P>Type: TEXT</P> 5443 */ 5444 public static final String DATA = DataColumns.DATA1; 5445 5446 /** 5447 * The type of data, for example Home or Work. 5448 * <P>Type: INTEGER</P> 5449 */ 5450 public static final String TYPE = DataColumns.DATA2; 5451 5452 /** 5453 * The user defined label for the the contact method. 5454 * <P>Type: TEXT</P> 5455 */ 5456 public static final String LABEL = DataColumns.DATA3; 5457 } 5458 5459 /** 5460 * A data kind representing the contact's proper name. You can use all 5461 * columns defined for {@link ContactsContract.Data} as well as the following aliases. 5462 * 5463 * <h2>Column aliases</h2> 5464 * <table class="jd-sumtable"> 5465 * <tr> 5466 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 5467 * </tr> 5468 * <tr> 5469 * <td>String</td> 5470 * <td>{@link #DISPLAY_NAME}</td> 5471 * <td>{@link #DATA1}</td> 5472 * <td></td> 5473 * </tr> 5474 * <tr> 5475 * <td>String</td> 5476 * <td>{@link #GIVEN_NAME}</td> 5477 * <td>{@link #DATA2}</td> 5478 * <td></td> 5479 * </tr> 5480 * <tr> 5481 * <td>String</td> 5482 * <td>{@link #FAMILY_NAME}</td> 5483 * <td>{@link #DATA3}</td> 5484 * <td></td> 5485 * </tr> 5486 * <tr> 5487 * <td>String</td> 5488 * <td>{@link #PREFIX}</td> 5489 * <td>{@link #DATA4}</td> 5490 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> 5491 * </tr> 5492 * <tr> 5493 * <td>String</td> 5494 * <td>{@link #MIDDLE_NAME}</td> 5495 * <td>{@link #DATA5}</td> 5496 * <td></td> 5497 * </tr> 5498 * <tr> 5499 * <td>String</td> 5500 * <td>{@link #SUFFIX}</td> 5501 * <td>{@link #DATA6}</td> 5502 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> 5503 * </tr> 5504 * <tr> 5505 * <td>String</td> 5506 * <td>{@link #PHONETIC_GIVEN_NAME}</td> 5507 * <td>{@link #DATA7}</td> 5508 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> 5509 * </tr> 5510 * <tr> 5511 * <td>String</td> 5512 * <td>{@link #PHONETIC_MIDDLE_NAME}</td> 5513 * <td>{@link #DATA8}</td> 5514 * <td></td> 5515 * </tr> 5516 * <tr> 5517 * <td>String</td> 5518 * <td>{@link #PHONETIC_FAMILY_NAME}</td> 5519 * <td>{@link #DATA9}</td> 5520 * <td></td> 5521 * </tr> 5522 * </table> 5523 */ 5524 public static final class StructuredName implements DataColumnsWithJoins, ContactCounts { 5525 /** 5526 * This utility class cannot be instantiated 5527 */ 5528 private StructuredName() {} 5529 5530 /** MIME type used when storing this in data table. */ 5531 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; 5532 5533 /** 5534 * The name that should be used to display the contact. 5535 * <i>Unstructured component of the name should be consistent with 5536 * its structured representation.</i> 5537 * <p> 5538 * Type: TEXT 5539 */ 5540 public static final String DISPLAY_NAME = DATA1; 5541 5542 /** 5543 * The given name for the contact. 5544 * <P>Type: TEXT</P> 5545 */ 5546 public static final String GIVEN_NAME = DATA2; 5547 5548 /** 5549 * The family name for the contact. 5550 * <P>Type: TEXT</P> 5551 */ 5552 public static final String FAMILY_NAME = DATA3; 5553 5554 /** 5555 * The contact's honorific prefix, e.g. "Sir" 5556 * <P>Type: TEXT</P> 5557 */ 5558 public static final String PREFIX = DATA4; 5559 5560 /** 5561 * The contact's middle name 5562 * <P>Type: TEXT</P> 5563 */ 5564 public static final String MIDDLE_NAME = DATA5; 5565 5566 /** 5567 * The contact's honorific suffix, e.g. "Jr" 5568 */ 5569 public static final String SUFFIX = DATA6; 5570 5571 /** 5572 * The phonetic version of the given name for the contact. 5573 * <P>Type: TEXT</P> 5574 */ 5575 public static final String PHONETIC_GIVEN_NAME = DATA7; 5576 5577 /** 5578 * The phonetic version of the additional name for the contact. 5579 * <P>Type: TEXT</P> 5580 */ 5581 public static final String PHONETIC_MIDDLE_NAME = DATA8; 5582 5583 /** 5584 * The phonetic version of the family name for the contact. 5585 * <P>Type: TEXT</P> 5586 */ 5587 public static final String PHONETIC_FAMILY_NAME = DATA9; 5588 5589 /** 5590 * The style used for combining given/middle/family name into a full name. 5591 * See {@link ContactsContract.FullNameStyle}. 5592 */ 5593 public static final String FULL_NAME_STYLE = DATA10; 5594 5595 /** 5596 * The alphabet used for capturing the phonetic name. 5597 * See ContactsContract.PhoneticNameStyle. 5598 * @hide 5599 */ 5600 public static final String PHONETIC_NAME_STYLE = DATA11; 5601 } 5602 5603 /** 5604 * <p>A data kind representing the contact's nickname. For example, for 5605 * Bob Parr ("Mr. Incredible"): 5606 * <pre> 5607 * ArrayList<ContentProviderOperation> ops = 5608 * new ArrayList<ContentProviderOperation>(); 5609 * 5610 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 5611 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 5612 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 5613 * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") 5614 * .build()); 5615 * 5616 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 5617 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 5618 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) 5619 * .withValue(Nickname.NAME, "Mr. Incredible") 5620 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) 5621 * .withValue(Nickname.LABEL, "Superhero") 5622 * .build()); 5623 * 5624 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 5625 * </pre> 5626 * </p> 5627 * <p> 5628 * You can use all columns defined for {@link ContactsContract.Data} as well as the 5629 * following aliases. 5630 * </p> 5631 * 5632 * <h2>Column aliases</h2> 5633 * <table class="jd-sumtable"> 5634 * <tr> 5635 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 5636 * </tr> 5637 * <tr> 5638 * <td>String</td> 5639 * <td>{@link #NAME}</td> 5640 * <td>{@link #DATA1}</td> 5641 * <td></td> 5642 * </tr> 5643 * <tr> 5644 * <td>int</td> 5645 * <td>{@link #TYPE}</td> 5646 * <td>{@link #DATA2}</td> 5647 * <td> 5648 * Allowed values are: 5649 * <p> 5650 * <ul> 5651 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 5652 * <li>{@link #TYPE_DEFAULT}</li> 5653 * <li>{@link #TYPE_OTHER_NAME}</li> 5654 * <li>{@link #TYPE_MAIDEN_NAME}</li> 5655 * <li>{@link #TYPE_SHORT_NAME}</li> 5656 * <li>{@link #TYPE_INITIALS}</li> 5657 * </ul> 5658 * </p> 5659 * </td> 5660 * </tr> 5661 * <tr> 5662 * <td>String</td> 5663 * <td>{@link #LABEL}</td> 5664 * <td>{@link #DATA3}</td> 5665 * <td></td> 5666 * </tr> 5667 * </table> 5668 */ 5669 public static final class Nickname implements DataColumnsWithJoins, CommonColumns, 5670 ContactCounts{ 5671 /** 5672 * This utility class cannot be instantiated 5673 */ 5674 private Nickname() {} 5675 5676 /** MIME type used when storing this in data table. */ 5677 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; 5678 5679 public static final int TYPE_DEFAULT = 1; 5680 public static final int TYPE_OTHER_NAME = 2; 5681 public static final int TYPE_MAIDEN_NAME = 3; 5682 /** @deprecated Use TYPE_MAIDEN_NAME instead. */ 5683 @Deprecated 5684 public static final int TYPE_MAINDEN_NAME = 3; 5685 public static final int TYPE_SHORT_NAME = 4; 5686 public static final int TYPE_INITIALS = 5; 5687 5688 /** 5689 * The name itself 5690 */ 5691 public static final String NAME = DATA; 5692 } 5693 5694 /** 5695 * <p> 5696 * A data kind representing a telephone number. 5697 * </p> 5698 * <p> 5699 * You can use all columns defined for {@link ContactsContract.Data} as 5700 * well as the following aliases. 5701 * </p> 5702 * <h2>Column aliases</h2> 5703 * <table class="jd-sumtable"> 5704 * <tr> 5705 * <th>Type</th> 5706 * <th>Alias</th><th colspan='2'>Data column</th> 5707 * </tr> 5708 * <tr> 5709 * <td>String</td> 5710 * <td>{@link #NUMBER}</td> 5711 * <td>{@link #DATA1}</td> 5712 * <td></td> 5713 * </tr> 5714 * <tr> 5715 * <td>int</td> 5716 * <td>{@link #TYPE}</td> 5717 * <td>{@link #DATA2}</td> 5718 * <td>Allowed values are: 5719 * <p> 5720 * <ul> 5721 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 5722 * <li>{@link #TYPE_HOME}</li> 5723 * <li>{@link #TYPE_MOBILE}</li> 5724 * <li>{@link #TYPE_WORK}</li> 5725 * <li>{@link #TYPE_FAX_WORK}</li> 5726 * <li>{@link #TYPE_FAX_HOME}</li> 5727 * <li>{@link #TYPE_PAGER}</li> 5728 * <li>{@link #TYPE_OTHER}</li> 5729 * <li>{@link #TYPE_CALLBACK}</li> 5730 * <li>{@link #TYPE_CAR}</li> 5731 * <li>{@link #TYPE_COMPANY_MAIN}</li> 5732 * <li>{@link #TYPE_ISDN}</li> 5733 * <li>{@link #TYPE_MAIN}</li> 5734 * <li>{@link #TYPE_OTHER_FAX}</li> 5735 * <li>{@link #TYPE_RADIO}</li> 5736 * <li>{@link #TYPE_TELEX}</li> 5737 * <li>{@link #TYPE_TTY_TDD}</li> 5738 * <li>{@link #TYPE_WORK_MOBILE}</li> 5739 * <li>{@link #TYPE_WORK_PAGER}</li> 5740 * <li>{@link #TYPE_ASSISTANT}</li> 5741 * <li>{@link #TYPE_MMS}</li> 5742 * </ul> 5743 * </p> 5744 * </td> 5745 * </tr> 5746 * <tr> 5747 * <td>String</td> 5748 * <td>{@link #LABEL}</td> 5749 * <td>{@link #DATA3}</td> 5750 * <td></td> 5751 * </tr> 5752 * </table> 5753 */ 5754 public static final class Phone implements DataColumnsWithJoins, CommonColumns, 5755 ContactCounts { 5756 /** 5757 * This utility class cannot be instantiated 5758 */ 5759 private Phone() {} 5760 5761 /** MIME type used when storing this in data table. */ 5762 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2"; 5763 5764 /** 5765 * The MIME type of {@link #CONTENT_URI} providing a directory of 5766 * phones. 5767 */ 5768 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; 5769 5770 /** 5771 * The content:// style URI for all data records of the 5772 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 5773 * associated raw contact and aggregate contact data. 5774 */ 5775 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 5776 "phones"); 5777 5778 /** 5779 * The content:// style URL for phone lookup using a filter. The filter returns 5780 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 5781 * to display names as well as phone numbers. The filter argument should be passed 5782 * as an additional path segment after this URI. 5783 */ 5784 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 5785 "filter"); 5786 5787 /** 5788 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. 5789 * If "1" or "true", display names are searched. If "0" or "false", display names 5790 * are not searched. Default is "1". 5791 */ 5792 public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; 5793 5794 /** 5795 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. 5796 * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers 5797 * are not searched. Default is "1". 5798 */ 5799 public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; 5800 5801 public static final int TYPE_HOME = 1; 5802 public static final int TYPE_MOBILE = 2; 5803 public static final int TYPE_WORK = 3; 5804 public static final int TYPE_FAX_WORK = 4; 5805 public static final int TYPE_FAX_HOME = 5; 5806 public static final int TYPE_PAGER = 6; 5807 public static final int TYPE_OTHER = 7; 5808 public static final int TYPE_CALLBACK = 8; 5809 public static final int TYPE_CAR = 9; 5810 public static final int TYPE_COMPANY_MAIN = 10; 5811 public static final int TYPE_ISDN = 11; 5812 public static final int TYPE_MAIN = 12; 5813 public static final int TYPE_OTHER_FAX = 13; 5814 public static final int TYPE_RADIO = 14; 5815 public static final int TYPE_TELEX = 15; 5816 public static final int TYPE_TTY_TDD = 16; 5817 public static final int TYPE_WORK_MOBILE = 17; 5818 public static final int TYPE_WORK_PAGER = 18; 5819 public static final int TYPE_ASSISTANT = 19; 5820 public static final int TYPE_MMS = 20; 5821 5822 /** 5823 * The phone number as the user entered it. 5824 * <P>Type: TEXT</P> 5825 */ 5826 public static final String NUMBER = DATA; 5827 5828 /** 5829 * The phone number's E164 representation. This value can be omitted in which 5830 * case the provider will try to automatically infer it. (It'll be left null if the 5831 * provider fails to infer.) 5832 * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise). 5833 * <P>Type: TEXT</P> 5834 */ 5835 public static final String NORMALIZED_NUMBER = DATA4; 5836 5837 /** 5838 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 5839 * @hide 5840 */ 5841 @Deprecated 5842 public static final CharSequence getDisplayLabel(Context context, int type, 5843 CharSequence label, CharSequence[] labelArray) { 5844 return getTypeLabel(context.getResources(), type, label); 5845 } 5846 5847 /** 5848 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 5849 * @hide 5850 */ 5851 @Deprecated 5852 public static final CharSequence getDisplayLabel(Context context, int type, 5853 CharSequence label) { 5854 return getTypeLabel(context.getResources(), type, label); 5855 } 5856 5857 /** 5858 * Return the string resource that best describes the given 5859 * {@link #TYPE}. Will always return a valid resource. 5860 */ 5861 public static final int getTypeLabelResource(int type) { 5862 switch (type) { 5863 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; 5864 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; 5865 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; 5866 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; 5867 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; 5868 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; 5869 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; 5870 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; 5871 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; 5872 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; 5873 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; 5874 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; 5875 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; 5876 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; 5877 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; 5878 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; 5879 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; 5880 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; 5881 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; 5882 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; 5883 default: return com.android.internal.R.string.phoneTypeCustom; 5884 } 5885 } 5886 5887 /** 5888 * Return a {@link CharSequence} that best describes the given type, 5889 * possibly substituting the given {@link #LABEL} value 5890 * for {@link #TYPE_CUSTOM}. 5891 */ 5892 public static final CharSequence getTypeLabel(Resources res, int type, 5893 CharSequence label) { 5894 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { 5895 return label; 5896 } else { 5897 final int labelRes = getTypeLabelResource(type); 5898 return res.getText(labelRes); 5899 } 5900 } 5901 } 5902 5903 /** 5904 * <p> 5905 * A data kind representing an email address. 5906 * </p> 5907 * <p> 5908 * You can use all columns defined for {@link ContactsContract.Data} as 5909 * well as the following aliases. 5910 * </p> 5911 * <h2>Column aliases</h2> 5912 * <table class="jd-sumtable"> 5913 * <tr> 5914 * <th>Type</th> 5915 * <th>Alias</th><th colspan='2'>Data column</th> 5916 * </tr> 5917 * <tr> 5918 * <td>String</td> 5919 * <td>{@link #ADDRESS}</td> 5920 * <td>{@link #DATA1}</td> 5921 * <td>Email address itself.</td> 5922 * </tr> 5923 * <tr> 5924 * <td>int</td> 5925 * <td>{@link #TYPE}</td> 5926 * <td>{@link #DATA2}</td> 5927 * <td>Allowed values are: 5928 * <p> 5929 * <ul> 5930 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 5931 * <li>{@link #TYPE_HOME}</li> 5932 * <li>{@link #TYPE_WORK}</li> 5933 * <li>{@link #TYPE_OTHER}</li> 5934 * <li>{@link #TYPE_MOBILE}</li> 5935 * </ul> 5936 * </p> 5937 * </td> 5938 * </tr> 5939 * <tr> 5940 * <td>String</td> 5941 * <td>{@link #LABEL}</td> 5942 * <td>{@link #DATA3}</td> 5943 * <td></td> 5944 * </tr> 5945 * </table> 5946 */ 5947 public static final class Email implements DataColumnsWithJoins, CommonColumns, 5948 ContactCounts { 5949 /** 5950 * This utility class cannot be instantiated 5951 */ 5952 private Email() {} 5953 5954 /** MIME type used when storing this in data table. */ 5955 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2"; 5956 5957 /** 5958 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. 5959 */ 5960 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; 5961 5962 /** 5963 * The content:// style URI for all data records of the 5964 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 5965 * associated raw contact and aggregate contact data. 5966 */ 5967 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 5968 "emails"); 5969 5970 /** 5971 * <p> 5972 * The content:// style URL for looking up data rows by email address. The 5973 * lookup argument, an email address, should be passed as an additional path segment 5974 * after this URI. 5975 * </p> 5976 * <p>Example: 5977 * <pre> 5978 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); 5979 * Cursor c = getContentResolver().query(uri, 5980 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, 5981 * null, null, null); 5982 * </pre> 5983 * </p> 5984 */ 5985 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, 5986 "lookup"); 5987 5988 /** 5989 * <p> 5990 * The content:// style URL for email lookup using a filter. The filter returns 5991 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 5992 * to display names as well as email addresses. The filter argument should be passed 5993 * as an additional path segment after this URI. 5994 * </p> 5995 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" 5996 * as well as "Bob Parr (incredible@android.com)". 5997 * <pre> 5998 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); 5999 * Cursor c = getContentResolver().query(uri, 6000 * new String[]{Email.DISPLAY_NAME, Email.DATA}, 6001 * null, null, null); 6002 * </pre> 6003 * </p> 6004 */ 6005 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 6006 "filter"); 6007 6008 /** 6009 * The email address. 6010 * <P>Type: TEXT</P> 6011 */ 6012 public static final String ADDRESS = DATA1; 6013 6014 public static final int TYPE_HOME = 1; 6015 public static final int TYPE_WORK = 2; 6016 public static final int TYPE_OTHER = 3; 6017 public static final int TYPE_MOBILE = 4; 6018 6019 /** 6020 * The display name for the email address 6021 * <P>Type: TEXT</P> 6022 */ 6023 public static final String DISPLAY_NAME = DATA4; 6024 6025 /** 6026 * Return the string resource that best describes the given 6027 * {@link #TYPE}. Will always return a valid resource. 6028 */ 6029 public static final int getTypeLabelResource(int type) { 6030 switch (type) { 6031 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; 6032 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; 6033 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; 6034 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; 6035 default: return com.android.internal.R.string.emailTypeCustom; 6036 } 6037 } 6038 6039 /** 6040 * Return a {@link CharSequence} that best describes the given type, 6041 * possibly substituting the given {@link #LABEL} value 6042 * for {@link #TYPE_CUSTOM}. 6043 */ 6044 public static final CharSequence getTypeLabel(Resources res, int type, 6045 CharSequence label) { 6046 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6047 return label; 6048 } else { 6049 final int labelRes = getTypeLabelResource(type); 6050 return res.getText(labelRes); 6051 } 6052 } 6053 } 6054 6055 /** 6056 * <p> 6057 * A data kind representing a postal addresses. 6058 * </p> 6059 * <p> 6060 * You can use all columns defined for {@link ContactsContract.Data} as 6061 * well as the following aliases. 6062 * </p> 6063 * <h2>Column aliases</h2> 6064 * <table class="jd-sumtable"> 6065 * <tr> 6066 * <th>Type</th> 6067 * <th>Alias</th><th colspan='2'>Data column</th> 6068 * </tr> 6069 * <tr> 6070 * <td>String</td> 6071 * <td>{@link #FORMATTED_ADDRESS}</td> 6072 * <td>{@link #DATA1}</td> 6073 * <td></td> 6074 * </tr> 6075 * <tr> 6076 * <td>int</td> 6077 * <td>{@link #TYPE}</td> 6078 * <td>{@link #DATA2}</td> 6079 * <td>Allowed values are: 6080 * <p> 6081 * <ul> 6082 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6083 * <li>{@link #TYPE_HOME}</li> 6084 * <li>{@link #TYPE_WORK}</li> 6085 * <li>{@link #TYPE_OTHER}</li> 6086 * </ul> 6087 * </p> 6088 * </td> 6089 * </tr> 6090 * <tr> 6091 * <td>String</td> 6092 * <td>{@link #LABEL}</td> 6093 * <td>{@link #DATA3}</td> 6094 * <td></td> 6095 * </tr> 6096 * <tr> 6097 * <td>String</td> 6098 * <td>{@link #STREET}</td> 6099 * <td>{@link #DATA4}</td> 6100 * <td></td> 6101 * </tr> 6102 * <tr> 6103 * <td>String</td> 6104 * <td>{@link #POBOX}</td> 6105 * <td>{@link #DATA5}</td> 6106 * <td>Post Office Box number</td> 6107 * </tr> 6108 * <tr> 6109 * <td>String</td> 6110 * <td>{@link #NEIGHBORHOOD}</td> 6111 * <td>{@link #DATA6}</td> 6112 * <td></td> 6113 * </tr> 6114 * <tr> 6115 * <td>String</td> 6116 * <td>{@link #CITY}</td> 6117 * <td>{@link #DATA7}</td> 6118 * <td></td> 6119 * </tr> 6120 * <tr> 6121 * <td>String</td> 6122 * <td>{@link #REGION}</td> 6123 * <td>{@link #DATA8}</td> 6124 * <td></td> 6125 * </tr> 6126 * <tr> 6127 * <td>String</td> 6128 * <td>{@link #POSTCODE}</td> 6129 * <td>{@link #DATA9}</td> 6130 * <td></td> 6131 * </tr> 6132 * <tr> 6133 * <td>String</td> 6134 * <td>{@link #COUNTRY}</td> 6135 * <td>{@link #DATA10}</td> 6136 * <td></td> 6137 * </tr> 6138 * </table> 6139 */ 6140 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns, 6141 ContactCounts { 6142 /** 6143 * This utility class cannot be instantiated 6144 */ 6145 private StructuredPostal() { 6146 } 6147 6148 /** MIME type used when storing this in data table. */ 6149 public static final String CONTENT_ITEM_TYPE = 6150 "vnd.android.cursor.item/postal-address_v2"; 6151 6152 /** 6153 * The MIME type of {@link #CONTENT_URI} providing a directory of 6154 * postal addresses. 6155 */ 6156 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2"; 6157 6158 /** 6159 * The content:// style URI for all data records of the 6160 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. 6161 */ 6162 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 6163 "postals"); 6164 6165 public static final int TYPE_HOME = 1; 6166 public static final int TYPE_WORK = 2; 6167 public static final int TYPE_OTHER = 3; 6168 6169 /** 6170 * The full, unstructured postal address. <i>This field must be 6171 * consistent with any structured data.</i> 6172 * <p> 6173 * Type: TEXT 6174 */ 6175 public static final String FORMATTED_ADDRESS = DATA; 6176 6177 /** 6178 * Can be street, avenue, road, etc. This element also includes the 6179 * house number and room/apartment/flat/floor number. 6180 * <p> 6181 * Type: TEXT 6182 */ 6183 public static final String STREET = DATA4; 6184 6185 /** 6186 * Covers actual P.O. boxes, drawers, locked bags, etc. This is 6187 * usually but not always mutually exclusive with street. 6188 * <p> 6189 * Type: TEXT 6190 */ 6191 public static final String POBOX = DATA5; 6192 6193 /** 6194 * This is used to disambiguate a street address when a city 6195 * contains more than one street with the same name, or to specify a 6196 * small place whose mail is routed through a larger postal town. In 6197 * China it could be a county or a minor city. 6198 * <p> 6199 * Type: TEXT 6200 */ 6201 public static final String NEIGHBORHOOD = DATA6; 6202 6203 /** 6204 * Can be city, village, town, borough, etc. This is the postal town 6205 * and not necessarily the place of residence or place of business. 6206 * <p> 6207 * Type: TEXT 6208 */ 6209 public static final String CITY = DATA7; 6210 6211 /** 6212 * A state, province, county (in Ireland), Land (in Germany), 6213 * departement (in France), etc. 6214 * <p> 6215 * Type: TEXT 6216 */ 6217 public static final String REGION = DATA8; 6218 6219 /** 6220 * Postal code. Usually country-wide, but sometimes specific to the 6221 * city (e.g. "2" in "Dublin 2, Ireland" addresses). 6222 * <p> 6223 * Type: TEXT 6224 */ 6225 public static final String POSTCODE = DATA9; 6226 6227 /** 6228 * The name or code of the country. 6229 * <p> 6230 * Type: TEXT 6231 */ 6232 public static final String COUNTRY = DATA10; 6233 6234 /** 6235 * Return the string resource that best describes the given 6236 * {@link #TYPE}. Will always return a valid resource. 6237 */ 6238 public static final int getTypeLabelResource(int type) { 6239 switch (type) { 6240 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; 6241 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; 6242 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; 6243 default: return com.android.internal.R.string.postalTypeCustom; 6244 } 6245 } 6246 6247 /** 6248 * Return a {@link CharSequence} that best describes the given type, 6249 * possibly substituting the given {@link #LABEL} value 6250 * for {@link #TYPE_CUSTOM}. 6251 */ 6252 public static final CharSequence getTypeLabel(Resources res, int type, 6253 CharSequence label) { 6254 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6255 return label; 6256 } else { 6257 final int labelRes = getTypeLabelResource(type); 6258 return res.getText(labelRes); 6259 } 6260 } 6261 } 6262 6263 /** 6264 * <p> 6265 * A data kind representing an IM address 6266 * </p> 6267 * <p> 6268 * You can use all columns defined for {@link ContactsContract.Data} as 6269 * well as the following aliases. 6270 * </p> 6271 * <h2>Column aliases</h2> 6272 * <table class="jd-sumtable"> 6273 * <tr> 6274 * <th>Type</th> 6275 * <th>Alias</th><th colspan='2'>Data column</th> 6276 * </tr> 6277 * <tr> 6278 * <td>String</td> 6279 * <td>{@link #DATA}</td> 6280 * <td>{@link #DATA1}</td> 6281 * <td></td> 6282 * </tr> 6283 * <tr> 6284 * <td>int</td> 6285 * <td>{@link #TYPE}</td> 6286 * <td>{@link #DATA2}</td> 6287 * <td>Allowed values are: 6288 * <p> 6289 * <ul> 6290 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6291 * <li>{@link #TYPE_HOME}</li> 6292 * <li>{@link #TYPE_WORK}</li> 6293 * <li>{@link #TYPE_OTHER}</li> 6294 * </ul> 6295 * </p> 6296 * </td> 6297 * </tr> 6298 * <tr> 6299 * <td>String</td> 6300 * <td>{@link #LABEL}</td> 6301 * <td>{@link #DATA3}</td> 6302 * <td></td> 6303 * </tr> 6304 * <tr> 6305 * <td>String</td> 6306 * <td>{@link #PROTOCOL}</td> 6307 * <td>{@link #DATA5}</td> 6308 * <td> 6309 * <p> 6310 * Allowed values: 6311 * <ul> 6312 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name 6313 * as {@link #CUSTOM_PROTOCOL}.</li> 6314 * <li>{@link #PROTOCOL_AIM}</li> 6315 * <li>{@link #PROTOCOL_MSN}</li> 6316 * <li>{@link #PROTOCOL_YAHOO}</li> 6317 * <li>{@link #PROTOCOL_SKYPE}</li> 6318 * <li>{@link #PROTOCOL_QQ}</li> 6319 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> 6320 * <li>{@link #PROTOCOL_ICQ}</li> 6321 * <li>{@link #PROTOCOL_JABBER}</li> 6322 * <li>{@link #PROTOCOL_NETMEETING}</li> 6323 * </ul> 6324 * </p> 6325 * </td> 6326 * </tr> 6327 * <tr> 6328 * <td>String</td> 6329 * <td>{@link #CUSTOM_PROTOCOL}</td> 6330 * <td>{@link #DATA6}</td> 6331 * <td></td> 6332 * </tr> 6333 * </table> 6334 */ 6335 public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts { 6336 /** 6337 * This utility class cannot be instantiated 6338 */ 6339 private Im() {} 6340 6341 /** MIME type used when storing this in data table. */ 6342 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; 6343 6344 public static final int TYPE_HOME = 1; 6345 public static final int TYPE_WORK = 2; 6346 public static final int TYPE_OTHER = 3; 6347 6348 /** 6349 * This column should be populated with one of the defined 6350 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this 6351 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} 6352 * should contain the name of the custom protocol. 6353 */ 6354 public static final String PROTOCOL = DATA5; 6355 6356 public static final String CUSTOM_PROTOCOL = DATA6; 6357 6358 /* 6359 * The predefined IM protocol types. 6360 */ 6361 public static final int PROTOCOL_CUSTOM = -1; 6362 public static final int PROTOCOL_AIM = 0; 6363 public static final int PROTOCOL_MSN = 1; 6364 public static final int PROTOCOL_YAHOO = 2; 6365 public static final int PROTOCOL_SKYPE = 3; 6366 public static final int PROTOCOL_QQ = 4; 6367 public static final int PROTOCOL_GOOGLE_TALK = 5; 6368 public static final int PROTOCOL_ICQ = 6; 6369 public static final int PROTOCOL_JABBER = 7; 6370 public static final int PROTOCOL_NETMEETING = 8; 6371 6372 /** 6373 * Return the string resource that best describes the given 6374 * {@link #TYPE}. Will always return a valid resource. 6375 */ 6376 public static final int getTypeLabelResource(int type) { 6377 switch (type) { 6378 case TYPE_HOME: return com.android.internal.R.string.imTypeHome; 6379 case TYPE_WORK: return com.android.internal.R.string.imTypeWork; 6380 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; 6381 default: return com.android.internal.R.string.imTypeCustom; 6382 } 6383 } 6384 6385 /** 6386 * Return a {@link CharSequence} that best describes the given type, 6387 * possibly substituting the given {@link #LABEL} value 6388 * for {@link #TYPE_CUSTOM}. 6389 */ 6390 public static final CharSequence getTypeLabel(Resources res, int type, 6391 CharSequence label) { 6392 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6393 return label; 6394 } else { 6395 final int labelRes = getTypeLabelResource(type); 6396 return res.getText(labelRes); 6397 } 6398 } 6399 6400 /** 6401 * Return the string resource that best describes the given 6402 * {@link #PROTOCOL}. Will always return a valid resource. 6403 */ 6404 public static final int getProtocolLabelResource(int type) { 6405 switch (type) { 6406 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; 6407 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; 6408 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; 6409 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; 6410 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; 6411 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; 6412 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; 6413 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; 6414 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; 6415 default: return com.android.internal.R.string.imProtocolCustom; 6416 } 6417 } 6418 6419 /** 6420 * Return a {@link CharSequence} that best describes the given 6421 * protocol, possibly substituting the given 6422 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. 6423 */ 6424 public static final CharSequence getProtocolLabel(Resources res, int type, 6425 CharSequence label) { 6426 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { 6427 return label; 6428 } else { 6429 final int labelRes = getProtocolLabelResource(type); 6430 return res.getText(labelRes); 6431 } 6432 } 6433 } 6434 6435 /** 6436 * <p> 6437 * A data kind representing an organization. 6438 * </p> 6439 * <p> 6440 * You can use all columns defined for {@link ContactsContract.Data} as 6441 * well as the following aliases. 6442 * </p> 6443 * <h2>Column aliases</h2> 6444 * <table class="jd-sumtable"> 6445 * <tr> 6446 * <th>Type</th> 6447 * <th>Alias</th><th colspan='2'>Data column</th> 6448 * </tr> 6449 * <tr> 6450 * <td>String</td> 6451 * <td>{@link #COMPANY}</td> 6452 * <td>{@link #DATA1}</td> 6453 * <td></td> 6454 * </tr> 6455 * <tr> 6456 * <td>int</td> 6457 * <td>{@link #TYPE}</td> 6458 * <td>{@link #DATA2}</td> 6459 * <td>Allowed values are: 6460 * <p> 6461 * <ul> 6462 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6463 * <li>{@link #TYPE_WORK}</li> 6464 * <li>{@link #TYPE_OTHER}</li> 6465 * </ul> 6466 * </p> 6467 * </td> 6468 * </tr> 6469 * <tr> 6470 * <td>String</td> 6471 * <td>{@link #LABEL}</td> 6472 * <td>{@link #DATA3}</td> 6473 * <td></td> 6474 * </tr> 6475 * <tr> 6476 * <td>String</td> 6477 * <td>{@link #TITLE}</td> 6478 * <td>{@link #DATA4}</td> 6479 * <td></td> 6480 * </tr> 6481 * <tr> 6482 * <td>String</td> 6483 * <td>{@link #DEPARTMENT}</td> 6484 * <td>{@link #DATA5}</td> 6485 * <td></td> 6486 * </tr> 6487 * <tr> 6488 * <td>String</td> 6489 * <td>{@link #JOB_DESCRIPTION}</td> 6490 * <td>{@link #DATA6}</td> 6491 * <td></td> 6492 * </tr> 6493 * <tr> 6494 * <td>String</td> 6495 * <td>{@link #SYMBOL}</td> 6496 * <td>{@link #DATA7}</td> 6497 * <td></td> 6498 * </tr> 6499 * <tr> 6500 * <td>String</td> 6501 * <td>{@link #PHONETIC_NAME}</td> 6502 * <td>{@link #DATA8}</td> 6503 * <td></td> 6504 * </tr> 6505 * <tr> 6506 * <td>String</td> 6507 * <td>{@link #OFFICE_LOCATION}</td> 6508 * <td>{@link #DATA9}</td> 6509 * <td></td> 6510 * </tr> 6511 * <tr> 6512 * <td>String</td> 6513 * <td>PHONETIC_NAME_STYLE</td> 6514 * <td>{@link #DATA10}</td> 6515 * <td></td> 6516 * </tr> 6517 * </table> 6518 */ 6519 public static final class Organization implements DataColumnsWithJoins, CommonColumns, 6520 ContactCounts { 6521 /** 6522 * This utility class cannot be instantiated 6523 */ 6524 private Organization() {} 6525 6526 /** MIME type used when storing this in data table. */ 6527 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; 6528 6529 public static final int TYPE_WORK = 1; 6530 public static final int TYPE_OTHER = 2; 6531 6532 /** 6533 * The company as the user entered it. 6534 * <P>Type: TEXT</P> 6535 */ 6536 public static final String COMPANY = DATA; 6537 6538 /** 6539 * The position title at this company as the user entered it. 6540 * <P>Type: TEXT</P> 6541 */ 6542 public static final String TITLE = DATA4; 6543 6544 /** 6545 * The department at this company as the user entered it. 6546 * <P>Type: TEXT</P> 6547 */ 6548 public static final String DEPARTMENT = DATA5; 6549 6550 /** 6551 * The job description at this company as the user entered it. 6552 * <P>Type: TEXT</P> 6553 */ 6554 public static final String JOB_DESCRIPTION = DATA6; 6555 6556 /** 6557 * The symbol of this company as the user entered it. 6558 * <P>Type: TEXT</P> 6559 */ 6560 public static final String SYMBOL = DATA7; 6561 6562 /** 6563 * The phonetic name of this company as the user entered it. 6564 * <P>Type: TEXT</P> 6565 */ 6566 public static final String PHONETIC_NAME = DATA8; 6567 6568 /** 6569 * The office location of this organization. 6570 * <P>Type: TEXT</P> 6571 */ 6572 public static final String OFFICE_LOCATION = DATA9; 6573 6574 /** 6575 * The alphabet used for capturing the phonetic name. 6576 * See {@link ContactsContract.PhoneticNameStyle}. 6577 * @hide 6578 */ 6579 public static final String PHONETIC_NAME_STYLE = DATA10; 6580 6581 /** 6582 * Return the string resource that best describes the given 6583 * {@link #TYPE}. Will always return a valid resource. 6584 */ 6585 public static final int getTypeLabelResource(int type) { 6586 switch (type) { 6587 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; 6588 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; 6589 default: return com.android.internal.R.string.orgTypeCustom; 6590 } 6591 } 6592 6593 /** 6594 * Return a {@link CharSequence} that best describes the given type, 6595 * possibly substituting the given {@link #LABEL} value 6596 * for {@link #TYPE_CUSTOM}. 6597 */ 6598 public static final CharSequence getTypeLabel(Resources res, int type, 6599 CharSequence label) { 6600 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6601 return label; 6602 } else { 6603 final int labelRes = getTypeLabelResource(type); 6604 return res.getText(labelRes); 6605 } 6606 } 6607 } 6608 6609 /** 6610 * <p> 6611 * A data kind representing a relation. 6612 * </p> 6613 * <p> 6614 * You can use all columns defined for {@link ContactsContract.Data} as 6615 * well as the following aliases. 6616 * </p> 6617 * <h2>Column aliases</h2> 6618 * <table class="jd-sumtable"> 6619 * <tr> 6620 * <th>Type</th> 6621 * <th>Alias</th><th colspan='2'>Data column</th> 6622 * </tr> 6623 * <tr> 6624 * <td>String</td> 6625 * <td>{@link #NAME}</td> 6626 * <td>{@link #DATA1}</td> 6627 * <td></td> 6628 * </tr> 6629 * <tr> 6630 * <td>int</td> 6631 * <td>{@link #TYPE}</td> 6632 * <td>{@link #DATA2}</td> 6633 * <td>Allowed values are: 6634 * <p> 6635 * <ul> 6636 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6637 * <li>{@link #TYPE_ASSISTANT}</li> 6638 * <li>{@link #TYPE_BROTHER}</li> 6639 * <li>{@link #TYPE_CHILD}</li> 6640 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> 6641 * <li>{@link #TYPE_FATHER}</li> 6642 * <li>{@link #TYPE_FRIEND}</li> 6643 * <li>{@link #TYPE_MANAGER}</li> 6644 * <li>{@link #TYPE_MOTHER}</li> 6645 * <li>{@link #TYPE_PARENT}</li> 6646 * <li>{@link #TYPE_PARTNER}</li> 6647 * <li>{@link #TYPE_REFERRED_BY}</li> 6648 * <li>{@link #TYPE_RELATIVE}</li> 6649 * <li>{@link #TYPE_SISTER}</li> 6650 * <li>{@link #TYPE_SPOUSE}</li> 6651 * </ul> 6652 * </p> 6653 * </td> 6654 * </tr> 6655 * <tr> 6656 * <td>String</td> 6657 * <td>{@link #LABEL}</td> 6658 * <td>{@link #DATA3}</td> 6659 * <td></td> 6660 * </tr> 6661 * </table> 6662 */ 6663 public static final class Relation implements DataColumnsWithJoins, CommonColumns, 6664 ContactCounts { 6665 /** 6666 * This utility class cannot be instantiated 6667 */ 6668 private Relation() {} 6669 6670 /** MIME type used when storing this in data table. */ 6671 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; 6672 6673 public static final int TYPE_ASSISTANT = 1; 6674 public static final int TYPE_BROTHER = 2; 6675 public static final int TYPE_CHILD = 3; 6676 public static final int TYPE_DOMESTIC_PARTNER = 4; 6677 public static final int TYPE_FATHER = 5; 6678 public static final int TYPE_FRIEND = 6; 6679 public static final int TYPE_MANAGER = 7; 6680 public static final int TYPE_MOTHER = 8; 6681 public static final int TYPE_PARENT = 9; 6682 public static final int TYPE_PARTNER = 10; 6683 public static final int TYPE_REFERRED_BY = 11; 6684 public static final int TYPE_RELATIVE = 12; 6685 public static final int TYPE_SISTER = 13; 6686 public static final int TYPE_SPOUSE = 14; 6687 6688 /** 6689 * The name of the relative as the user entered it. 6690 * <P>Type: TEXT</P> 6691 */ 6692 public static final String NAME = DATA; 6693 6694 /** 6695 * Return the string resource that best describes the given 6696 * {@link #TYPE}. Will always return a valid resource. 6697 */ 6698 public static final int getTypeLabelResource(int type) { 6699 switch (type) { 6700 case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; 6701 case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; 6702 case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; 6703 case TYPE_DOMESTIC_PARTNER: 6704 return com.android.internal.R.string.relationTypeDomesticPartner; 6705 case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; 6706 case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; 6707 case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; 6708 case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; 6709 case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; 6710 case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; 6711 case TYPE_REFERRED_BY: 6712 return com.android.internal.R.string.relationTypeReferredBy; 6713 case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; 6714 case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; 6715 case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; 6716 default: return com.android.internal.R.string.orgTypeCustom; 6717 } 6718 } 6719 6720 /** 6721 * Return a {@link CharSequence} that best describes the given type, 6722 * possibly substituting the given {@link #LABEL} value 6723 * for {@link #TYPE_CUSTOM}. 6724 */ 6725 public static final CharSequence getTypeLabel(Resources res, int type, 6726 CharSequence label) { 6727 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6728 return label; 6729 } else { 6730 final int labelRes = getTypeLabelResource(type); 6731 return res.getText(labelRes); 6732 } 6733 } 6734 } 6735 6736 /** 6737 * <p> 6738 * A data kind representing an event. 6739 * </p> 6740 * <p> 6741 * You can use all columns defined for {@link ContactsContract.Data} as 6742 * well as the following aliases. 6743 * </p> 6744 * <h2>Column aliases</h2> 6745 * <table class="jd-sumtable"> 6746 * <tr> 6747 * <th>Type</th> 6748 * <th>Alias</th><th colspan='2'>Data column</th> 6749 * </tr> 6750 * <tr> 6751 * <td>String</td> 6752 * <td>{@link #START_DATE}</td> 6753 * <td>{@link #DATA1}</td> 6754 * <td></td> 6755 * </tr> 6756 * <tr> 6757 * <td>int</td> 6758 * <td>{@link #TYPE}</td> 6759 * <td>{@link #DATA2}</td> 6760 * <td>Allowed values are: 6761 * <p> 6762 * <ul> 6763 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 6764 * <li>{@link #TYPE_ANNIVERSARY}</li> 6765 * <li>{@link #TYPE_OTHER}</li> 6766 * <li>{@link #TYPE_BIRTHDAY}</li> 6767 * </ul> 6768 * </p> 6769 * </td> 6770 * </tr> 6771 * <tr> 6772 * <td>String</td> 6773 * <td>{@link #LABEL}</td> 6774 * <td>{@link #DATA3}</td> 6775 * <td></td> 6776 * </tr> 6777 * </table> 6778 */ 6779 public static final class Event implements DataColumnsWithJoins, CommonColumns, 6780 ContactCounts { 6781 /** 6782 * This utility class cannot be instantiated 6783 */ 6784 private Event() {} 6785 6786 /** MIME type used when storing this in data table. */ 6787 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event"; 6788 6789 public static final int TYPE_ANNIVERSARY = 1; 6790 public static final int TYPE_OTHER = 2; 6791 public static final int TYPE_BIRTHDAY = 3; 6792 6793 /** 6794 * The event start date as the user entered it. 6795 * <P>Type: TEXT</P> 6796 */ 6797 public static final String START_DATE = DATA; 6798 6799 /** 6800 * Return the string resource that best describes the given 6801 * {@link #TYPE}. Will always return a valid resource. 6802 */ 6803 public static int getTypeResource(Integer type) { 6804 if (type == null) { 6805 return com.android.internal.R.string.eventTypeOther; 6806 } 6807 switch (type) { 6808 case TYPE_ANNIVERSARY: 6809 return com.android.internal.R.string.eventTypeAnniversary; 6810 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; 6811 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; 6812 default: return com.android.internal.R.string.eventTypeCustom; 6813 } 6814 } 6815 6816 /** 6817 * Return a {@link CharSequence} that best describes the given type, 6818 * possibly substituting the given {@link #LABEL} value 6819 * for {@link #TYPE_CUSTOM}. 6820 */ 6821 public static final CharSequence getTypeLabel(Resources res, int type, 6822 CharSequence label) { 6823 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 6824 return label; 6825 } else { 6826 final int labelRes = getTypeResource(type); 6827 return res.getText(labelRes); 6828 } 6829 } 6830 } 6831 6832 /** 6833 * <p> 6834 * A data kind representing a photo for the contact. 6835 * </p> 6836 * <p> 6837 * Some sync adapters will choose to download photos in a separate 6838 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} 6839 * through {@link ContactsContract.Data#SYNC4} to store temporary 6840 * data, e.g. the image URL or ID, state of download, server-side version 6841 * of the image. It is allowed for the {@link #PHOTO} to be null. 6842 * </p> 6843 * <p> 6844 * You can use all columns defined for {@link ContactsContract.Data} as 6845 * well as the following aliases. 6846 * </p> 6847 * <h2>Column aliases</h2> 6848 * <table class="jd-sumtable"> 6849 * <tr> 6850 * <th>Type</th> 6851 * <th>Alias</th><th colspan='2'>Data column</th> 6852 * </tr> 6853 * <tr> 6854 * <td>NUMBER</td> 6855 * <td>{@link #PHOTO_FILE_ID}</td> 6856 * <td>{@link #DATA14}</td> 6857 * <td>ID of the hi-res photo file.</td> 6858 * </tr> 6859 * <tr> 6860 * <td>BLOB</td> 6861 * <td>{@link #PHOTO}</td> 6862 * <td>{@link #DATA15}</td> 6863 * <td>By convention, binary data is stored in DATA15. The thumbnail of the 6864 * photo is stored in this column.</td> 6865 * </tr> 6866 * </table> 6867 */ 6868 public static final class Photo implements DataColumnsWithJoins, ContactCounts { 6869 /** 6870 * This utility class cannot be instantiated 6871 */ 6872 private Photo() {} 6873 6874 /** MIME type used when storing this in data table. */ 6875 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; 6876 6877 /** 6878 * Photo file ID for the display photo of the raw contact. 6879 * See {@link ContactsContract.DisplayPhoto}. 6880 * <p> 6881 * Type: NUMBER 6882 */ 6883 public static final String PHOTO_FILE_ID = DATA14; 6884 6885 /** 6886 * Thumbnail photo of the raw contact. This is the raw bytes of an image 6887 * that could be inflated using {@link android.graphics.BitmapFactory}. 6888 * <p> 6889 * Type: BLOB 6890 */ 6891 public static final String PHOTO = DATA15; 6892 } 6893 6894 /** 6895 * <p> 6896 * Notes about the contact. 6897 * </p> 6898 * <p> 6899 * You can use all columns defined for {@link ContactsContract.Data} as 6900 * well as the following aliases. 6901 * </p> 6902 * <h2>Column aliases</h2> 6903 * <table class="jd-sumtable"> 6904 * <tr> 6905 * <th>Type</th> 6906 * <th>Alias</th><th colspan='2'>Data column</th> 6907 * </tr> 6908 * <tr> 6909 * <td>String</td> 6910 * <td>{@link #NOTE}</td> 6911 * <td>{@link #DATA1}</td> 6912 * <td></td> 6913 * </tr> 6914 * </table> 6915 */ 6916 public static final class Note implements DataColumnsWithJoins, ContactCounts { 6917 /** 6918 * This utility class cannot be instantiated 6919 */ 6920 private Note() {} 6921 6922 /** MIME type used when storing this in data table. */ 6923 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; 6924 6925 /** 6926 * The note text. 6927 * <P>Type: TEXT</P> 6928 */ 6929 public static final String NOTE = DATA1; 6930 } 6931 6932 /** 6933 * <p> 6934 * Group Membership. 6935 * </p> 6936 * <p> 6937 * You can use all columns defined for {@link ContactsContract.Data} as 6938 * well as the following aliases. 6939 * </p> 6940 * <h2>Column aliases</h2> 6941 * <table class="jd-sumtable"> 6942 * <tr> 6943 * <th>Type</th> 6944 * <th>Alias</th><th colspan='2'>Data column</th> 6945 * </tr> 6946 * <tr> 6947 * <td>long</td> 6948 * <td>{@link #GROUP_ROW_ID}</td> 6949 * <td>{@link #DATA1}</td> 6950 * <td></td> 6951 * </tr> 6952 * <tr> 6953 * <td>String</td> 6954 * <td>{@link #GROUP_SOURCE_ID}</td> 6955 * <td>none</td> 6956 * <td> 6957 * <p> 6958 * The sourceid of the group that this group membership refers to. 6959 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when 6960 * inserting a row. 6961 * </p> 6962 * <p> 6963 * If this field is specified, the provider will first try to 6964 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group 6965 * is found, it will use the corresponding row id. If the group is not 6966 * found, it will create one. 6967 * </td> 6968 * </tr> 6969 * </table> 6970 */ 6971 public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts { 6972 /** 6973 * This utility class cannot be instantiated 6974 */ 6975 private GroupMembership() {} 6976 6977 /** MIME type used when storing this in data table. */ 6978 public static final String CONTENT_ITEM_TYPE = 6979 "vnd.android.cursor.item/group_membership"; 6980 6981 /** 6982 * The row id of the group that this group membership refers to. Exactly one of 6983 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. 6984 * <P>Type: INTEGER</P> 6985 */ 6986 public static final String GROUP_ROW_ID = DATA1; 6987 6988 /** 6989 * The sourceid of the group that this group membership refers to. Exactly one of 6990 * this or {@link #GROUP_ROW_ID} must be set when inserting a row. 6991 * <P>Type: TEXT</P> 6992 */ 6993 public static final String GROUP_SOURCE_ID = "group_sourceid"; 6994 } 6995 6996 /** 6997 * <p> 6998 * A data kind representing a website related to the contact. 6999 * </p> 7000 * <p> 7001 * You can use all columns defined for {@link ContactsContract.Data} as 7002 * well as the following aliases. 7003 * </p> 7004 * <h2>Column aliases</h2> 7005 * <table class="jd-sumtable"> 7006 * <tr> 7007 * <th>Type</th> 7008 * <th>Alias</th><th colspan='2'>Data column</th> 7009 * </tr> 7010 * <tr> 7011 * <td>String</td> 7012 * <td>{@link #URL}</td> 7013 * <td>{@link #DATA1}</td> 7014 * <td></td> 7015 * </tr> 7016 * <tr> 7017 * <td>int</td> 7018 * <td>{@link #TYPE}</td> 7019 * <td>{@link #DATA2}</td> 7020 * <td>Allowed values are: 7021 * <p> 7022 * <ul> 7023 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 7024 * <li>{@link #TYPE_HOMEPAGE}</li> 7025 * <li>{@link #TYPE_BLOG}</li> 7026 * <li>{@link #TYPE_PROFILE}</li> 7027 * <li>{@link #TYPE_HOME}</li> 7028 * <li>{@link #TYPE_WORK}</li> 7029 * <li>{@link #TYPE_FTP}</li> 7030 * <li>{@link #TYPE_OTHER}</li> 7031 * </ul> 7032 * </p> 7033 * </td> 7034 * </tr> 7035 * <tr> 7036 * <td>String</td> 7037 * <td>{@link #LABEL}</td> 7038 * <td>{@link #DATA3}</td> 7039 * <td></td> 7040 * </tr> 7041 * </table> 7042 */ 7043 public static final class Website implements DataColumnsWithJoins, CommonColumns, 7044 ContactCounts { 7045 /** 7046 * This utility class cannot be instantiated 7047 */ 7048 private Website() {} 7049 7050 /** MIME type used when storing this in data table. */ 7051 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; 7052 7053 public static final int TYPE_HOMEPAGE = 1; 7054 public static final int TYPE_BLOG = 2; 7055 public static final int TYPE_PROFILE = 3; 7056 public static final int TYPE_HOME = 4; 7057 public static final int TYPE_WORK = 5; 7058 public static final int TYPE_FTP = 6; 7059 public static final int TYPE_OTHER = 7; 7060 7061 /** 7062 * The website URL string. 7063 * <P>Type: TEXT</P> 7064 */ 7065 public static final String URL = DATA; 7066 } 7067 7068 /** 7069 * <p> 7070 * A data kind representing a SIP address for the contact. 7071 * </p> 7072 * <p> 7073 * You can use all columns defined for {@link ContactsContract.Data} as 7074 * well as the following aliases. 7075 * </p> 7076 * <h2>Column aliases</h2> 7077 * <table class="jd-sumtable"> 7078 * <tr> 7079 * <th>Type</th> 7080 * <th>Alias</th><th colspan='2'>Data column</th> 7081 * </tr> 7082 * <tr> 7083 * <td>String</td> 7084 * <td>{@link #SIP_ADDRESS}</td> 7085 * <td>{@link #DATA1}</td> 7086 * <td></td> 7087 * </tr> 7088 * <tr> 7089 * <td>int</td> 7090 * <td>{@link #TYPE}</td> 7091 * <td>{@link #DATA2}</td> 7092 * <td>Allowed values are: 7093 * <p> 7094 * <ul> 7095 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 7096 * <li>{@link #TYPE_HOME}</li> 7097 * <li>{@link #TYPE_WORK}</li> 7098 * <li>{@link #TYPE_OTHER}</li> 7099 * </ul> 7100 * </p> 7101 * </td> 7102 * </tr> 7103 * <tr> 7104 * <td>String</td> 7105 * <td>{@link #LABEL}</td> 7106 * <td>{@link #DATA3}</td> 7107 * <td></td> 7108 * </tr> 7109 * </table> 7110 */ 7111 public static final class SipAddress implements DataColumnsWithJoins, CommonColumns, 7112 ContactCounts { 7113 /** 7114 * This utility class cannot be instantiated 7115 */ 7116 private SipAddress() {} 7117 7118 /** MIME type used when storing this in data table. */ 7119 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; 7120 7121 public static final int TYPE_HOME = 1; 7122 public static final int TYPE_WORK = 2; 7123 public static final int TYPE_OTHER = 3; 7124 7125 /** 7126 * The SIP address. 7127 * <P>Type: TEXT</P> 7128 */ 7129 public static final String SIP_ADDRESS = DATA1; 7130 // ...and TYPE and LABEL come from the CommonColumns interface. 7131 7132 /** 7133 * Return the string resource that best describes the given 7134 * {@link #TYPE}. Will always return a valid resource. 7135 */ 7136 public static final int getTypeLabelResource(int type) { 7137 switch (type) { 7138 case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; 7139 case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; 7140 case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; 7141 default: return com.android.internal.R.string.sipAddressTypeCustom; 7142 } 7143 } 7144 7145 /** 7146 * Return a {@link CharSequence} that best describes the given type, 7147 * possibly substituting the given {@link #LABEL} value 7148 * for {@link #TYPE_CUSTOM}. 7149 */ 7150 public static final CharSequence getTypeLabel(Resources res, int type, 7151 CharSequence label) { 7152 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 7153 return label; 7154 } else { 7155 final int labelRes = getTypeLabelResource(type); 7156 return res.getText(labelRes); 7157 } 7158 } 7159 } 7160 7161 /** 7162 * A data kind representing an Identity related to the contact. 7163 * <p> 7164 * This can be used as a signal by the aggregator to combine raw contacts into 7165 * contacts, e.g. if two contacts have Identity rows with 7166 * the same NAMESPACE and IDENTITY values the aggregator can know that they refer 7167 * to the same person. 7168 * </p> 7169 */ 7170 public static final class Identity implements DataColumnsWithJoins, ContactCounts { 7171 /** 7172 * This utility class cannot be instantiated 7173 */ 7174 private Identity() {} 7175 7176 /** MIME type used when storing this in data table. */ 7177 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; 7178 7179 /** 7180 * The identity string. 7181 * <P>Type: TEXT</P> 7182 */ 7183 public static final String IDENTITY = DataColumns.DATA1; 7184 7185 /** 7186 * The namespace of the identity string, e.g. "com.google" 7187 * <P>Type: TEXT</P> 7188 */ 7189 public static final String NAMESPACE = DataColumns.DATA2; 7190 } 7191 7192 /** 7193 * <p> 7194 * Convenient functionalities for "callable" data. Note that, this is NOT a separate data 7195 * kind. 7196 * </p> 7197 * <p> 7198 * This URI allows the ContactsProvider to return a unified result for "callable" data 7199 * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the 7200 * current examples for "callable", but may be expanded to the other types. 7201 * </p> 7202 * <p> 7203 * Each returned row may have a different MIMETYPE and thus different interpretation for 7204 * each column. For example the meaning for {@link Phone}'s type is different than 7205 * {@link SipAddress}'s. 7206 * </p> 7207 */ 7208 public static final class Callable implements DataColumnsWithJoins, CommonColumns, 7209 ContactCounts { 7210 /** 7211 * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only 7212 * phone numbers. 7213 */ 7214 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 7215 "callables"); 7216 /** 7217 * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable 7218 * data. 7219 */ 7220 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 7221 "filter"); 7222 } 7223 7224 /** 7225 * A special class of data items, used to refer to types of data that can be used to attempt 7226 * to start communicating with a person ({@link Phone} and {@link Email}). Note that this 7227 * is NOT a separate data kind. 7228 * 7229 * This URI allows the ContactsProvider to return a unified result for data items that users 7230 * can use to initiate communications with another contact. {@link Phone} and {@link Email} 7231 * are the current data types in this category. 7232 */ 7233 public static final class Contactables implements DataColumnsWithJoins, CommonColumns, 7234 ContactCounts { 7235 /** 7236 * The content:// style URI for these data items, which requests a directory of data 7237 * rows matching the selection criteria. 7238 */ 7239 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 7240 "contactables"); 7241 7242 /** 7243 * The content:// style URI for these data items, which allows for a query parameter to 7244 * be appended onto the end to filter for data items matching the query. 7245 */ 7246 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( 7247 Contactables.CONTENT_URI, "filter"); 7248 7249 /** 7250 * A boolean parameter for {@link Data#CONTENT_URI}. 7251 * This specifies whether or not the returned data items should be filtered to show 7252 * data items belonging to visible contacts only. 7253 */ 7254 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; 7255 } 7256 } 7257 7258 /** 7259 * @see Groups 7260 */ 7261 protected interface GroupsColumns { 7262 /** 7263 * The data set within the account that this group belongs to. This allows 7264 * multiple sync adapters for the same account type to distinguish between 7265 * each others' group data. 7266 * 7267 * This is empty by default, and is completely optional. It only needs to 7268 * be populated if multiple sync adapters are entering distinct group data 7269 * for the same account type and account name. 7270 * <P>Type: TEXT</P> 7271 */ 7272 public static final String DATA_SET = "data_set"; 7273 7274 /** 7275 * A concatenation of the account type and data set (delimited by a forward 7276 * slash) - if the data set is empty, this will be the same as the account 7277 * type. For applications that need to be aware of the data set, this can 7278 * be used instead of account type to distinguish sets of data. This is 7279 * never intended to be used for specifying accounts. 7280 * @hide 7281 */ 7282 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; 7283 7284 /** 7285 * The display title of this group. 7286 * <p> 7287 * Type: TEXT 7288 */ 7289 public static final String TITLE = "title"; 7290 7291 /** 7292 * The package name to use when creating {@link Resources} objects for 7293 * this group. This value is only designed for use when building user 7294 * interfaces, and should not be used to infer the owner. 7295 */ 7296 public static final String RES_PACKAGE = "res_package"; 7297 7298 /** 7299 * The display title of this group to load as a resource from 7300 * {@link #RES_PACKAGE}, which may be localized. 7301 * <P>Type: TEXT</P> 7302 */ 7303 public static final String TITLE_RES = "title_res"; 7304 7305 /** 7306 * Notes about the group. 7307 * <p> 7308 * Type: TEXT 7309 */ 7310 public static final String NOTES = "notes"; 7311 7312 /** 7313 * The ID of this group if it is a System Group, i.e. a group that has a special meaning 7314 * to the sync adapter, null otherwise. 7315 * <P>Type: TEXT</P> 7316 */ 7317 public static final String SYSTEM_ID = "system_id"; 7318 7319 /** 7320 * The total number of {@link Contacts} that have 7321 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only 7322 * present when querying {@link Groups#CONTENT_SUMMARY_URI}. 7323 * <p> 7324 * Type: INTEGER 7325 */ 7326 public static final String SUMMARY_COUNT = "summ_count"; 7327 7328 /** 7329 * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. 7330 * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. 7331 * 7332 * @hide 7333 */ 7334 public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = 7335 "return_group_count_per_account"; 7336 7337 /** 7338 * The total number of groups of the account that a group belongs to. 7339 * This column is available only when the parameter 7340 * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in 7341 * {@link Groups#CONTENT_SUMMARY_URI}. 7342 * 7343 * For example, when the account "A" has two groups "group1" and "group2", and the account 7344 * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for 7345 * "group3" returns "1" for this column. 7346 * 7347 * Note: This counts only non-favorites, non-auto-add, and not deleted groups. 7348 * 7349 * Type: INTEGER 7350 * @hide 7351 */ 7352 public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; 7353 7354 /** 7355 * The total number of {@link Contacts} that have both 7356 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. 7357 * Read-only value that is only present when querying 7358 * {@link Groups#CONTENT_SUMMARY_URI}. 7359 * <p> 7360 * Type: INTEGER 7361 */ 7362 public static final String SUMMARY_WITH_PHONES = "summ_phones"; 7363 7364 /** 7365 * Flag indicating if the contacts belonging to this group should be 7366 * visible in any user interface. 7367 * <p> 7368 * Type: INTEGER (boolean) 7369 */ 7370 public static final String GROUP_VISIBLE = "group_visible"; 7371 7372 /** 7373 * The "deleted" flag: "0" by default, "1" if the row has been marked 7374 * for deletion. When {@link android.content.ContentResolver#delete} is 7375 * called on a group, it is marked for deletion. The sync adaptor 7376 * deletes the group on the server and then calls ContactResolver.delete 7377 * once more, this time setting the the 7378 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to 7379 * finalize the data removal. 7380 * <P>Type: INTEGER</P> 7381 */ 7382 public static final String DELETED = "deleted"; 7383 7384 /** 7385 * Whether this group should be synced if the SYNC_EVERYTHING settings 7386 * is false for this group's account. 7387 * <p> 7388 * Type: INTEGER (boolean) 7389 */ 7390 public static final String SHOULD_SYNC = "should_sync"; 7391 7392 /** 7393 * Any newly created contacts will automatically be added to groups that have this 7394 * flag set to true. 7395 * <p> 7396 * Type: INTEGER (boolean) 7397 */ 7398 public static final String AUTO_ADD = "auto_add"; 7399 7400 /** 7401 * When a contacts is marked as a favorites it will be automatically added 7402 * to the groups that have this flag set, and when it is removed from favorites 7403 * it will be removed from these groups. 7404 * <p> 7405 * Type: INTEGER (boolean) 7406 */ 7407 public static final String FAVORITES = "favorites"; 7408 7409 /** 7410 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or 7411 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. 7412 * <P>Type: INTEGER</P> 7413 */ 7414 public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; 7415 } 7416 7417 /** 7418 * Constants for the groups table. Only per-account groups are supported. 7419 * <h2>Columns</h2> 7420 * <table class="jd-sumtable"> 7421 * <tr> 7422 * <th colspan='4'>Groups</th> 7423 * </tr> 7424 * <tr> 7425 * <td>long</td> 7426 * <td>{@link #_ID}</td> 7427 * <td>read-only</td> 7428 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. 7429 * In other words, it would be a really bad idea to delete and reinsert a 7430 * group. A sync adapter should always do an update instead.</td> 7431 * </tr> 7432 # <tr> 7433 * <td>String</td> 7434 * <td>{@link #DATA_SET}</td> 7435 * <td>read/write-once</td> 7436 * <td> 7437 * <p> 7438 * The data set within the account that this group belongs to. This allows 7439 * multiple sync adapters for the same account type to distinguish between 7440 * each others' group data. The combination of {@link #ACCOUNT_TYPE}, 7441 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data 7442 * that is associated with a single sync adapter. 7443 * </p> 7444 * <p> 7445 * This is empty by default, and is completely optional. It only needs to 7446 * be populated if multiple sync adapters are entering distinct data for 7447 * the same account type and account name. 7448 * </p> 7449 * <p> 7450 * It should be set at the time the group is inserted and never changed 7451 * afterwards. 7452 * </p> 7453 * </td> 7454 * </tr> 7455 * <tr> 7456 * <td>String</td> 7457 * <td>{@link #TITLE}</td> 7458 * <td>read/write</td> 7459 * <td>The display title of this group.</td> 7460 * </tr> 7461 * <tr> 7462 * <td>String</td> 7463 * <td>{@link #NOTES}</td> 7464 * <td>read/write</td> 7465 * <td>Notes about the group.</td> 7466 * </tr> 7467 * <tr> 7468 * <td>String</td> 7469 * <td>{@link #SYSTEM_ID}</td> 7470 * <td>read/write</td> 7471 * <td>The ID of this group if it is a System Group, i.e. a group that has a 7472 * special meaning to the sync adapter, null otherwise.</td> 7473 * </tr> 7474 * <tr> 7475 * <td>int</td> 7476 * <td>{@link #SUMMARY_COUNT}</td> 7477 * <td>read-only</td> 7478 * <td>The total number of {@link Contacts} that have 7479 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value 7480 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> 7481 * </tr> 7482 * <tr> 7483 * <td>int</td> 7484 * <td>{@link #SUMMARY_WITH_PHONES}</td> 7485 * <td>read-only</td> 7486 * <td>The total number of {@link Contacts} that have both 7487 * {@link CommonDataKinds.GroupMembership} in this group, and also have 7488 * phone numbers. Read-only value that is only present when querying 7489 * {@link Groups#CONTENT_SUMMARY_URI}.</td> 7490 * </tr> 7491 * <tr> 7492 * <td>int</td> 7493 * <td>{@link #GROUP_VISIBLE}</td> 7494 * <td>read-only</td> 7495 * <td>Flag indicating if the contacts belonging to this group should be 7496 * visible in any user interface. Allowed values: 0 and 1.</td> 7497 * </tr> 7498 * <tr> 7499 * <td>int</td> 7500 * <td>{@link #DELETED}</td> 7501 * <td>read/write</td> 7502 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked 7503 * for deletion. When {@link android.content.ContentResolver#delete} is 7504 * called on a group, it is marked for deletion. The sync adaptor deletes 7505 * the group on the server and then calls ContactResolver.delete once more, 7506 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} 7507 * query parameter to finalize the data removal.</td> 7508 * </tr> 7509 * <tr> 7510 * <td>int</td> 7511 * <td>{@link #SHOULD_SYNC}</td> 7512 * <td>read/write</td> 7513 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings 7514 * is false for this group's account.</td> 7515 * </tr> 7516 * </table> 7517 */ 7518 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { 7519 /** 7520 * This utility class cannot be instantiated 7521 */ 7522 private Groups() { 7523 } 7524 7525 /** 7526 * The content:// style URI for this table 7527 */ 7528 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); 7529 7530 /** 7531 * The content:// style URI for this table joined with details data from 7532 * {@link ContactsContract.Data}. 7533 */ 7534 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, 7535 "groups_summary"); 7536 7537 /** 7538 * The MIME type of a directory of groups. 7539 */ 7540 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; 7541 7542 /** 7543 * The MIME type of a single group. 7544 */ 7545 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; 7546 7547 public static EntityIterator newEntityIterator(Cursor cursor) { 7548 return new EntityIteratorImpl(cursor); 7549 } 7550 7551 private static class EntityIteratorImpl extends CursorEntityIterator { 7552 public EntityIteratorImpl(Cursor cursor) { 7553 super(cursor); 7554 } 7555 7556 @Override 7557 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { 7558 // we expect the cursor is already at the row we need to read from 7559 final ContentValues values = new ContentValues(); 7560 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); 7561 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); 7562 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); 7563 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); 7564 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); 7565 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); 7566 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); 7567 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); 7568 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); 7569 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); 7570 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); 7571 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); 7572 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); 7573 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); 7574 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); 7575 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); 7576 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); 7577 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); 7578 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); 7579 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); 7580 cursor.moveToNext(); 7581 return new Entity(values); 7582 } 7583 } 7584 } 7585 7586 /** 7587 * <p> 7588 * Constants for the contact aggregation exceptions table, which contains 7589 * aggregation rules overriding those used by automatic aggregation. This 7590 * type only supports query and update. Neither insert nor delete are 7591 * supported. 7592 * </p> 7593 * <h2>Columns</h2> 7594 * <table class="jd-sumtable"> 7595 * <tr> 7596 * <th colspan='4'>AggregationExceptions</th> 7597 * </tr> 7598 * <tr> 7599 * <td>int</td> 7600 * <td>{@link #TYPE}</td> 7601 * <td>read/write</td> 7602 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, 7603 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> 7604 * </tr> 7605 * <tr> 7606 * <td>long</td> 7607 * <td>{@link #RAW_CONTACT_ID1}</td> 7608 * <td>read/write</td> 7609 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that 7610 * the rule applies to.</td> 7611 * </tr> 7612 * <tr> 7613 * <td>long</td> 7614 * <td>{@link #RAW_CONTACT_ID2}</td> 7615 * <td>read/write</td> 7616 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact 7617 * that the rule applies to.</td> 7618 * </tr> 7619 * </table> 7620 */ 7621 public static final class AggregationExceptions implements BaseColumns { 7622 /** 7623 * This utility class cannot be instantiated 7624 */ 7625 private AggregationExceptions() {} 7626 7627 /** 7628 * The content:// style URI for this table 7629 */ 7630 public static final Uri CONTENT_URI = 7631 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); 7632 7633 /** 7634 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 7635 */ 7636 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; 7637 7638 /** 7639 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception 7640 */ 7641 public static final String CONTENT_ITEM_TYPE = 7642 "vnd.android.cursor.item/aggregation_exception"; 7643 7644 /** 7645 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or 7646 * {@link #TYPE_AUTOMATIC}. 7647 * 7648 * <P>Type: INTEGER</P> 7649 */ 7650 public static final String TYPE = "type"; 7651 7652 /** 7653 * Allows the provider to automatically decide whether the specified raw contacts should 7654 * be included in the same aggregate contact or not. 7655 */ 7656 public static final int TYPE_AUTOMATIC = 0; 7657 7658 /** 7659 * Makes sure that the specified raw contacts are included in the same 7660 * aggregate contact. 7661 */ 7662 public static final int TYPE_KEEP_TOGETHER = 1; 7663 7664 /** 7665 * Makes sure that the specified raw contacts are NOT included in the same 7666 * aggregate contact. 7667 */ 7668 public static final int TYPE_KEEP_SEPARATE = 2; 7669 7670 /** 7671 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. 7672 */ 7673 public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; 7674 7675 /** 7676 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule 7677 * applies to. 7678 */ 7679 public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; 7680 } 7681 7682 /** 7683 * @see Settings 7684 */ 7685 protected interface SettingsColumns { 7686 /** 7687 * The name of the account instance to which this row belongs. 7688 * <P>Type: TEXT</P> 7689 */ 7690 public static final String ACCOUNT_NAME = "account_name"; 7691 7692 /** 7693 * The type of account to which this row belongs, which when paired with 7694 * {@link #ACCOUNT_NAME} identifies a specific account. 7695 * <P>Type: TEXT</P> 7696 */ 7697 public static final String ACCOUNT_TYPE = "account_type"; 7698 7699 /** 7700 * The data set within the account that this row belongs to. This allows 7701 * multiple sync adapters for the same account type to distinguish between 7702 * each others' data. 7703 * 7704 * This is empty by default, and is completely optional. It only needs to 7705 * be populated if multiple sync adapters are entering distinct data for 7706 * the same account type and account name. 7707 * <P>Type: TEXT</P> 7708 */ 7709 public static final String DATA_SET = "data_set"; 7710 7711 /** 7712 * Depending on the mode defined by the sync-adapter, this flag controls 7713 * the top-level sync behavior for this data source. 7714 * <p> 7715 * Type: INTEGER (boolean) 7716 */ 7717 public static final String SHOULD_SYNC = "should_sync"; 7718 7719 /** 7720 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} 7721 * entries should be visible in any user interface. 7722 * <p> 7723 * Type: INTEGER (boolean) 7724 */ 7725 public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; 7726 7727 /** 7728 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any 7729 * {@link Groups#SHOULD_SYNC} under this account have been marked as 7730 * unsynced. 7731 */ 7732 public static final String ANY_UNSYNCED = "any_unsynced"; 7733 7734 /** 7735 * Read-only count of {@link Contacts} from a specific source that have 7736 * no {@link CommonDataKinds.GroupMembership} entries. 7737 * <p> 7738 * Type: INTEGER 7739 */ 7740 public static final String UNGROUPED_COUNT = "summ_count"; 7741 7742 /** 7743 * Read-only count of {@link Contacts} from a specific source that have 7744 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. 7745 * <p> 7746 * Type: INTEGER 7747 */ 7748 public static final String UNGROUPED_WITH_PHONES = "summ_phones"; 7749 } 7750 7751 /** 7752 * <p> 7753 * Contacts-specific settings for various {@link Account}'s. 7754 * </p> 7755 * <h2>Columns</h2> 7756 * <table class="jd-sumtable"> 7757 * <tr> 7758 * <th colspan='4'>Settings</th> 7759 * </tr> 7760 * <tr> 7761 * <td>String</td> 7762 * <td>{@link #ACCOUNT_NAME}</td> 7763 * <td>read/write-once</td> 7764 * <td>The name of the account instance to which this row belongs.</td> 7765 * </tr> 7766 * <tr> 7767 * <td>String</td> 7768 * <td>{@link #ACCOUNT_TYPE}</td> 7769 * <td>read/write-once</td> 7770 * <td>The type of account to which this row belongs, which when paired with 7771 * {@link #ACCOUNT_NAME} identifies a specific account.</td> 7772 * </tr> 7773 * <tr> 7774 * <td>int</td> 7775 * <td>{@link #SHOULD_SYNC}</td> 7776 * <td>read/write</td> 7777 * <td>Depending on the mode defined by the sync-adapter, this flag controls 7778 * the top-level sync behavior for this data source.</td> 7779 * </tr> 7780 * <tr> 7781 * <td>int</td> 7782 * <td>{@link #UNGROUPED_VISIBLE}</td> 7783 * <td>read/write</td> 7784 * <td>Flag indicating if contacts without any 7785 * {@link CommonDataKinds.GroupMembership} entries should be visible in any 7786 * user interface.</td> 7787 * </tr> 7788 * <tr> 7789 * <td>int</td> 7790 * <td>{@link #ANY_UNSYNCED}</td> 7791 * <td>read-only</td> 7792 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any 7793 * {@link Groups#SHOULD_SYNC} under this account have been marked as 7794 * unsynced.</td> 7795 * </tr> 7796 * <tr> 7797 * <td>int</td> 7798 * <td>{@link #UNGROUPED_COUNT}</td> 7799 * <td>read-only</td> 7800 * <td>Read-only count of {@link Contacts} from a specific source that have 7801 * no {@link CommonDataKinds.GroupMembership} entries.</td> 7802 * </tr> 7803 * <tr> 7804 * <td>int</td> 7805 * <td>{@link #UNGROUPED_WITH_PHONES}</td> 7806 * <td>read-only</td> 7807 * <td>Read-only count of {@link Contacts} from a specific source that have 7808 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone 7809 * numbers.</td> 7810 * </tr> 7811 * </table> 7812 */ 7813 public static final class Settings implements SettingsColumns { 7814 /** 7815 * This utility class cannot be instantiated 7816 */ 7817 private Settings() { 7818 } 7819 7820 /** 7821 * The content:// style URI for this table 7822 */ 7823 public static final Uri CONTENT_URI = 7824 Uri.withAppendedPath(AUTHORITY_URI, "settings"); 7825 7826 /** 7827 * The MIME-type of {@link #CONTENT_URI} providing a directory of 7828 * settings. 7829 */ 7830 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; 7831 7832 /** 7833 * The MIME-type of {@link #CONTENT_URI} providing a single setting. 7834 */ 7835 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; 7836 } 7837 7838 /** 7839 * API for inquiring about the general status of the provider. 7840 */ 7841 public static final class ProviderStatus { 7842 7843 /** 7844 * Not instantiable. 7845 */ 7846 private ProviderStatus() { 7847 } 7848 7849 /** 7850 * The content:// style URI for this table. Requests to this URI can be 7851 * performed on the UI thread because they are always unblocking. 7852 */ 7853 public static final Uri CONTENT_URI = 7854 Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); 7855 7856 /** 7857 * The MIME-type of {@link #CONTENT_URI} providing a directory of 7858 * settings. 7859 */ 7860 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; 7861 7862 /** 7863 * An integer representing the current status of the provider. 7864 */ 7865 public static final String STATUS = "status"; 7866 7867 /** 7868 * Default status of the provider. 7869 */ 7870 public static final int STATUS_NORMAL = 0; 7871 7872 /** 7873 * The status used when the provider is in the process of upgrading. Contacts 7874 * are temporarily unaccessible. 7875 */ 7876 public static final int STATUS_UPGRADING = 1; 7877 7878 /** 7879 * The status used during a locale change. 7880 */ 7881 public static final int STATUS_CHANGING_LOCALE = 3; 7882 7883 /** 7884 * The status that indicates that there are no accounts and no contacts 7885 * on the device. 7886 */ 7887 public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4; 7888 } 7889 7890 /** 7891 * <p> 7892 * API allowing applications to send usage information for each {@link Data} row to the 7893 * Contacts Provider. Applications can also clear all usage information. 7894 * </p> 7895 * <p> 7896 * With the feedback, Contacts Provider may return more contextually appropriate results for 7897 * Data listing, typically supplied with 7898 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, 7899 * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, 7900 * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit 7901 * from better ranked (sorted) lists in applications that show auto-complete list. 7902 * </p> 7903 * <p> 7904 * There is no guarantee for how this feedback is used, or even whether it is used at all. 7905 * The ranking algorithm will make best efforts to use the feedback data, but the exact 7906 * implementation, the storage data structures as well as the resulting sort order is device 7907 * and version specific and can change over time. 7908 * </p> 7909 * <p> 7910 * When updating usage information, users of this API need to use 7911 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed 7912 * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as 7913 * its last path. They also need to append a query parameter to the Uri, to specify the type of 7914 * the communication, which enables the Contacts Provider to differentiate between kinds of 7915 * interactions using the same contact data field (for example a phone number can be used to 7916 * make phone calls or send SMS). 7917 * </p> 7918 * <p> 7919 * Selection and selectionArgs are ignored and must be set to null. To get data ids, 7920 * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} 7921 * toward {@link Data#CONTENT_URI}. 7922 * </p> 7923 * <p> 7924 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive 7925 * integer when successful, and returns 0 if no contact with that id was found. 7926 * </p> 7927 * <p> 7928 * Example: 7929 * <pre> 7930 * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() 7931 * .appendPath(TextUtils.join(",", dataIds)) 7932 * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, 7933 * DataUsageFeedback.USAGE_TYPE_CALL) 7934 * .build(); 7935 * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; 7936 * </pre> 7937 * </p> 7938 * <p> 7939 * Applications can also clear all usage information with: 7940 * <pre> 7941 * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; 7942 * </pre> 7943 * </p> 7944 */ 7945 public static final class DataUsageFeedback { 7946 7947 /** 7948 * The content:// style URI for sending usage feedback. 7949 * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. 7950 */ 7951 public static final Uri FEEDBACK_URI = 7952 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); 7953 7954 /** 7955 * The content:// style URI for deleting all usage information. 7956 * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. 7957 * The {@code where} and {@code selectionArgs} parameters are ignored. 7958 */ 7959 public static final Uri DELETE_USAGE_URI = 7960 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); 7961 7962 /** 7963 * <p> 7964 * Name for query parameter specifying the type of data usage. 7965 * </p> 7966 */ 7967 public static final String USAGE_TYPE = "type"; 7968 7969 /** 7970 * <p> 7971 * Type of usage for voice interaction, which includes phone call, voice chat, and 7972 * video chat. 7973 * </p> 7974 */ 7975 public static final String USAGE_TYPE_CALL = "call"; 7976 7977 /** 7978 * <p> 7979 * Type of usage for text interaction involving longer messages, which includes email. 7980 * </p> 7981 */ 7982 public static final String USAGE_TYPE_LONG_TEXT = "long_text"; 7983 7984 /** 7985 * <p> 7986 * Type of usage for text interaction involving shorter messages, which includes SMS, 7987 * text chat with email addresses. 7988 * </p> 7989 */ 7990 public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; 7991 } 7992 7993 /** 7994 * <p> 7995 * Contact-specific information about whether or not a contact has been pinned by the user 7996 * at a particular position within the system contact application's user interface. 7997 * </p> 7998 * 7999 * <p> 8000 * This pinning information can be used by individual applications to customize how 8001 * they order particular pinned contacts. For example, a Dialer application could 8002 * use pinned information to order user-pinned contacts in a top row of favorites. 8003 * </p> 8004 * 8005 * <p> 8006 * It is possible for two or more contacts to occupy the same pinned position (due 8007 * to aggregation and sync), so this pinning information should be used on a best-effort 8008 * basis to order contacts in-application rather than an absolute guide on where a contact 8009 * should be positioned. Contacts returned by the ContactsProvider will not be ordered based 8010 * on this information, so it is up to the client application to reorder these contacts within 8011 * their own UI adhering to (or ignoring as appropriate) information stored in the pinned 8012 * column. 8013 * </p> 8014 * 8015 * <p> 8016 * By default, unpinned contacts will have a pinned position of 8017 * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive 8018 * integers that are greater than 1. 8019 * </p> 8020 */ 8021 public static final class PinnedPositions { 8022 /** 8023 * The method to invoke in order to undemote a formerly demoted contact. The contact id of 8024 * the contact must be provided as an argument. If the contact was not previously demoted, 8025 * nothing will be done. 8026 * @hide 8027 */ 8028 public static final String UNDEMOTE_METHOD = "undemote"; 8029 8030 /** 8031 * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing 8032 * will be done. 8033 * 8034 * @param contentResolver to perform the undemote operation on. 8035 * @param contactId the id of the contact to undemote. 8036 */ 8037 public static void undemote(ContentResolver contentResolver, long contactId) { 8038 contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD, 8039 String.valueOf(contactId), null); 8040 } 8041 8042 /** 8043 * Pins a contact at a provided position, or unpins a contact. 8044 * 8045 * @param contentResolver to perform the pinning operation on. 8046 * @param pinnedPosition the position to pin the contact at. To unpin a contact, use 8047 * {@link PinnedPositions#UNPINNED}. 8048 */ 8049 public static void pin( 8050 ContentResolver contentResolver, long contactId, int pinnedPosition) { 8051 final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); 8052 final ContentValues values = new ContentValues(); 8053 values.put(Contacts.PINNED, pinnedPosition); 8054 contentResolver.update(uri, values, null, null); 8055 } 8056 8057 /** 8058 * Default value for the pinned position of an unpinned contact. 8059 */ 8060 public static final int UNPINNED = 0; 8061 8062 /** 8063 * Value of pinned position for a contact that a user has indicated should be considered 8064 * of the lowest priority. It is up to the client application to determine how to present 8065 * such a contact - for example all the way at the bottom of a contact list, or simply 8066 * just hidden from view. 8067 */ 8068 public static final int DEMOTED = -1; 8069 } 8070 8071 /** 8072 * Helper methods to display QuickContact dialogs that display all the information belonging to 8073 * a specific {@link Contacts} entry. 8074 */ 8075 public static final class QuickContact { 8076 /** 8077 * Action used to launch the system contacts application and bring up a QuickContact dialog 8078 * for the provided {@link Contacts} entry. 8079 */ 8080 public static final String ACTION_QUICK_CONTACT = 8081 "android.provider.action.QUICK_CONTACT"; 8082 8083 /** 8084 * Extra used to specify pivot dialog location in screen coordinates. 8085 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. 8086 * @hide 8087 */ 8088 @Deprecated 8089 public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT"; 8090 8091 /** 8092 * Extra used to specify size of pivot dialog. 8093 * @hide 8094 */ 8095 public static final String EXTRA_MODE = "android.provider.extra.MODE"; 8096 8097 /** 8098 * Extra used to indicate a list of specific MIME-types to exclude and not display in the 8099 * QuickContacts dialog. Stored as a {@link String} array. 8100 */ 8101 public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; 8102 8103 /** 8104 * Small QuickContact mode, usually presented with minimal actions. 8105 */ 8106 public static final int MODE_SMALL = 1; 8107 8108 /** 8109 * Medium QuickContact mode, includes actions and light summary describing 8110 * the {@link Contacts} entry being shown. This may include social 8111 * status and presence details. 8112 */ 8113 public static final int MODE_MEDIUM = 2; 8114 8115 /** 8116 * Large QuickContact mode, includes actions and larger, card-like summary 8117 * of the {@link Contacts} entry being shown. This may include detailed 8118 * information, such as a photo. 8119 */ 8120 public static final int MODE_LARGE = 3; 8121 8122 /** 8123 * Constructs the QuickContacts intent with a view's rect. 8124 * @hide 8125 */ 8126 public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, 8127 int mode, String[] excludeMimes) { 8128 // Find location and bounds of target view, adjusting based on the 8129 // assumed local density. 8130 final float appScale = context.getResources().getCompatibilityInfo().applicationScale; 8131 final int[] pos = new int[2]; 8132 target.getLocationOnScreen(pos); 8133 8134 final Rect rect = new Rect(); 8135 rect.left = (int) (pos[0] * appScale + 0.5f); 8136 rect.top = (int) (pos[1] * appScale + 0.5f); 8137 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); 8138 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); 8139 8140 return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); 8141 } 8142 8143 /** 8144 * Constructs the QuickContacts intent. 8145 * @hide 8146 */ 8147 public static Intent composeQuickContactsIntent(Context context, Rect target, 8148 Uri lookupUri, int mode, String[] excludeMimes) { 8149 // When launching from an Activiy, we don't want to start a new task, but otherwise 8150 // we *must* start a new task. (Otherwise startActivity() would crash.) 8151 Context actualContext = context; 8152 while ((actualContext instanceof ContextWrapper) 8153 && !(actualContext instanceof Activity)) { 8154 actualContext = ((ContextWrapper) actualContext).getBaseContext(); 8155 } 8156 final int intentFlags = ((actualContext instanceof Activity) 8157 ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) 8158 // Workaround for b/16898764. Declaring singleTop in manifest doesn't work. 8159 | Intent.FLAG_ACTIVITY_SINGLE_TOP; 8160 8161 // Launch pivot dialog through intent for now 8162 final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); 8163 8164 intent.setData(lookupUri); 8165 intent.setSourceBounds(target); 8166 intent.putExtra(EXTRA_MODE, mode); 8167 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); 8168 return intent; 8169 } 8170 8171 /** 8172 * Trigger a dialog that lists the various methods of interacting with 8173 * the requested {@link Contacts} entry. This may be based on available 8174 * {@link ContactsContract.Data} rows under that contact, and may also 8175 * include social status and presence details. 8176 * 8177 * @param context The parent {@link Context} that may be used as the 8178 * parent for this dialog. 8179 * @param target Specific {@link View} from your layout that this dialog 8180 * should be centered around. In particular, if the dialog 8181 * has a "callout" arrow, it will be pointed and centered 8182 * around this {@link View}. 8183 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 8184 * {@link Uri} that describes a specific contact to feature 8185 * in this dialog. 8186 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 8187 * {@link #MODE_LARGE}, indicating the desired dialog size, 8188 * when supported. 8189 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 8190 * to exclude when showing this dialog. For example, when 8191 * already viewing the contact details card, this can be used 8192 * to omit the details entry from the dialog. 8193 */ 8194 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, 8195 String[] excludeMimes) { 8196 // Trigger with obtained rectangle 8197 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, 8198 excludeMimes); 8199 startActivityWithErrorToast(context, intent); 8200 } 8201 8202 /** 8203 * Trigger a dialog that lists the various methods of interacting with 8204 * the requested {@link Contacts} entry. This may be based on available 8205 * {@link ContactsContract.Data} rows under that contact, and may also 8206 * include social status and presence details. 8207 * 8208 * @param context The parent {@link Context} that may be used as the 8209 * parent for this dialog. 8210 * @param target Specific {@link Rect} that this dialog should be 8211 * centered around, in screen coordinates. In particular, if 8212 * the dialog has a "callout" arrow, it will be pointed and 8213 * centered around this {@link Rect}. If you are running at a 8214 * non-native density, you need to manually adjust using 8215 * {@link DisplayMetrics#density} before calling. 8216 * @param lookupUri A 8217 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 8218 * {@link Uri} that describes a specific contact to feature 8219 * in this dialog. 8220 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 8221 * {@link #MODE_LARGE}, indicating the desired dialog size, 8222 * when supported. 8223 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 8224 * to exclude when showing this dialog. For example, when 8225 * already viewing the contact details card, this can be used 8226 * to omit the details entry from the dialog. 8227 */ 8228 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, 8229 String[] excludeMimes) { 8230 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, 8231 excludeMimes); 8232 startActivityWithErrorToast(context, intent); 8233 } 8234 8235 private static void startActivityWithErrorToast(Context context, Intent intent) { 8236 try { 8237 context.startActivity(intent); 8238 } catch (ActivityNotFoundException e) { 8239 Toast.makeText(context, com.android.internal.R.string.quick_contacts_not_available, 8240 Toast.LENGTH_SHORT).show(); 8241 } 8242 } 8243 } 8244 8245 /** 8246 * Helper class for accessing full-size photos by photo file ID. 8247 * <p> 8248 * Usage example: 8249 * <dl> 8250 * <dt>Retrieving a full-size photo by photo file ID (see 8251 * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) 8252 * </dt> 8253 * <dd> 8254 * <pre> 8255 * public InputStream openDisplayPhoto(long photoFileId) { 8256 * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); 8257 * try { 8258 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( 8259 * displayPhotoUri, "r"); 8260 * return fd.createInputStream(); 8261 * } catch (IOException e) { 8262 * return null; 8263 * } 8264 * } 8265 * </pre> 8266 * </dd> 8267 * </dl> 8268 * </p> 8269 */ 8270 public static final class DisplayPhoto { 8271 /** 8272 * no public constructor since this is a utility class 8273 */ 8274 private DisplayPhoto() {} 8275 8276 /** 8277 * The content:// style URI for this class, which allows access to full-size photos, 8278 * given a key. 8279 */ 8280 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); 8281 8282 /** 8283 * This URI allows the caller to query for the maximum dimensions of a display photo 8284 * or thumbnail. Requests to this URI can be performed on the UI thread because 8285 * they are always unblocking. 8286 */ 8287 public static final Uri CONTENT_MAX_DIMENSIONS_URI = 8288 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); 8289 8290 /** 8291 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will 8292 * contain this column, populated with the maximum height and width (in pixels) 8293 * that will be stored for a display photo. Larger photos will be down-sized to 8294 * fit within a square of this many pixels. 8295 */ 8296 public static final String DISPLAY_MAX_DIM = "display_max_dim"; 8297 8298 /** 8299 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will 8300 * contain this column, populated with the height and width (in pixels) for photo 8301 * thumbnails. 8302 */ 8303 public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; 8304 } 8305 8306 /** 8307 * Contains helper classes used to create or manage {@link android.content.Intent Intents} 8308 * that involve contacts. 8309 */ 8310 public static final class Intents { 8311 /** 8312 * This is the intent that is fired when a search suggestion is clicked on. 8313 */ 8314 public static final String SEARCH_SUGGESTION_CLICKED = 8315 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; 8316 8317 /** 8318 * This is the intent that is fired when a search suggestion for dialing a number 8319 * is clicked on. 8320 */ 8321 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = 8322 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; 8323 8324 /** 8325 * This is the intent that is fired when a search suggestion for creating a contact 8326 * is clicked on. 8327 */ 8328 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = 8329 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; 8330 8331 /** 8332 * This is the intent that is fired when the contacts database is created. <p> The 8333 * READ_CONTACT permission is required to receive these broadcasts. 8334 */ 8335 public static final String CONTACTS_DATABASE_CREATED = 8336 "android.provider.Contacts.DATABASE_CREATED"; 8337 8338 /** 8339 * Starts an Activity that lets the user pick a contact to attach an image to. 8340 * After picking the contact it launches the image cropper in face detection mode. 8341 */ 8342 public static final String ATTACH_IMAGE = 8343 "com.android.contacts.action.ATTACH_IMAGE"; 8344 8345 /** 8346 * This is the intent that is fired when the user clicks the "invite to the network" button 8347 * on a contact. Only sent to an activity which is explicitly registered by a contact 8348 * provider which supports the "invite to the network" feature. 8349 * <p> 8350 * {@link Intent#getData()} contains the lookup URI for the contact. 8351 */ 8352 public static final String INVITE_CONTACT = 8353 "com.android.contacts.action.INVITE_CONTACT"; 8354 8355 /** 8356 * Takes as input a data URI with a mailto: or tel: scheme. If a single 8357 * contact exists with the given data it will be shown. If no contact 8358 * exists, a dialog will ask the user if they want to create a new 8359 * contact with the provided details filled in. If multiple contacts 8360 * share the data the user will be prompted to pick which contact they 8361 * want to view. 8362 * <p> 8363 * For <code>mailto:</code> URIs, the scheme specific portion must be a 8364 * raw email address, such as one built using 8365 * {@link Uri#fromParts(String, String, String)}. 8366 * <p> 8367 * For <code>tel:</code> URIs, the scheme specific portion is compared 8368 * to existing numbers using the standard caller ID lookup algorithm. 8369 * The number must be properly encoded, for example using 8370 * {@link Uri#fromParts(String, String, String)}. 8371 * <p> 8372 * Any extras from the {@link Insert} class will be passed along to the 8373 * create activity if there are no contacts to show. 8374 * <p> 8375 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip 8376 * prompting the user when the contact doesn't exist. 8377 */ 8378 public static final String SHOW_OR_CREATE_CONTACT = 8379 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; 8380 8381 /** 8382 * Starts an Activity that lets the user select the multiple phones from a 8383 * list of phone numbers which come from the contacts or 8384 * {@link #EXTRA_PHONE_URIS}. 8385 * <p> 8386 * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} 8387 * could belong to the contacts or not, and will be selected by default. 8388 * <p> 8389 * The user's selection will be returned from 8390 * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} 8391 * if the resultCode is 8392 * {@link android.app.Activity#RESULT_OK}, the array of picked phone 8393 * numbers are in the Intent's 8394 * {@link #EXTRA_PHONE_URIS}; otherwise, the 8395 * {@link android.app.Activity#RESULT_CANCELED} is returned if the user 8396 * left the Activity without changing the selection. 8397 * 8398 * @hide 8399 */ 8400 public static final String ACTION_GET_MULTIPLE_PHONES = 8401 "com.android.contacts.action.GET_MULTIPLE_PHONES"; 8402 8403 /** 8404 * A broadcast action which is sent when any change has been made to the profile, such 8405 * as the profile name or the picture. A receiver must have 8406 * the android.permission.READ_PROFILE permission. 8407 * 8408 * @hide 8409 */ 8410 public static final String ACTION_PROFILE_CHANGED = 8411 "android.provider.Contacts.PROFILE_CHANGED"; 8412 8413 /** 8414 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new 8415 * contact if no matching contact found. Otherwise, default behavior is 8416 * to prompt user with dialog before creating. 8417 * <p> 8418 * Type: BOOLEAN 8419 */ 8420 public static final String EXTRA_FORCE_CREATE = 8421 "com.android.contacts.action.FORCE_CREATE"; 8422 8423 /** 8424 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact 8425 * description to be shown when prompting user about creating a new 8426 * contact. 8427 * <p> 8428 * Type: STRING 8429 */ 8430 public static final String EXTRA_CREATE_DESCRIPTION = 8431 "com.android.contacts.action.CREATE_DESCRIPTION"; 8432 8433 /** 8434 * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. 8435 * <p> 8436 * The phone numbers want to be picked by default should be passed in as 8437 * input value. These phone numbers could belong to the contacts or not. 8438 * <p> 8439 * The phone numbers which were picked by the user are returned as output 8440 * value. 8441 * <p> 8442 * Type: array of URIs, the tel URI is used for the phone numbers which don't 8443 * belong to any contact, the content URI is used for phone id in contacts. 8444 * 8445 * @hide 8446 */ 8447 public static final String EXTRA_PHONE_URIS = 8448 "com.android.contacts.extra.PHONE_URIS"; 8449 8450 /** 8451 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 8452 * dialog location using screen coordinates. When not specified, the 8453 * dialog will be centered. 8454 * 8455 * @hide 8456 */ 8457 @Deprecated 8458 public static final String EXTRA_TARGET_RECT = "target_rect"; 8459 8460 /** 8461 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 8462 * desired dialog style, usually a variation on size. One of 8463 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. 8464 * 8465 * @hide 8466 */ 8467 @Deprecated 8468 public static final String EXTRA_MODE = "mode"; 8469 8470 /** 8471 * Value for {@link #EXTRA_MODE} to show a small-sized dialog. 8472 * 8473 * @hide 8474 */ 8475 @Deprecated 8476 public static final int MODE_SMALL = 1; 8477 8478 /** 8479 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. 8480 * 8481 * @hide 8482 */ 8483 @Deprecated 8484 public static final int MODE_MEDIUM = 2; 8485 8486 /** 8487 * Value for {@link #EXTRA_MODE} to show a large-sized dialog. 8488 * 8489 * @hide 8490 */ 8491 @Deprecated 8492 public static final int MODE_LARGE = 3; 8493 8494 /** 8495 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate 8496 * a list of specific MIME-types to exclude and not display. Stored as a 8497 * {@link String} array. 8498 * 8499 * @hide 8500 */ 8501 @Deprecated 8502 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; 8503 8504 /** 8505 * Convenience class that contains string constants used 8506 * to create contact {@link android.content.Intent Intents}. 8507 */ 8508 public static final class Insert { 8509 /** The action code to use when adding a contact */ 8510 public static final String ACTION = Intent.ACTION_INSERT; 8511 8512 /** 8513 * If present, forces a bypass of quick insert mode. 8514 */ 8515 public static final String FULL_MODE = "full_mode"; 8516 8517 /** 8518 * The extra field for the contact name. 8519 * <P>Type: String</P> 8520 */ 8521 public static final String NAME = "name"; 8522 8523 // TODO add structured name values here. 8524 8525 /** 8526 * The extra field for the contact phonetic name. 8527 * <P>Type: String</P> 8528 */ 8529 public static final String PHONETIC_NAME = "phonetic_name"; 8530 8531 /** 8532 * The extra field for the contact company. 8533 * <P>Type: String</P> 8534 */ 8535 public static final String COMPANY = "company"; 8536 8537 /** 8538 * The extra field for the contact job title. 8539 * <P>Type: String</P> 8540 */ 8541 public static final String JOB_TITLE = "job_title"; 8542 8543 /** 8544 * The extra field for the contact notes. 8545 * <P>Type: String</P> 8546 */ 8547 public static final String NOTES = "notes"; 8548 8549 /** 8550 * The extra field for the contact phone number. 8551 * <P>Type: String</P> 8552 */ 8553 public static final String PHONE = "phone"; 8554 8555 /** 8556 * The extra field for the contact phone number type. 8557 * <P>Type: Either an integer value from 8558 * {@link CommonDataKinds.Phone}, 8559 * or a string specifying a custom label.</P> 8560 */ 8561 public static final String PHONE_TYPE = "phone_type"; 8562 8563 /** 8564 * The extra field for the phone isprimary flag. 8565 * <P>Type: boolean</P> 8566 */ 8567 public static final String PHONE_ISPRIMARY = "phone_isprimary"; 8568 8569 /** 8570 * The extra field for an optional second contact phone number. 8571 * <P>Type: String</P> 8572 */ 8573 public static final String SECONDARY_PHONE = "secondary_phone"; 8574 8575 /** 8576 * The extra field for an optional second contact phone number type. 8577 * <P>Type: Either an integer value from 8578 * {@link CommonDataKinds.Phone}, 8579 * or a string specifying a custom label.</P> 8580 */ 8581 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; 8582 8583 /** 8584 * The extra field for an optional third contact phone number. 8585 * <P>Type: String</P> 8586 */ 8587 public static final String TERTIARY_PHONE = "tertiary_phone"; 8588 8589 /** 8590 * The extra field for an optional third contact phone number type. 8591 * <P>Type: Either an integer value from 8592 * {@link CommonDataKinds.Phone}, 8593 * or a string specifying a custom label.</P> 8594 */ 8595 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; 8596 8597 /** 8598 * The extra field for the contact email address. 8599 * <P>Type: String</P> 8600 */ 8601 public static final String EMAIL = "email"; 8602 8603 /** 8604 * The extra field for the contact email type. 8605 * <P>Type: Either an integer value from 8606 * {@link CommonDataKinds.Email} 8607 * or a string specifying a custom label.</P> 8608 */ 8609 public static final String EMAIL_TYPE = "email_type"; 8610 8611 /** 8612 * The extra field for the email isprimary flag. 8613 * <P>Type: boolean</P> 8614 */ 8615 public static final String EMAIL_ISPRIMARY = "email_isprimary"; 8616 8617 /** 8618 * The extra field for an optional second contact email address. 8619 * <P>Type: String</P> 8620 */ 8621 public static final String SECONDARY_EMAIL = "secondary_email"; 8622 8623 /** 8624 * The extra field for an optional second contact email type. 8625 * <P>Type: Either an integer value from 8626 * {@link CommonDataKinds.Email} 8627 * or a string specifying a custom label.</P> 8628 */ 8629 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; 8630 8631 /** 8632 * The extra field for an optional third contact email address. 8633 * <P>Type: String</P> 8634 */ 8635 public static final String TERTIARY_EMAIL = "tertiary_email"; 8636 8637 /** 8638 * The extra field for an optional third contact email type. 8639 * <P>Type: Either an integer value from 8640 * {@link CommonDataKinds.Email} 8641 * or a string specifying a custom label.</P> 8642 */ 8643 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; 8644 8645 /** 8646 * The extra field for the contact postal address. 8647 * <P>Type: String</P> 8648 */ 8649 public static final String POSTAL = "postal"; 8650 8651 /** 8652 * The extra field for the contact postal address type. 8653 * <P>Type: Either an integer value from 8654 * {@link CommonDataKinds.StructuredPostal} 8655 * or a string specifying a custom label.</P> 8656 */ 8657 public static final String POSTAL_TYPE = "postal_type"; 8658 8659 /** 8660 * The extra field for the postal isprimary flag. 8661 * <P>Type: boolean</P> 8662 */ 8663 public static final String POSTAL_ISPRIMARY = "postal_isprimary"; 8664 8665 /** 8666 * The extra field for an IM handle. 8667 * <P>Type: String</P> 8668 */ 8669 public static final String IM_HANDLE = "im_handle"; 8670 8671 /** 8672 * The extra field for the IM protocol 8673 */ 8674 public static final String IM_PROTOCOL = "im_protocol"; 8675 8676 /** 8677 * The extra field for the IM isprimary flag. 8678 * <P>Type: boolean</P> 8679 */ 8680 public static final String IM_ISPRIMARY = "im_isprimary"; 8681 8682 /** 8683 * The extra field that allows the client to supply multiple rows of 8684 * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} 8685 * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of 8686 * {@link ContentValues}, one per data row. Supplying this extra is 8687 * similar to inserting multiple rows into the {@link Data} table, 8688 * except the user gets a chance to see and edit them before saving. 8689 * Each ContentValues object must have a value for {@link Data#MIMETYPE}. 8690 * If supplied values are not visible in the editor UI, they will be 8691 * dropped. Duplicate data will dropped. Some fields 8692 * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically 8693 * adjusted to comply with the constraints of the specific account type. 8694 * For example, an Exchange contact can only have one phone numbers of type Home, 8695 * so the contact editor may choose a different type for this phone number to 8696 * avoid dropping the valueable part of the row, which is the phone number. 8697 * <p> 8698 * Example: 8699 * <pre> 8700 * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); 8701 * 8702 * ContentValues row1 = new ContentValues(); 8703 * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); 8704 * row1.put(Organization.COMPANY, "Android"); 8705 * data.add(row1); 8706 * 8707 * ContentValues row2 = new ContentValues(); 8708 * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); 8709 * row2.put(Email.TYPE, Email.TYPE_CUSTOM); 8710 * row2.put(Email.LABEL, "Green Bot"); 8711 * row2.put(Email.ADDRESS, "android@android.com"); 8712 * data.add(row2); 8713 * 8714 * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); 8715 * intent.putParcelableArrayListExtra(Insert.DATA, data); 8716 * 8717 * startActivity(intent); 8718 * </pre> 8719 */ 8720 public static final String DATA = "data"; 8721 8722 /** 8723 * Used to specify the account in which to create the new contact. 8724 * <p> 8725 * If this value is not provided, the user is presented with a disambiguation 8726 * dialog to chose an account 8727 * <p> 8728 * Type: {@link Account} 8729 */ 8730 public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT"; 8731 8732 /** 8733 * Used to specify the data set within the account in which to create the 8734 * new contact. 8735 * <p> 8736 * This value is optional - if it is not specified, the contact will be 8737 * created in the base account, with no data set. 8738 * <p> 8739 * Type: String 8740 */ 8741 public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET"; 8742 } 8743 } 8744} 8745