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