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