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