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