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