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