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