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