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