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