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