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