ContactsContract.java revision 274dc9d35fdf5d0464f74071a9a8f14e497d4d5f
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.Intent; 27import android.content.CursorEntityIterator; 28import android.content.EntityIterator; 29import android.content.Entity; 30import android.content.res.Resources; 31import android.database.Cursor; 32import android.database.DatabaseUtils; 33import android.database.sqlite.SQLiteException; 34import android.graphics.Rect; 35import android.net.Uri; 36import android.os.RemoteException; 37import android.text.TextUtils; 38import android.util.Pair; 39import android.view.View; 40 41import java.io.ByteArrayInputStream; 42import java.io.InputStream; 43 44/** 45 * <p> 46 * The contract between the contacts provider and applications. Contains 47 * definitions for the supported URIs and columns. These APIs supersede 48 * {@link Contacts}. 49 * </p> 50 * <h3>Overview</h3> 51 * <p> 52 * ContactsContract defines an extensible database of contact-related 53 * information. Contact information is stored in a three-tier data model: 54 * </p> 55 * <blockquote> 56 * <p> 57 * The {@link Data} table contains all kinds of personal data: phone numbers, 58 * email addresses etc. The list of data kinds that can be stored in this table 59 * is open-ended. There is a predefined set of common kinds, but any application 60 * can add its own data kinds. 61 * </p> 62 * <p> 63 * A row in the {@link RawContacts} table represents a set of Data describing a 64 * person and associated with a single account. 65 * </p> 66 * <p> 67 * A row in the {@link Contacts} table represents an aggregate of one or more 68 * RawContacts presumably describing the same person. 69 * </p> 70 * </blockquote> 71 * <p> 72 * Other tables include: 73 * </p> 74 * <blockquote> 75 * <p> 76 * {@link Groups}, which contains information about raw contact groups - the 77 * current API does not support the notion of groups spanning multiple accounts. 78 * </p> 79 * <p> 80 * {@link StatusUpdates}, which contains social status updates including IM 81 * availability. 82 * </p> 83 * <p> 84 * {@link AggregationExceptions}, which is used for manual aggregation and 85 * disaggregation of raw contacts 86 * </p> 87 * <p> 88 * {@link Settings}, which contains visibility and sync settings for accounts 89 * and groups. 90 * </p> 91 * <p> 92 * {@link SyncState}, which contains free-form data maintained on behalf of sync 93 * adapters 94 * </p> 95 * <p> 96 * {@link PhoneLookup}, which is used for quick caller-ID lookup</id> 97 * </blockquote> 98 */ 99@SuppressWarnings("unused") 100public final class ContactsContract { 101 /** The authority for the contacts provider */ 102 public static final String AUTHORITY = "com.android.contacts"; 103 /** A content:// style uri to the authority for the contacts provider */ 104 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); 105 106 /** 107 * An optional insert, update or delete URI parameter that allows the caller 108 * to specify that it is a sync adapter. The default value is false. If true 109 * the dirty flag is not automatically set and the "syncToNetwork" parameter 110 * is set to false when calling 111 * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. 112 */ 113 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; 114 115 /** 116 * A query parameter key used to specify the package that is requesting a query. 117 * This is used for restricting data based on package name. 118 * 119 * @hide 120 */ 121 public static final String REQUESTING_PACKAGE_PARAM_KEY = "requesting_package"; 122 123 /** 124 * @hide should be removed when users are updated to refer to SyncState 125 * @deprecated use SyncState instead 126 */ 127 @Deprecated 128 public interface SyncStateColumns extends SyncStateContract.Columns { 129 } 130 131 /** 132 * A table provided for sync adapters to use for storing private sync state data. 133 * 134 * @see SyncStateContract 135 */ 136 public static final class SyncState implements SyncStateContract.Columns { 137 /** 138 * This utility class cannot be instantiated 139 */ 140 private SyncState() {} 141 142 public static final String CONTENT_DIRECTORY = 143 SyncStateContract.Constants.CONTENT_DIRECTORY; 144 145 /** 146 * The content:// style URI for this table 147 */ 148 public static final Uri CONTENT_URI = 149 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); 150 151 /** 152 * @see android.provider.SyncStateContract.Helpers#get 153 */ 154 public static byte[] get(ContentProviderClient provider, Account account) 155 throws RemoteException { 156 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); 157 } 158 159 /** 160 * @see android.provider.SyncStateContract.Helpers#get 161 */ 162 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) 163 throws RemoteException { 164 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); 165 } 166 167 /** 168 * @see android.provider.SyncStateContract.Helpers#set 169 */ 170 public static void set(ContentProviderClient provider, Account account, byte[] data) 171 throws RemoteException { 172 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); 173 } 174 175 /** 176 * @see android.provider.SyncStateContract.Helpers#newSetOperation 177 */ 178 public static ContentProviderOperation newSetOperation(Account account, byte[] data) { 179 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); 180 } 181 } 182 183 /** 184 * Generic columns for use by sync adapters. The specific functions of 185 * these columns are private to the sync adapter. Other clients of the API 186 * should not attempt to either read or write this column. 187 * 188 * @see RawContacts 189 * @see Groups 190 */ 191 protected interface BaseSyncColumns { 192 193 /** Generic column for use by sync adapters. */ 194 public static final String SYNC1 = "sync1"; 195 /** Generic column for use by sync adapters. */ 196 public static final String SYNC2 = "sync2"; 197 /** Generic column for use by sync adapters. */ 198 public static final String SYNC3 = "sync3"; 199 /** Generic column for use by sync adapters. */ 200 public static final String SYNC4 = "sync4"; 201 } 202 203 /** 204 * Columns that appear when each row of a table belongs to a specific 205 * account, including sync information that an account may need. 206 * 207 * @see RawContacts 208 * @see Groups 209 */ 210 protected interface SyncColumns extends BaseSyncColumns { 211 /** 212 * The name of the account instance to which this row belongs, which when paired with 213 * {@link #ACCOUNT_TYPE} identifies a specific account. 214 * <P>Type: TEXT</P> 215 */ 216 public static final String ACCOUNT_NAME = "account_name"; 217 218 /** 219 * The type of account to which this row belongs, which when paired with 220 * {@link #ACCOUNT_NAME} identifies a specific account. 221 * <P>Type: TEXT</P> 222 */ 223 public static final String ACCOUNT_TYPE = "account_type"; 224 225 /** 226 * String that uniquely identifies this row to its source account. 227 * <P>Type: TEXT</P> 228 */ 229 public static final String SOURCE_ID = "sourceid"; 230 231 /** 232 * Version number that is updated whenever this row or its related data 233 * changes. 234 * <P>Type: INTEGER</P> 235 */ 236 public static final String VERSION = "version"; 237 238 /** 239 * Flag indicating that {@link #VERSION} has changed, and this row needs 240 * to be synchronized by its owning account. 241 * <P>Type: INTEGER (boolean)</P> 242 */ 243 public static final String DIRTY = "dirty"; 244 } 245 246 /** 247 * @see Contacts 248 * @see RawContacts 249 * @see ContactsContract.Data 250 * @see PhoneLookup 251 * @see ContactsContract.Contacts.AggregationSuggestions 252 */ 253 protected interface ContactOptionsColumns { 254 /** 255 * The number of times a contact has been contacted 256 * <P>Type: INTEGER</P> 257 */ 258 public static final String TIMES_CONTACTED = "times_contacted"; 259 260 /** 261 * The last time a contact was contacted. 262 * <P>Type: INTEGER</P> 263 */ 264 public static final String LAST_TIME_CONTACTED = "last_time_contacted"; 265 266 /** 267 * Is the contact starred? 268 * <P>Type: INTEGER (boolean)</P> 269 */ 270 public static final String STARRED = "starred"; 271 272 /** 273 * A custom ringtone associated with a contact. Not always present. 274 * <P>Type: TEXT (URI to the ringtone)</P> 275 */ 276 public static final String CUSTOM_RINGTONE = "custom_ringtone"; 277 278 /** 279 * Whether the contact should always be sent to voicemail. Not always 280 * present. 281 * <P>Type: INTEGER (0 for false, 1 for true)</P> 282 */ 283 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; 284 } 285 286 /** 287 * @see Contacts 288 * @see ContactsContract.Data 289 * @see PhoneLookup 290 * @see ContactsContract.Contacts.AggregationSuggestions 291 */ 292 protected interface ContactsColumns { 293 /** 294 * The display name for the contact. 295 * <P>Type: TEXT</P> 296 */ 297 public static final String DISPLAY_NAME = "display_name"; 298 299 /** 300 * Reference to the row in the RawContacts table holding the contact name. 301 * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> 302 * @hide 303 */ 304 public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; 305 306 /** 307 * Reference to the row in the data table holding the photo. 308 * <P>Type: INTEGER REFERENCES data(_id)</P> 309 */ 310 public static final String PHOTO_ID = "photo_id"; 311 312 /** 313 * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of 314 * any {@link CommonDataKinds.GroupMembership} for this contact. 315 */ 316 public static final String IN_VISIBLE_GROUP = "in_visible_group"; 317 318 /** 319 * An indicator of whether this contact has at least one phone number. "1" if there is 320 * at least one phone number, "0" otherwise. 321 * <P>Type: INTEGER</P> 322 */ 323 public static final String HAS_PHONE_NUMBER = "has_phone_number"; 324 325 /** 326 * An opaque value that contains hints on how to find the contact if 327 * its row id changed as a result of a sync or aggregation. 328 */ 329 public static final String LOOKUP_KEY = "lookup"; 330 } 331 332 /** 333 * @see Contacts 334 */ 335 protected interface ContactStatusColumns { 336 /** 337 * Contact presence status. See {@link StatusUpdates} for individual status 338 * definitions. 339 * <p>Type: NUMBER</p> 340 */ 341 public static final String CONTACT_PRESENCE = "contact_presence"; 342 343 /** 344 * Contact's latest status update. 345 * <p>Type: TEXT</p> 346 */ 347 public static final String CONTACT_STATUS = "contact_status"; 348 349 /** 350 * The absolute time in milliseconds when the latest status was 351 * inserted/updated. 352 * <p>Type: NUMBER</p> 353 */ 354 public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; 355 356 /** 357 * The package containing resources for this status: label and icon. 358 * <p>Type: TEXT</p> 359 */ 360 public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; 361 362 /** 363 * The resource ID of the label describing the source of contact 364 * status, e.g. "Google Talk". This resource is scoped by the 365 * {@link #CONTACT_STATUS_RES_PACKAGE}. 366 * <p>Type: NUMBER</p> 367 */ 368 public static final String CONTACT_STATUS_LABEL = "contact_status_label"; 369 370 /** 371 * The resource ID of the icon for the source of contact status. This 372 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. 373 * <p>Type: NUMBER</p> 374 */ 375 public static final String CONTACT_STATUS_ICON = "contact_status_icon"; 376 } 377 378 /** 379 * Constants for the contacts table, which contains a record per aggregate 380 * of raw contacts representing the same person. 381 * <h3>Operations</h3> 382 * <dl> 383 * <dt><b>Insert</b></dt> 384 * <dd>A Contact cannot be created explicitly. When a raw contact is 385 * inserted, the provider will first try to find a Contact representing the 386 * same person. If one is found, the raw contact's 387 * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate 388 * Contact. If no match is found, the provider automatically inserts a new 389 * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column 390 * of the newly inserted raw contact.</dd> 391 * <dt><b>Update</b></dt> 392 * <dd>Only certain columns of Contact are modifiable: 393 * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, 394 * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of 395 * these columns on the Contact also changes them on all constituent raw 396 * contacts.</dd> 397 * <dt><b>Delete</b></dt> 398 * <dd>Be careful with deleting Contacts! Deleting an aggregate contact 399 * deletes all constituent raw contacts. The corresponding sync adapters 400 * will notice the deletions of their respective raw contacts and remove 401 * them from their back end storage.</dd> 402 * <dt><b>Query</b></dt> 403 * <dd> 404 * <ul> 405 * <li>If you need to read an individual contact, consider using 406 * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> 407 * <li>If you need to look up a contact by the phone number, use 408 * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, 409 * which is optimized for this purpose.</li> 410 * <li>If you need to look up a contact by partial name, e.g. to produce 411 * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. 412 * <li>If you need to look up a contact by some data element like email 413 * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. 414 * The result will contain contact ID, name etc. 415 * </ul> 416 * </dd> 417 * </dl> 418 * <h2>Columns</h2> 419 * <table class="jd-sumtable"> 420 * <tr> 421 * <th colspan='4'>Contacts</th> 422 * </tr> 423 * <tr> 424 * <td>long</td> 425 * <td>{@link #_ID}</td> 426 * <td>read-only</td> 427 * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> 428 * </tr> 429 * <tr> 430 * <td>String</td> 431 * <td>{@link #LOOKUP_KEY}</td> 432 * <td>read-only</td> 433 * <td>An opaque value that contains hints on how to find the contact if its 434 * row id changed as a result of a sync or aggregation.</td> 435 * </tr> 436 * <tr> 437 * <td>long</td> 438 * <td>NAME_RAW_CONTACT_ID</td> 439 * <td>read-only</td> 440 * <td>The ID of the raw contact that contributes the display name 441 * to the aggregate contact. During aggregation one of the constituent 442 * raw contacts is chosen using a heuristic: a longer name or a name 443 * with more diacritic marks or more upper case characters is chosen.</td> 444 * </tr> 445 * <tr> 446 * <td>String</td> 447 * <td>{@link #DISPLAY_NAME}</td> 448 * <td>read-only</td> 449 * <td>The display name for the contact. It is the display name 450 * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID 451 * column.</td> 452 * </tr> 453 * <tr> 454 * <td>long</td> 455 * <td>{@link #PHOTO_ID}</td> 456 * <td>read-only</td> 457 * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. 458 * That row has the mime type 459 * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field 460 * is computed automatically based on the 461 * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of 462 * that mime type.</td> 463 * </tr> 464 * <tr> 465 * <td>int</td> 466 * <td>{@link #IN_VISIBLE_GROUP}</td> 467 * <td>read-only</td> 468 * <td>An indicator of whether this contact is supposed to be visible in the 469 * UI. "1" if the contact has at least one raw contact that belongs to a 470 * visible group; "0" otherwise.</td> 471 * </tr> 472 * <tr> 473 * <td>int</td> 474 * <td>{@link #HAS_PHONE_NUMBER}</td> 475 * <td>read-only</td> 476 * <td>An indicator of whether this contact has at least one phone number. 477 * "1" if there is at least one phone number, "0" otherwise.</td> 478 * </tr> 479 * <tr> 480 * <td>int</td> 481 * <td>{@link #TIMES_CONTACTED}</td> 482 * <td>read/write</td> 483 * <td>The number of times the contact has been contacted. See 484 * {@link #markAsContacted}. When raw contacts are aggregated, this field is 485 * computed automatically as the maximum number of times contacted among all 486 * constituent raw contacts. Setting this field automatically changes the 487 * corresponding field on all constituent raw contacts.</td> 488 * </tr> 489 * <tr> 490 * <td>long</td> 491 * <td>{@link #LAST_TIME_CONTACTED}</td> 492 * <td>read/write</td> 493 * <td>The timestamp of the last time the contact was contacted. See 494 * {@link #markAsContacted}. Setting this field also automatically 495 * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, 496 * this field is computed automatically as the latest time contacted of all 497 * constituent raw contacts. Setting this field automatically changes the 498 * corresponding field on all constituent raw contacts.</td> 499 * </tr> 500 * <tr> 501 * <td>int</td> 502 * <td>{@link #STARRED}</td> 503 * <td>read/write</td> 504 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. 505 * When raw contacts are aggregated, this field is automatically computed: 506 * if any constituent raw contacts are starred, then this field is set to 507 * '1'. Setting this field automatically changes the corresponding field on 508 * all constituent raw contacts.</td> 509 * </tr> 510 * <tr> 511 * <td>String</td> 512 * <td>{@link #CUSTOM_RINGTONE}</td> 513 * <td>read/write</td> 514 * <td>A custom ringtone associated with a contact. Typically this is the 515 * URI returned by an activity launched with the 516 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> 517 * </tr> 518 * <tr> 519 * <td>int</td> 520 * <td>{@link #SEND_TO_VOICEMAIL}</td> 521 * <td>read/write</td> 522 * <td>An indicator of whether calls from this contact should be forwarded 523 * directly to voice mail ('1') or not ('0'). When raw contacts are 524 * aggregated, this field is automatically computed: if <i>all</i> 525 * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set 526 * to '1'. Setting this field automatically changes the corresponding field 527 * on all constituent raw contacts.</td> 528 * </tr> 529 * <tr> 530 * <td>int</td> 531 * <td>{@link #CONTACT_PRESENCE}</td> 532 * <td>read-only</td> 533 * <td>Contact IM presence status. See {@link StatusUpdates} for individual 534 * status definitions. Automatically computed as the highest presence of all 535 * constituent raw contacts. The provider may choose not to store this value 536 * in persistent storage. The expectation is that presence status will be 537 * updated on a regular basic.</td> 538 * </tr> 539 * <tr> 540 * <td>String</td> 541 * <td>{@link #CONTACT_STATUS}</td> 542 * <td>read-only</td> 543 * <td>Contact's latest status update. Automatically computed as the latest 544 * of all constituent raw contacts' status updates.</td> 545 * </tr> 546 * <tr> 547 * <td>long</td> 548 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> 549 * <td>read-only</td> 550 * <td>The absolute time in milliseconds when the latest status was 551 * inserted/updated.</td> 552 * </tr> 553 * <tr> 554 * <td>String</td> 555 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> 556 * <td>read-only</td> 557 * <td> The package containing resources for this status: label and icon.</td> 558 * </tr> 559 * <tr> 560 * <td>long</td> 561 * <td>{@link #CONTACT_STATUS_LABEL}</td> 562 * <td>read-only</td> 563 * <td>The resource ID of the label describing the source of contact status, 564 * e.g. "Google Talk". This resource is scoped by the 565 * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> 566 * </tr> 567 * <tr> 568 * <td>long</td> 569 * <td>{@link #CONTACT_STATUS_ICON}</td> 570 * <td>read-only</td> 571 * <td>The resource ID of the icon for the source of contact status. This 572 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> 573 * </tr> 574 * </table> 575 */ 576 public static class Contacts implements BaseColumns, ContactsColumns, 577 ContactOptionsColumns, ContactStatusColumns { 578 /** 579 * This utility class cannot be instantiated 580 */ 581 private Contacts() {} 582 583 /** 584 * The content:// style URI for this table 585 */ 586 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); 587 588 /** 589 * A content:// style URI for this table that should be used to create 590 * shortcuts or otherwise create long-term links to contacts. This URI 591 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. 592 * It can optionally also have a "/" and last known contact ID appended after 593 * that. This "complete" format is an important optimization and is highly recommended. 594 * <p> 595 * As long as the contact's row ID remains the same, this URI is 596 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes 597 * as a result of a sync or aggregation, this URI will look up the 598 * contact using indirect information (sync IDs or constituent raw 599 * contacts). 600 * <p> 601 * Lookup key should be appended unencoded - it is stored in the encoded 602 * form, ready for use in a URI. 603 */ 604 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, 605 "lookup"); 606 607 /** 608 * Base {@link Uri} for referencing a single {@link Contacts} entry, 609 * created by appending {@link #LOOKUP_KEY} using 610 * {@link Uri#withAppendedPath(Uri, String)}. Provides 611 * {@link OpenableColumns} columns when queried, or returns the 612 * referenced contact formatted as a vCard when opened through 613 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. 614 */ 615 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, 616 "as_vcard"); 617 618 /** 619 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the 620 * requested {@link Contacts} entry. 621 * 622 * @param contactUri A {@link #CONTENT_URI} row, or an existing 623 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. 624 */ 625 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { 626 final Cursor c = resolver.query(contactUri, new String[] { 627 Contacts.LOOKUP_KEY, Contacts._ID 628 }, null, null, null); 629 if (c == null) { 630 return null; 631 } 632 633 try { 634 if (c.moveToFirst()) { 635 final String lookupKey = c.getString(0); 636 final long contactId = c.getLong(1); 637 return getLookupUri(contactId, lookupKey); 638 } 639 } finally { 640 c.close(); 641 } 642 return null; 643 } 644 645 /** 646 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the 647 * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. 648 */ 649 public static Uri getLookupUri(long contactId, String lookupKey) { 650 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, 651 lookupKey), contactId); 652 } 653 654 /** 655 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. 656 * <p> 657 * Returns null if the contact cannot be found. 658 */ 659 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { 660 if (lookupUri == null) { 661 return null; 662 } 663 664 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); 665 if (c == null) { 666 return null; 667 } 668 669 try { 670 if (c.moveToFirst()) { 671 long contactId = c.getLong(0); 672 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); 673 } 674 } finally { 675 c.close(); 676 } 677 return null; 678 } 679 680 /** 681 * Mark a contact as having been contacted. 682 * 683 * @param resolver the ContentResolver to use 684 * @param contactId the person who was contacted 685 */ 686 public static void markAsContacted(ContentResolver resolver, long contactId) { 687 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); 688 ContentValues values = new ContentValues(); 689 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. 690 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis()); 691 resolver.update(uri, values, null, null); 692 } 693 694 /** 695 * The content:// style URI used for "type-to-filter" functionality on the 696 * {@link #CONTENT_URI} URI. The filter string will be used to match 697 * various parts of the contact name. The filter argument should be passed 698 * as an additional path segment after this URI. 699 */ 700 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( 701 CONTENT_URI, "filter"); 702 703 /** 704 * The content:// style URI for this table joined with useful data from 705 * {@link ContactsContract.Data}, filtered to include only starred contacts 706 * and the most frequently contacted contacts. 707 */ 708 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( 709 CONTENT_URI, "strequent"); 710 711 /** 712 * The content:// style URI used for "type-to-filter" functionality on the 713 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match 714 * various parts of the contact name. The filter argument should be passed 715 * as an additional path segment after this URI. 716 */ 717 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( 718 CONTENT_STREQUENT_URI, "filter"); 719 720 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( 721 CONTENT_URI, "group"); 722 723 /** 724 * The MIME type of {@link #CONTENT_URI} providing a directory of 725 * people. 726 */ 727 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; 728 729 /** 730 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 731 * person. 732 */ 733 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; 734 735 /** 736 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 737 * person. 738 */ 739 public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; 740 741 /** 742 * A sub-directory of a single contact that contains all of the constituent raw contact 743 * {@link ContactsContract.Data} rows. 744 */ 745 public static final class Data implements BaseColumns, DataColumns { 746 /** 747 * no public constructor since this is a utility class 748 */ 749 private Data() {} 750 751 /** 752 * The directory twig for this sub-table 753 */ 754 public static final String CONTENT_DIRECTORY = "data"; 755 } 756 757 /** 758 * <p> 759 * A <i>read-only</i> sub-directory of a single contact aggregate that 760 * contains all aggregation suggestions (other contacts). The 761 * aggregation suggestions are computed based on approximate data 762 * matches with this contact. 763 * </p> 764 * <p> 765 * <i>Note: this query may be expensive! If you need to use it in bulk, 766 * make sure the user experience is acceptable when the query runs for a 767 * long time.</i> 768 * <p> 769 * Usage example: 770 * 771 * <pre> 772 * Uri uri = Contacts.CONTENT_URI.buildUpon() 773 * .appendEncodedPath(String.valueOf(contactId)) 774 * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) 775 * .appendQueryParameter("limit", "3") 776 * .build() 777 * Cursor cursor = getContentResolver().query(suggestionsUri, 778 * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, 779 * null, null, null); 780 * </pre> 781 * 782 * </p> 783 */ 784 // TODO: add ContactOptionsColumns, ContactStatusColumns 785 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns { 786 /** 787 * No public constructor since this is a utility class 788 */ 789 private AggregationSuggestions() {} 790 791 /** 792 * The directory twig for this sub-table. The URI can be followed by an optional 793 * type-to-filter, similar to 794 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. 795 */ 796 public static final String CONTENT_DIRECTORY = "suggestions"; 797 } 798 799 /** 800 * A <i>read-only</i> sub-directory of a single contact that contains 801 * the contact's primary photo. 802 * <p> 803 * Usage example: 804 * 805 * <pre> 806 * public InputStream openPhoto(long contactId) { 807 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); 808 * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); 809 * Cursor cursor = getContentResolver().query(photoUri, 810 * new String[] {Contacts.Photo.PHOTO}, null, null, null); 811 * if (cursor == null) { 812 * return null; 813 * } 814 * try { 815 * if (cursor.moveToFirst()) { 816 * byte[] data = cursor.getBlob(0); 817 * if (data != null) { 818 * return new ByteArrayInputStream(data); 819 * } 820 * } 821 * } finally { 822 * cursor.close(); 823 * } 824 * return null; 825 * } 826 * </pre> 827 * 828 * </p> 829 * <p>You should also consider using the convenience method 830 * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri)} 831 * </p> 832 */ 833 // TODO: change DataColumns to DataColumnsWithJoins 834 public static final class Photo implements BaseColumns, DataColumns { 835 /** 836 * no public constructor since this is a utility class 837 */ 838 private Photo() {} 839 840 /** 841 * The directory twig for this sub-table 842 */ 843 public static final String CONTENT_DIRECTORY = "photo"; 844 845 /** 846 * Thumbnail photo of the raw contact. This is the raw bytes of an image 847 * that could be inflated using {@link android.graphics.BitmapFactory}. 848 * <p> 849 * Type: BLOB 850 * @hide TODO: Unhide in a separate CL 851 */ 852 public static final String PHOTO = DATA15; 853 } 854 855 /** 856 * Opens an InputStream for the contacts's default photo and returns the 857 * photo as a byte stream. If there is not photo null will be returned. 858 * 859 * @param contactUri the contact whose photo should be used 860 * @return an InputStream of the photo, or null if no photo is present 861 */ 862 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { 863 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); 864 if (photoUri == null) { 865 return null; 866 } 867 Cursor cursor = cr.query(photoUri, 868 new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null); 869 try { 870 if (cursor == null || !cursor.moveToNext()) { 871 return null; 872 } 873 byte[] data = cursor.getBlob(0); 874 if (data == null) { 875 return null; 876 } 877 return new ByteArrayInputStream(data); 878 } finally { 879 if (cursor != null) { 880 cursor.close(); 881 } 882 } 883 } 884 } 885 886 protected interface RawContactsColumns { 887 /** 888 * A reference to the {@link ContactsContract.Contacts#_ID} that this 889 * data belongs to. 890 * <P>Type: INTEGER</P> 891 */ 892 public static final String CONTACT_ID = "contact_id"; 893 894 /** 895 * Flag indicating that this {@link RawContacts} entry and its children have 896 * been restricted to specific platform apps. 897 * <P>Type: INTEGER (boolean)</P> 898 * 899 * @hide until finalized in future platform release 900 */ 901 public static final String IS_RESTRICTED = "is_restricted"; 902 903 /** 904 * The aggregation mode for this contact. 905 * <P>Type: INTEGER</P> 906 */ 907 public static final String AGGREGATION_MODE = "aggregation_mode"; 908 909 /** 910 * The "deleted" flag: "0" by default, "1" if the row has been marked 911 * for deletion. When {@link android.content.ContentResolver#delete} is 912 * called on a raw contact, it is marked for deletion and removed from its 913 * aggregate contact. The sync adaptor deletes the raw contact on the server and 914 * then calls ContactResolver.delete once more, this time passing the 915 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize 916 * the data removal. 917 * <P>Type: INTEGER</P> 918 */ 919 public static final String DELETED = "deleted"; 920 } 921 922 /** 923 * Constants for the raw contacts table, which contains the base contact 924 * information per sync source. Sync adapters and contact management apps 925 * are the primary consumers of this API. 926 * <h3>Operations</h3> 927 * <dl> 928 * <dt><b>Insert</b></dt> 929 * <dd>There are two mechanisms that can be used to insert a raw contact: incremental and 930 * batch. The incremental method is more traditional but less efficient. It should be used 931 * only if the constituent data rows are unavailable at the time the raw contact is created: 932 * <pre> 933 * ContentValues values = new ContentValues(); 934 * values.put(RawContacts.ACCOUNT_TYPE, accountType); 935 * values.put(RawContacts.ACCOUNT_NAME, accountName); 936 * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); 937 * long rawContactId = ContentUris.parseId(rawContactUri); 938 * </pre> 939 * <p> 940 * Once data rows are available, insert those. For example, here's how you would insert 941 * a name: 942 * 943 * <pre> 944 * values.clear(); 945 * values.put(Data.RAW_CONTACT_ID, rawContactId); 946 * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); 947 * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); 948 * getContentResolver().insert(Data.CONTENT_URI, values); 949 * </pre> 950 * </p> 951 * <p> 952 * The batch method is by far preferred. It inserts the raw contact and its 953 * constituent data rows in a single database transaction 954 * and causes at most one aggregation pass. 955 * <pre> 956 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 957 * int rawContactInsertIndex = ops.size(); 958 * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) 959 * .withValue(RawContacts.ACCOUNT_TYPE, accountType) 960 * .withValue(RawContacts.ACCOUNT_NAME, accountName) 961 * .build()); 962 * 963 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 964 * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) 965 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 966 * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") 967 * .build()); 968 * 969 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 970 * </pre> 971 * </p> 972 * <p> 973 * Please note the use of back reference in the construction of the 974 * {@link ContentProviderOperation}. It allows an operation to use the result of 975 * a previous operation by referring to it by its index in the batch. 976 * </p> 977 * <dt><b>Update</b></dt> 978 * <dd><p>Just as with insert, the update can be done incrementally or as a batch, the 979 * batch mode being the preferred method.</p></dd> 980 * <dt><b>Delete</b></dt> 981 * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, 982 * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw 983 * contacts in a Contact are deleted, the Contact itself is also deleted automatically. 984 * </p> 985 * <p> 986 * The invocation of {@code resolver.delete(...)}, does not physically delete 987 * a raw contacts row. It sets the {@link #DELETED} flag on the raw contact and 988 * removes the raw contact from its aggregate contact. 989 * The sync adapter then deletes the raw contact from the server and 990 * finalizes phone-side deletion by calling {@code resolver.delete(...)} 991 * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> 992 * <p>Some sync adapters are read-only, meaning that they only sync server-side 993 * changes to the phone, but not the reverse. If one of those raw contacts 994 * is marked for deletion, it will remain on the phone. However it will be 995 * effectively invisible, because it will not be part of any aggregate contact. 996 * </dd> 997 * <dt><b>Query</b></dt> 998 * <dd> 999 * <p> 1000 * Finding all raw contacts in a Contact is easy: 1001 * <pre> 1002 * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, 1003 * new String[]{RawContacts._ID}, 1004 * RawContacts.CONTACT_ID + "=?", 1005 * new String[]{String.valueOf(contactId)}, null); 1006 * </pre> 1007 * </p> 1008 * <p> 1009 * There are two ways to find raw contacts within a specific account, 1010 * you can either put the account name and type in the selection or pass them as query 1011 * parameters. The latter approach is preferable, especially when you can reuse the 1012 * URI: 1013 * <pre> 1014 * Uri rawContactUri = RawContacts.URI.buildUpon() 1015 * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) 1016 * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) 1017 * .build(); 1018 * Cursor c1 = getContentResolver().query(rawContactUri, 1019 * RawContacts.STARRED + "<>0", null, null, null); 1020 * ... 1021 * Cursor c2 = getContentResolver().query(rawContactUri, 1022 * RawContacts.DELETED + "<>0", null, null, null); 1023 * </pre> 1024 * </p> 1025 * <p>The best way to read a raw contact along with all the data associated with it is 1026 * by using the {@link Entity} directory. If the raw contact has data rows, 1027 * the Entity cursor will contain a row for each data row. If the raw contact has no 1028 * data rows, the cursor will still contain one row with the raw contact-level information. 1029 * <pre> 1030 * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); 1031 * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); 1032 * Cursor c = getContentResolver().query(entityUri, 1033 * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, 1034 * null, null, null); 1035 * try { 1036 * while (c.moveToNext()) { 1037 * String sourceId = c.getString(0); 1038 * if (!c.isNull(1)) { 1039 * String mimeType = c.getString(2); 1040 * String data = c.getString(3); 1041 * ... 1042 * } 1043 * } 1044 * } finally { 1045 * c.close(); 1046 * } 1047 * </pre> 1048 * </p> 1049 * </dd> 1050 * </dl> 1051 * <h3>Aggregation</h3> 1052 * <p> 1053 * As soon as a raw contact is inserted or whenever its constituent data 1054 * changes, the provider will check if the raw contact matches other 1055 * existing raw contacts and if so will aggregate it with those. From the 1056 * data standpoint, aggregation is reflected in the change of the 1057 * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. 1058 * </p> 1059 * <p> 1060 * See also {@link AggregationExceptions} for a mechanism to control 1061 * aggregation programmatically. 1062 * </p> 1063 * <h2>Columns</h2> 1064 * <table class="jd-sumtable"> 1065 * <tr> 1066 * <th colspan='4'>RawContacts</th> 1067 * </tr> 1068 * <tr> 1069 * <td>long</td> 1070 * <td>{@link #_ID}</td> 1071 * <td>read-only</td> 1072 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words, 1073 * it would be a really bad idea to delete and reinsert a raw contact. A sync adapter should 1074 * always do an update instead.</td> 1075 * </tr> 1076 * <tr> 1077 * <td>long</td> 1078 * <td>{@link #CONTACT_ID}</td> 1079 * <td>read-only</td> 1080 * <td>A reference to the {@link ContactsContract.Contacts#_ID} that this raw contact belongs 1081 * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled 1082 * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> 1083 * </tr> 1084 * <tr> 1085 * <td>int</td> 1086 * <td>{@link #AGGREGATION_MODE}</td> 1087 * <td>read/write</td> 1088 * <td>A mechanism that allows programmatic control of the aggregation process. The allowed 1089 * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} 1090 * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> 1091 * </tr> 1092 * <tr> 1093 * <td>int</td> 1094 * <td>{@link #DELETED}</td> 1095 * <td>read/write</td> 1096 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked 1097 * for deletion. When {@link android.content.ContentResolver#delete} is 1098 * called on a raw contact, it is marked for deletion and removed from its 1099 * aggregate contact. The sync adaptor deletes the raw contact on the server and 1100 * then calls ContactResolver.delete once more, this time passing the 1101 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize 1102 * the data removal.</td> 1103 * </tr> 1104 * <tr> 1105 * <td>int</td> 1106 * <td>{@link #TIMES_CONTACTED}</td> 1107 * <td>read/write</td> 1108 * <td>The number of times the contact has been contacted. To have an effect 1109 * on the corresponding value of the aggregate contact, this field 1110 * should be set at the time the raw contact is inserted. 1111 * See {@link ContactsContract.Contacts#markAsContacted}.</td> 1112 * </tr> 1113 * <tr> 1114 * <td>long</td> 1115 * <td>{@link #LAST_TIME_CONTACTED}</td> 1116 * <td>read/write</td> 1117 * <td>The timestamp of the last time the contact was contacted. To have an effect 1118 * on the corresponding value of the aggregate contact, this field 1119 * should be set at the time the raw contact is inserted. 1120 * See {@link ContactsContract.Contacts#markAsContacted}.</td> 1121 * </tr> 1122 * <tr> 1123 * <td>int</td> 1124 * <td>{@link #STARRED}</td> 1125 * <td>read/write</td> 1126 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. 1127 * Changing this field immediately effects the corresponding aggregate contact: 1128 * if any raw contacts in that aggregate contact are starred, then the contact 1129 * itself is marked as starred.</td> 1130 * </tr> 1131 * <tr> 1132 * <td>String</td> 1133 * <td>{@link #CUSTOM_RINGTONE}</td> 1134 * <td>read/write</td> 1135 * <td>A custom ringtone associated with a raw contact. Typically this is the 1136 * URI returned by an activity launched with the 1137 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. 1138 * To have an effect on the corresponding value of the aggregate contact, this field 1139 * should be set at the time the raw contact is inserted. To set a custom 1140 * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE} 1141 * instead.</td> 1142 * </tr> 1143 * <tr> 1144 * <td>int</td> 1145 * <td>{@link #SEND_TO_VOICEMAIL}</td> 1146 * <td>read/write</td> 1147 * <td>An indicator of whether calls from this raw contact should be forwarded 1148 * directly to voice mail ('1') or not ('0'). To have an effect 1149 * on the corresponding value of the aggregate contact, this field 1150 * should be set at the time the raw contact is inserted.</td> 1151 * </tr> 1152 * <tr> 1153 * <td>String</td> 1154 * <td>{@link #ACCOUNT_NAME}</td> 1155 * <td>read/write-once</td> 1156 * <td>The name of the account instance to which this row belongs, which when paired with 1157 * {@link #ACCOUNT_TYPE} identifies a specific account. It should be set at the time 1158 * the raw contact is inserted and never changed afterwards.</td> 1159 * </tr> 1160 * <tr> 1161 * <td>String</td> 1162 * <td>{@link #ACCOUNT_TYPE}</td> 1163 * <td>read/write-once</td> 1164 * <td>The type of account to which this row belongs, which when paired with 1165 * {@link #ACCOUNT_NAME} identifies a specific account. It should be set at the time 1166 * the raw contact is inserted and never changed afterwards.</td> 1167 * </tr> 1168 * <tr> 1169 * <td>String</td> 1170 * <td>{@link #SOURCE_ID}</td> 1171 * <td>read/write</td> 1172 * <td>String that uniquely identifies this row to its source account. 1173 * Typically it is set at the time the raw contact is inserted and never 1174 * changed afterwards. The one notable exception is a new raw contact: it 1175 * will have an account name and type, but no source id. This should 1176 * indicated to the sync adapter that a new contact needs to be created 1177 * server-side and its ID stored in the corresponding SOURCE_ID field on 1178 * the phone. 1179 * </td> 1180 * </tr> 1181 * <tr> 1182 * <td>int</td> 1183 * <td>{@link #VERSION}</td> 1184 * <td>read-only</td> 1185 * <td>Version number that is updated whenever this row or its related data 1186 * changes. This field can be used for optimistic locking of a raw contact. 1187 * </td> 1188 * </tr> 1189 * <tr> 1190 * <td>int</td> 1191 * <td>{@link #DIRTY}</td> 1192 * <td>read/write</td> 1193 * <td>Flag indicating that {@link #VERSION} has changed, and this row needs 1194 * to be synchronized by its owning account. The value is set to "1" automatically 1195 * whenever the raw contact changes, unless the URI has the 1196 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. 1197 * The sync adapter should always supply this query parameter to prevent 1198 * unnecessary synchronization: user changes some data on the server, 1199 * the sync adapter updates the contact on the phone (without the 1200 * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, 1201 * which triggers a sync to bring the changes to the server. 1202 * </td> 1203 * </tr> 1204 * <tr> 1205 * <td>String</td> 1206 * <td>{@link #SYNC1}</td> 1207 * <td>read/write</td> 1208 * <td>Generic column for use by sync adapters. Content provider 1209 * stores this information on behalf of the sync adapter but does not 1210 * interpret it in any way. 1211 * </td> 1212 * </tr> 1213 * <tr> 1214 * <td>String</td> 1215 * <td>{@link #SYNC2}</td> 1216 * <td>read/write</td> 1217 * <td>Generic column for use by sync adapters. 1218 * </td> 1219 * </tr> 1220 * <tr> 1221 * <td>String</td> 1222 * <td>{@link #SYNC3}</td> 1223 * <td>read/write</td> 1224 * <td>Generic column for use by sync adapters. 1225 * </td> 1226 * </tr> 1227 * <tr> 1228 * <td>String</td> 1229 * <td>{@link #SYNC4}</td> 1230 * <td>read/write</td> 1231 * <td>Generic column for use by sync adapters. 1232 * </td> 1233 * </tr> 1234 * </table> 1235 */ 1236 public static final class RawContacts implements BaseColumns, RawContactsColumns, 1237 ContactOptionsColumns, SyncColumns { 1238 /** 1239 * This utility class cannot be instantiated 1240 */ 1241 private RawContacts() { 1242 } 1243 1244 /** 1245 * The content:// style URI for this table 1246 */ 1247 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); 1248 1249 /** 1250 * The MIME type of {@link #CONTENT_URI} providing a directory of 1251 * people. 1252 */ 1253 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; 1254 1255 /** 1256 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 1257 * person. 1258 */ 1259 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact"; 1260 1261 /** 1262 * Aggregation mode: aggregate asynchronously. 1263 */ 1264 public static final int AGGREGATION_MODE_DEFAULT = 0; 1265 1266 /** 1267 * Aggregation mode: aggregate at the time the raw contact is inserted/updated. 1268 * TODO: deprecate. Aggregation is now synchronous, this value is a no-op 1269 */ 1270 public static final int AGGREGATION_MODE_IMMEDIATE = 1; 1271 1272 /** 1273 * If {@link #AGGREGATION_MODE} is {@link #AGGREGATION_MODE_SUSPENDED}, changes 1274 * to the raw contact do not cause its aggregation to be revisited. Note that changing 1275 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to 1276 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass. Any subsequent 1277 * change to the raw contact's data will. 1278 */ 1279 public static final int AGGREGATION_MODE_SUSPENDED = 2; 1280 1281 /** 1282 * Aggregation mode: never aggregate this raw contact (note that the raw contact will not 1283 * have a corresponding Aggregate and therefore will not be included in Aggregates 1284 * query results.) 1285 */ 1286 public static final int AGGREGATION_MODE_DISABLED = 3; 1287 1288 /** 1289 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} 1290 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} 1291 * entry of the given {@link RawContacts} entry. 1292 */ 1293 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { 1294 // TODO: use a lighter query by joining rawcontacts with contacts in provider 1295 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); 1296 final Cursor cursor = resolver.query(dataUri, new String[] { 1297 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY 1298 }, null, null, null); 1299 1300 Uri lookupUri = null; 1301 try { 1302 if (cursor != null && cursor.moveToFirst()) { 1303 final long contactId = cursor.getLong(0); 1304 final String lookupKey = cursor.getString(1); 1305 return Contacts.getLookupUri(contactId, lookupKey); 1306 } 1307 } finally { 1308 if (cursor != null) cursor.close(); 1309 } 1310 return lookupUri; 1311 } 1312 1313 /** 1314 * A sub-directory of a single raw contact that contains all of their 1315 * {@link ContactsContract.Data} rows. To access this directory 1316 * append {@link Data#CONTENT_DIRECTORY} to the contact URI. 1317 */ 1318 public static final class Data implements BaseColumns, DataColumns { 1319 /** 1320 * no public constructor since this is a utility class 1321 */ 1322 private Data() { 1323 } 1324 1325 /** 1326 * The directory twig for this sub-table 1327 */ 1328 public static final String CONTENT_DIRECTORY = "data"; 1329 } 1330 1331 /** 1332 * <p> 1333 * A sub-directory of a single raw contact that contains all of their 1334 * {@link ContactsContract.Data} rows. To access this directory append 1335 * {@link #CONTENT_DIRECTORY} to the contact URI. See 1336 * {@link RawContactsEntity} for a stand-alone table containing the same 1337 * data. 1338 * </p> 1339 * <p> 1340 * The Entity directory is similar to the {@link RawContacts.Data} 1341 * directory but with two important differences: 1342 * <ul> 1343 * <li>Entity has different ID fields: {@link #_ID} for the raw contact 1344 * and {@link #DATA_ID} for the data rows.</li> 1345 * <li>Entity always contains at least one row, even if there are no 1346 * actual data rows. In this case the {@link #DATA_ID} field will be 1347 * null.</li> 1348 * </ul> 1349 * Using Entity should preferred to using two separate queries: 1350 * RawContacts followed by Data. The reason is that Entity reads all 1351 * data for a raw contact in one transaction, so there is no possibility 1352 * of the data changing between the two queries. 1353 */ 1354 public static final class Entity implements BaseColumns, DataColumns { 1355 /** 1356 * no public constructor since this is a utility class 1357 */ 1358 private Entity() { 1359 } 1360 1361 /** 1362 * The directory twig for this sub-table 1363 */ 1364 public static final String CONTENT_DIRECTORY = "entity"; 1365 1366 /** 1367 * The ID of the data column. The value will be null if this raw contact has no 1368 * data rows. 1369 * <P>Type: INTEGER</P> 1370 */ 1371 public static final String DATA_ID = "data_id"; 1372 } 1373 1374 public static EntityIterator newEntityIterator(Cursor cursor) { 1375 return new EntityIteratorImpl(cursor); 1376 } 1377 1378 private static class EntityIteratorImpl extends CursorEntityIterator { 1379 private static final String[] DATA_KEYS = new String[]{ 1380 Data.DATA1, 1381 Data.DATA2, 1382 Data.DATA3, 1383 Data.DATA4, 1384 Data.DATA5, 1385 Data.DATA6, 1386 Data.DATA7, 1387 Data.DATA8, 1388 Data.DATA9, 1389 Data.DATA10, 1390 Data.DATA11, 1391 Data.DATA12, 1392 Data.DATA13, 1393 Data.DATA14, 1394 Data.DATA15, 1395 Data.SYNC1, 1396 Data.SYNC2, 1397 Data.SYNC3, 1398 Data.SYNC4}; 1399 1400 public EntityIteratorImpl(Cursor cursor) { 1401 super(cursor); 1402 } 1403 1404 public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) 1405 throws RemoteException { 1406 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); 1407 final long rawContactId = cursor.getLong(columnRawContactId); 1408 1409 // we expect the cursor is already at the row we need to read from 1410 ContentValues cv = new ContentValues(); 1411 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); 1412 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); 1413 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); 1414 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); 1415 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); 1416 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); 1417 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); 1418 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); 1419 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); 1420 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); 1421 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); 1422 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); 1423 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); 1424 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, IS_RESTRICTED); 1425 android.content.Entity contact = new android.content.Entity(cv); 1426 1427 // read data rows until the contact id changes 1428 do { 1429 if (rawContactId != cursor.getLong(columnRawContactId)) { 1430 break; 1431 } 1432 // add the data to to the contact 1433 cv = new ContentValues(); 1434 cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); 1435 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 1436 Data.RES_PACKAGE); 1437 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); 1438 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); 1439 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, 1440 Data.IS_SUPER_PRIMARY); 1441 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); 1442 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 1443 CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); 1444 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 1445 Data.DATA_VERSION); 1446 for (String key : DATA_KEYS) { 1447 final int columnIndex = cursor.getColumnIndexOrThrow(key); 1448 if (cursor.isNull(columnIndex)) { 1449 // don't put anything 1450 } else { 1451 try { 1452 cv.put(key, cursor.getString(columnIndex)); 1453 } catch (SQLiteException e) { 1454 cv.put(key, cursor.getBlob(columnIndex)); 1455 } 1456 } 1457 // TODO: go back to this version of the code when bug 1458 // http://b/issue?id=2306370 is fixed. 1459// if (cursor.isNull(columnIndex)) { 1460// // don't put anything 1461// } else if (cursor.isLong(columnIndex)) { 1462// values.put(key, cursor.getLong(columnIndex)); 1463// } else if (cursor.isFloat(columnIndex)) { 1464// values.put(key, cursor.getFloat(columnIndex)); 1465// } else if (cursor.isString(columnIndex)) { 1466// values.put(key, cursor.getString(columnIndex)); 1467// } else if (cursor.isBlob(columnIndex)) { 1468// values.put(key, cursor.getBlob(columnIndex)); 1469// } 1470 } 1471 contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); 1472 } while (cursor.moveToNext()); 1473 1474 return contact; 1475 } 1476 1477 } 1478 } 1479 1480 /** 1481 * Social status update columns. 1482 * 1483 * @see StatusUpdates 1484 * @see ContactsContract.Data 1485 */ 1486 protected interface StatusColumns extends Im.CommonPresenceColumns { 1487 /** 1488 * Contact's latest presence level. 1489 * <P>Type: INTEGER (one of the values below)</P> 1490 */ 1491 public static final String PRESENCE = PRESENCE_STATUS; 1492 1493 /** 1494 * Contact latest status update. 1495 * <p>Type: TEXT</p> 1496 */ 1497 public static final String STATUS = PRESENCE_CUSTOM_STATUS; 1498 1499 /** 1500 * The absolute time in milliseconds when the latest status was inserted/updated. 1501 * <p>Type: NUMBER</p> 1502 */ 1503 public static final String STATUS_TIMESTAMP = "status_ts"; 1504 1505 /** 1506 * The package containing resources for this status: label and icon. 1507 * <p>Type: NUMBER</p> 1508 */ 1509 public static final String STATUS_RES_PACKAGE = "status_res_package"; 1510 1511 /** 1512 * The resource ID of the label describing the source of the status update, e.g. "Google 1513 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. 1514 * <p>Type: NUMBER</p> 1515 */ 1516 public static final String STATUS_LABEL = "status_label"; 1517 1518 /** 1519 * The resource ID of the icon for the source of the status update. 1520 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. 1521 * <p>Type: NUMBER</p> 1522 */ 1523 public static final String STATUS_ICON = "status_icon"; 1524 } 1525 1526 /** 1527 * Columns in the Data table. 1528 * 1529 * @see ContactsContract.Data 1530 */ 1531 protected interface DataColumns { 1532 /** 1533 * The package name to use when creating {@link Resources} objects for 1534 * this data row. This value is only designed for use when building user 1535 * interfaces, and should not be used to infer the owner. 1536 * 1537 * @hide 1538 */ 1539 public static final String RES_PACKAGE = "res_package"; 1540 1541 /** 1542 * The MIME type of the item represented by this row. 1543 */ 1544 public static final String MIMETYPE = "mimetype"; 1545 1546 /** 1547 * A reference to the {@link RawContacts#_ID} 1548 * that this data belongs to. 1549 */ 1550 public static final String RAW_CONTACT_ID = "raw_contact_id"; 1551 1552 /** 1553 * Whether this is the primary entry of its kind for the raw contact it belongs to 1554 * <P>Type: INTEGER (if set, non-0 means true)</P> 1555 */ 1556 public static final String IS_PRIMARY = "is_primary"; 1557 1558 /** 1559 * Whether this is the primary entry of its kind for the aggregate 1560 * contact it belongs to. Any data record that is "super primary" must 1561 * also be "primary". 1562 * <P>Type: INTEGER (if set, non-0 means true)</P> 1563 */ 1564 public static final String IS_SUPER_PRIMARY = "is_super_primary"; 1565 1566 /** 1567 * The version of this data record. This is a read-only value. The data column is 1568 * guaranteed to not change without the version going up. This value is monotonically 1569 * increasing. 1570 * <P>Type: INTEGER</P> 1571 */ 1572 public static final String DATA_VERSION = "data_version"; 1573 1574 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1575 public static final String DATA1 = "data1"; 1576 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1577 public static final String DATA2 = "data2"; 1578 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1579 public static final String DATA3 = "data3"; 1580 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1581 public static final String DATA4 = "data4"; 1582 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1583 public static final String DATA5 = "data5"; 1584 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1585 public static final String DATA6 = "data6"; 1586 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1587 public static final String DATA7 = "data7"; 1588 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1589 public static final String DATA8 = "data8"; 1590 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1591 public static final String DATA9 = "data9"; 1592 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1593 public static final String DATA10 = "data10"; 1594 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1595 public static final String DATA11 = "data11"; 1596 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1597 public static final String DATA12 = "data12"; 1598 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1599 public static final String DATA13 = "data13"; 1600 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1601 public static final String DATA14 = "data14"; 1602 /** Generic data column, the meaning is {@link #MIMETYPE} specific */ 1603 public static final String DATA15 = "data15"; 1604 1605 /** Generic column for use by sync adapters. */ 1606 public static final String SYNC1 = "data_sync1"; 1607 /** Generic column for use by sync adapters. */ 1608 public static final String SYNC2 = "data_sync2"; 1609 /** Generic column for use by sync adapters. */ 1610 public static final String SYNC3 = "data_sync3"; 1611 /** Generic column for use by sync adapters. */ 1612 public static final String SYNC4 = "data_sync4"; 1613 } 1614 1615 /** 1616 * Combines all columns returned by {@link ContactsContract.Data} table queries. 1617 * 1618 * @see ContactsContract.Data 1619 */ 1620 protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, 1621 RawContactsColumns, ContactsColumns, ContactOptionsColumns, ContactStatusColumns { 1622 1623 } 1624 1625 /** 1626 * <p> 1627 * Constants for the data table, which contains data points tied to a raw 1628 * contact. For example, a phone number or email address. 1629 * </p> 1630 * <h3>Data kinds</h3> 1631 * <p> 1632 * Data is a generic table that can hold all kinds of data. Sync adapters 1633 * and applications can introduce their own data kinds. The kind of data 1634 * stored in a particular row is determined by the mime type in the row. 1635 * Fields from {@link #DATA1} through {@link #DATA15} are generic columns 1636 * whose specific use is determined by the kind of data stored in the row. 1637 * For example, if the data kind is 1638 * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then DATA1 stores the 1639 * phone number, but if the data kind is 1640 * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then DATA1 stores the 1641 * email address. 1642 * </p> 1643 * <p> 1644 * ContactsContract defines a small number of common data kinds, e.g. 1645 * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a 1646 * convenience, these classes define data kind specific aliases for DATA1 etc. 1647 * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as 1648 * {@link ContactsContract.Data Data.DATA1}. 1649 * </p> 1650 * <p> 1651 * {@link #DATA1} is an indexed column and should be used for the data element that is 1652 * expected to be most frequently used in query selections. For example, in the 1653 * case of a row representing email addresses {@link #DATA1} should probably 1654 * be used for the email address itself, while {@link #DATA2} etc can be 1655 * used for auxiliary information like type of email address. 1656 * <p> 1657 * <p> 1658 * By convention, {@link #DATA15} is used for storing BLOBs (binary data). 1659 * </p> 1660 * <p> 1661 * Typically you should refrain from introducing new kinds of data for 3rd 1662 * party account types. For example, if you add a data row for 1663 * "favorite song" to a raw contact owned by a Google account, it will not 1664 * get synced to the server, because the Google sync adapter does not know 1665 * how to handle this data kind. Thus new data kinds are typically 1666 * introduced along with new account types, i.e. new sync adapters. 1667 * </p> 1668 * <h3>Batch operations</h3> 1669 * <p> 1670 * Data rows can be inserted/updated/deleted using the traditional 1671 * {@link ContentResolver#insert}, {@link ContentResolver#update} and 1672 * {@link ContentResolver#delete} methods, however the newer mechanism based 1673 * on a batch of {@link ContentProviderOperation} will prove to be a better 1674 * choice in almost all cases. All operations in a batch are executed in a 1675 * single transaction, which ensures that the phone-side and server-side 1676 * state of a raw contact are always consistent. Also, the batch-based 1677 * approach is far more efficient: not only are the database operations 1678 * faster when executed in a single transaction, but also sending a batch of 1679 * commands to the content provider saves a lot of time on context switching 1680 * between your process and the process in which the content provider runs. 1681 * </p> 1682 * <p> 1683 * The flip side of using batched operations is that a large batch may lock 1684 * up the database for a long time preventing other applications from 1685 * accessing data and potentially causing ANRs ("Application Not Responding" 1686 * dialogs.) 1687 * </p> 1688 * <p> 1689 * To avoid such lockups of the database, make sure to insert "yield points" 1690 * in the batch. A yield point indicates to the content provider that before 1691 * executing the next operation it can commit the changes that have already 1692 * been made, yield to other requests, open another transaction and continue 1693 * processing operations. A yield point will not automatically commit the 1694 * transaction, but only if there is another request waiting on the 1695 * database. Normally a sync adapter should insert a yield point at the 1696 * beginning of each raw contact operation sequence in the batch. See 1697 * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. 1698 * </p> 1699 * <h3>Operations</h3> 1700 * <dl> 1701 * <dt><b>Insert</b></dt> 1702 * <dd> 1703 * <p> 1704 * An individual data row can be inserted using the traditional 1705 * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows 1706 * should always be inserted as a batch. 1707 * </p> 1708 * <p> 1709 * An example of a traditional insert: 1710 * <pre> 1711 * ContentValues values = new ContentValues(); 1712 * values.put(Data.RAW_CONTACT_ID, rawContactId); 1713 * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); 1714 * values.put(Phone.NUMBER, "1-800-GOOG-411"); 1715 * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); 1716 * values.put(Phone.LABEL, "free directory assistance"); 1717 * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); 1718 * </pre> 1719 * <p> 1720 * The same done using ContentProviderOperations: 1721 * <pre> 1722 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 1723 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 1724 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 1725 * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) 1726 * .withValue(Phone.NUMBER, "1-800-GOOG-411") 1727 * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) 1728 * .withValue(Phone.LABEL, "free directory assistance") 1729 * .build()); 1730 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 1731 * </pre> 1732 * </p> 1733 * <dt><b>Update</b></dt> 1734 * <dd> 1735 * <p> 1736 * Just as with insert, update can be done incrementally or as a batch, 1737 * the batch mode being the preferred method: 1738 * <pre> 1739 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 1740 * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) 1741 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) 1742 * .withValue(Email.DATA, "somebody@android.com") 1743 * .build()); 1744 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 1745 * </pre> 1746 * </p> 1747 * </dd> 1748 * <dt><b>Delete</b></dt> 1749 * <dd> 1750 * <p> 1751 * Just as with insert and update, deletion can be done either using the 1752 * {@link ContentResolver#delete} method or using a ContentProviderOperation: 1753 * <pre> 1754 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 1755 * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) 1756 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) 1757 * .build()); 1758 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 1759 * </pre> 1760 * </p> 1761 * </dd> 1762 * <dt><b>Query</b></dt> 1763 * <dd> 1764 * <p> 1765 * <dl> 1766 * <dt>Finding all Data of a given type for a given contact</dt> 1767 * <dd> 1768 * <pre> 1769 * Cursor c = getContentResolver().query(Data.CONTENT_URI, 1770 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, 1771 * Data.CONTACT_ID + "=?" + " AND " 1772 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", 1773 * new String[] {String.valueOf(contactId)}, null); 1774 * </pre> 1775 * </p> 1776 * <p> 1777 * </dd> 1778 * <dt>Finding all Data of a given type for a given raw contact</dt> 1779 * <dd> 1780 * <pre> 1781 * Cursor c = getContentResolver().query(Data.CONTENT_URI, 1782 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, 1783 * Data.RAW_CONTACT_ID + "=?" + " AND " 1784 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", 1785 * new String[] {String.valueOf(rawContactId)}, null); 1786 * </pre> 1787 * </dd> 1788 * <dt>Finding all Data for a given raw contact</dt> 1789 * <dd> 1790 * Most sync adapters will want to read all data rows for a raw contact 1791 * along with the raw contact itself. For that you should use the 1792 * {@link RawContactsEntity}. See also {@link RawContacts}. 1793 * </dd> 1794 * </dl> 1795 * </p> 1796 * </dd> 1797 * </dl> 1798 * <h2>Columns</h2> 1799 * <table class="jd-sumtable"> 1800 * <tr> 1801 * <th colspan='4'>Data</th> 1802 * </tr> 1803 * <tr> 1804 * <td style="width: 7em;">long</td> 1805 * <td style="width: 20em;">{@link #_ID}</td> 1806 * <td style="width: 5em;">read-only</td> 1807 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words, 1808 * it would be a bad idea to delete and reinsert a data rows. A sync adapter should 1809 * always do an update instead.</td> 1810 * </tr> 1811 * <tr> 1812 * <td>String</td> 1813 * <td>{@link #MIMETYPE}</td> 1814 * <td>read/write-once</td> 1815 * <td> 1816 * <p>The MIME type of the item represented by this row. Examples of common 1817 * MIME types are: 1818 * <ul> 1819 * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> 1820 * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> 1821 * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> 1822 * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> 1823 * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> 1824 * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> 1825 * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> 1826 * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> 1827 * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> 1828 * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> 1829 * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> 1830 * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> 1831 * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> 1832 * </ul> 1833 * </p> 1834 * </td> 1835 * </tr> 1836 * <tr> 1837 * <td>long</td> 1838 * <td>{@link #RAW_CONTACT_ID}</td> 1839 * <td>read/write-once</td> 1840 * <td>A reference to the {@link RawContacts#_ID} that this data belongs to.</td> 1841 * </tr> 1842 * <tr> 1843 * <td>long</td> 1844 * <td>{@link #CONTACT_ID}</td> 1845 * <td>read-only</td> 1846 * <td>A reference to the {@link ContactsContract.Contacts#_ID} that this data row belongs 1847 * to. It is obtained through a join with RawContacts.</td> 1848 * </tr> 1849 * <tr> 1850 * <td>int</td> 1851 * <td>{@link #IS_PRIMARY}</td> 1852 * <td>read/write</td> 1853 * <td>Whether this is the primary entry of its kind for the raw contact it belongs to. 1854 * "1" if true, "0" if false.</td> 1855 * </tr> 1856 * <tr> 1857 * <td>int</td> 1858 * <td>{@link #IS_SUPER_PRIMARY}</td> 1859 * <td>read/write</td> 1860 * <td>Whether this is the primary entry of its kind for the aggregate 1861 * contact it belongs to. Any data record that is "super primary" must 1862 * also be "primary".</td> 1863 * </tr> 1864 * <tr> 1865 * <td>int</td> 1866 * <td>{@link #DATA_VERSION}</td> 1867 * <td>read-only</td> 1868 * <td>The version of this data record. Whenever the data row changes 1869 * the version goes up. This value is monotonically increasing.</td> 1870 * </tr> 1871 * <tr> 1872 * <td>Any type</td> 1873 * <td> 1874 * {@link #DATA1}<br> 1875 * {@link #DATA2}<br> 1876 * {@link #DATA3}<br> 1877 * {@link #DATA4}<br> 1878 * {@link #DATA5}<br> 1879 * {@link #DATA6}<br> 1880 * {@link #DATA7}<br> 1881 * {@link #DATA8}<br> 1882 * {@link #DATA9}<br> 1883 * {@link #DATA10}<br> 1884 * {@link #DATA11}<br> 1885 * {@link #DATA12}<br> 1886 * {@link #DATA13}<br> 1887 * {@link #DATA14}<br> 1888 * {@link #DATA15} 1889 * </td> 1890 * <td>read/write</td> 1891 * <td>Generic data columns, the meaning is {@link #MIMETYPE} specific.</td> 1892 * </tr> 1893 * <tr> 1894 * <td>Any type</td> 1895 * <td> 1896 * {@link #SYNC1}<br> 1897 * {@link #SYNC2}<br> 1898 * {@link #SYNC3}<br> 1899 * {@link #SYNC4} 1900 * </td> 1901 * <td>read/write</td> 1902 * <td>Generic columns for use by sync adapters. For example, a Photo row 1903 * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) 1904 * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> 1905 * </tr> 1906 * </table> 1907 * 1908 * <table class="jd-sumtable"> 1909 * <tr> 1910 * <th colspan='4'>Join with {@link StatusUpdates}</th> 1911 * </tr> 1912 * <tr> 1913 * <td style="width: 7em;">int</td> 1914 * <td style="width: 20em;">{@link #PRESENCE}</td> 1915 * <td style="width: 5em;">read-only</td> 1916 * <td>IM presence status linked to this data row. Compare with 1917 * {@link #CONTACT_PRESENCE}, which contains the contact's presence across 1918 * all IM rows. See {@link StatusUpdates} for individual status definitions. 1919 * The provider may choose not to store this value 1920 * in persistent storage. The expectation is that presence status will be 1921 * updated on a regular basic. 1922 * </td> 1923 * </tr> 1924 * <tr> 1925 * <td>String</td> 1926 * <td>{@link #STATUS}</td> 1927 * <td>read-only</td> 1928 * <td>Latest status update linked with this data row.</td> 1929 * </tr> 1930 * <tr> 1931 * <td>long</td> 1932 * <td>{@link #STATUS_TIMESTAMP}</td> 1933 * <td>read-only</td> 1934 * <td>The absolute time in milliseconds when the latest status was 1935 * inserted/updated for this data row.</td> 1936 * </tr> 1937 * <tr> 1938 * <td>String</td> 1939 * <td>{@link #STATUS_RES_PACKAGE}</td> 1940 * <td>read-only</td> 1941 * <td>The package containing resources for this status: label and icon.</td> 1942 * </tr> 1943 * <tr> 1944 * <td>long</td> 1945 * <td>{@link #STATUS_LABEL}</td> 1946 * <td>read-only</td> 1947 * <td>The resource ID of the label describing the source of status update linked 1948 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 1949 * </tr> 1950 * <tr> 1951 * <td>long</td> 1952 * <td>{@link #STATUS_ICON}</td> 1953 * <td>read-only</td> 1954 * <td>The resource ID of the icon for the source of the status update linked 1955 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 1956 * </tr> 1957 * </table> 1958 * 1959 * <p> 1960 * Columns from the associated raw contact are also available through an 1961 * implicit join. 1962 * </p> 1963 * 1964 * <table class="jd-sumtable"> 1965 * <tr> 1966 * <th colspan='4'>Join with {@link RawContacts}</th> 1967 * </tr> 1968 * <tr> 1969 * <td style="width: 7em;">int</td> 1970 * <td style="width: 20em;">{@link #AGGREGATION_MODE}</td> 1971 * <td style="width: 5em;">read-only</td> 1972 * <td>See {@link RawContacts}.</td> 1973 * </tr> 1974 * <tr> 1975 * <td>int</td> 1976 * <td>{@link #DELETED}</td> 1977 * <td>read-only</td> 1978 * <td>See {@link RawContacts}.</td> 1979 * </tr> 1980 * </table> 1981 * 1982 * <p> 1983 * Columns from the associated aggregated contact are also available through an 1984 * implicit join. 1985 * </p> 1986 * 1987 * <table class="jd-sumtable"> 1988 * <tr> 1989 * <th colspan='4'>Join with {@link Contacts}</th> 1990 * </tr> 1991 * <tr> 1992 * <td style="width: 7em;">String</td> 1993 * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> 1994 * <td style="width: 5em;">read-only</td> 1995 * <td>See {@link ContactsContract.Contacts}</td> 1996 * </tr> 1997 * <tr> 1998 * <td>String</td> 1999 * <td>{@link #DISPLAY_NAME}</td> 2000 * <td>read-only</td> 2001 * <td>See {@link ContactsContract.Contacts}</td> 2002 * </tr> 2003 * <tr> 2004 * <td>long</td> 2005 * <td>{@link #PHOTO_ID}</td> 2006 * <td>read-only</td> 2007 * <td>See {@link ContactsContract.Contacts}.</td> 2008 * </tr> 2009 * <tr> 2010 * <td>int</td> 2011 * <td>{@link #IN_VISIBLE_GROUP}</td> 2012 * <td>read-only</td> 2013 * <td>See {@link ContactsContract.Contacts}.</td> 2014 * </tr> 2015 * <tr> 2016 * <td>int</td> 2017 * <td>{@link #HAS_PHONE_NUMBER}</td> 2018 * <td>read-only</td> 2019 * <td>See {@link ContactsContract.Contacts}.</td> 2020 * </tr> 2021 * <tr> 2022 * <td>int</td> 2023 * <td>{@link #TIMES_CONTACTED}</td> 2024 * <td>read-only</td> 2025 * <td>See {@link ContactsContract.Contacts}.</td> 2026 * </tr> 2027 * <tr> 2028 * <td>long</td> 2029 * <td>{@link #LAST_TIME_CONTACTED}</td> 2030 * <td>read-only</td> 2031 * <td>See {@link ContactsContract.Contacts}.</td> 2032 * </tr> 2033 * <tr> 2034 * <td>int</td> 2035 * <td>{@link #STARRED}</td> 2036 * <td>read-only</td> 2037 * <td>See {@link ContactsContract.Contacts}.</td> 2038 * </tr> 2039 * <tr> 2040 * <td>String</td> 2041 * <td>{@link #CUSTOM_RINGTONE}</td> 2042 * <td>read-only</td> 2043 * <td>See {@link ContactsContract.Contacts}.</td> 2044 * </tr> 2045 * <tr> 2046 * <td>int</td> 2047 * <td>{@link #SEND_TO_VOICEMAIL}</td> 2048 * <td>read-only</td> 2049 * <td>See {@link ContactsContract.Contacts}.</td> 2050 * </tr> 2051 * <tr> 2052 * <td>int</td> 2053 * <td>{@link #CONTACT_PRESENCE}</td> 2054 * <td>read-only</td> 2055 * <td>See {@link ContactsContract.Contacts}.</td> 2056 * </tr> 2057 * <tr> 2058 * <td>String</td> 2059 * <td>{@link #CONTACT_STATUS}</td> 2060 * <td>read-only</td> 2061 * <td>See {@link ContactsContract.Contacts}.</td> 2062 * </tr> 2063 * <tr> 2064 * <td>long</td> 2065 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> 2066 * <td>read-only</td> 2067 * <td>See {@link ContactsContract.Contacts}.</td> 2068 * </tr> 2069 * <tr> 2070 * <td>String</td> 2071 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> 2072 * <td>read-only</td> 2073 * <td>See {@link ContactsContract.Contacts}.</td> 2074 * </tr> 2075 * <tr> 2076 * <td>long</td> 2077 * <td>{@link #CONTACT_STATUS_LABEL}</td> 2078 * <td>read-only</td> 2079 * <td>See {@link ContactsContract.Contacts}.</td> 2080 * </tr> 2081 * <tr> 2082 * <td>long</td> 2083 * <td>{@link #CONTACT_STATUS_ICON}</td> 2084 * <td>read-only</td> 2085 * <td>See {@link ContactsContract.Contacts}.</td> 2086 * </tr> 2087 * </table> 2088 */ 2089 public final static class Data implements DataColumnsWithJoins { 2090 /** 2091 * This utility class cannot be instantiated 2092 */ 2093 private Data() {} 2094 2095 /** 2096 * The content:// style URI for this table 2097 */ 2098 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); 2099 2100 /** 2101 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 2102 */ 2103 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; 2104 2105 /** 2106 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward 2107 * Data.CONTENT_URI contains only exportable data. 2108 * 2109 * This flag is useful (currently) only for vCard exporter in Contacts app, which 2110 * needs to exclude "un-exportable" data from available data to export, while 2111 * Contacts app itself has priviledge to access all data including "un-exportable" 2112 * ones and providers return all of them regardless of the callers' intention. 2113 * <P>Type: INTEGER</p> 2114 * 2115 * @hide Maybe available only in Eclair and not really ready for public use. 2116 * TODO: remove, or implement this feature completely. As of now (Eclair), 2117 * we only use this flag in queryEntities(), not query(). 2118 */ 2119 public static final String FOR_EXPORT_ONLY = "for_export_only"; 2120 2121 /** 2122 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} 2123 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} 2124 * entry of the given {@link ContactsContract.Data} entry. 2125 */ 2126 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { 2127 final Cursor cursor = resolver.query(dataUri, new String[] { 2128 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY 2129 }, null, null, null); 2130 2131 Uri lookupUri = null; 2132 try { 2133 if (cursor != null && cursor.moveToFirst()) { 2134 final long contactId = cursor.getLong(0); 2135 final String lookupKey = cursor.getString(1); 2136 return Contacts.getLookupUri(contactId, lookupKey); 2137 } 2138 } finally { 2139 if (cursor != null) cursor.close(); 2140 } 2141 return lookupUri; 2142 } 2143 } 2144 2145 /** 2146 * <p> 2147 * Constants for the raw contacts entities table, which can be though of as 2148 * an outer join of the raw_contacts table with the data table. It is a strictly 2149 * read-only table. 2150 * </p> 2151 * <p> 2152 * If a raw contact has data rows, the RawContactsEntity cursor will contain 2153 * a one row for each data row. If the raw contact has no data rows, the 2154 * cursor will still contain one row with the raw contact-level information 2155 * and nulls for data columns. 2156 * 2157 * <pre> 2158 * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); 2159 * Cursor c = getContentResolver().query(entityUri, 2160 * new String[]{ 2161 * RawContactsEntity.SOURCE_ID, 2162 * RawContactsEntity.DATA_ID, 2163 * RawContactsEntity.MIMETYPE, 2164 * RawContactsEntity.DATA1 2165 * }, null, null, null); 2166 * try { 2167 * while (c.moveToNext()) { 2168 * String sourceId = c.getString(0); 2169 * if (!c.isNull(1)) { 2170 * String mimeType = c.getString(2); 2171 * String data = c.getString(3); 2172 * ... 2173 * } 2174 * } 2175 * } finally { 2176 * c.close(); 2177 * } 2178 * </pre> 2179 * 2180 * <h3>Columns</h3> 2181 * RawContactsEntity has a combination of RawContact and Data columns. 2182 * 2183 * <table class="jd-sumtable"> 2184 * <tr> 2185 * <th colspan='4'>RawContacts</th> 2186 * </tr> 2187 * <tr> 2188 * <td style="width: 7em;">long</td> 2189 * <td style="width: 20em;">{@link #_ID}</td> 2190 * <td style="width: 5em;">read-only</td> 2191 * <td>Raw contact row ID. See {@link RawContacts}.</td> 2192 * </tr> 2193 * <tr> 2194 * <td>long</td> 2195 * <td>{@link #CONTACT_ID}</td> 2196 * <td>read-only</td> 2197 * <td>See {@link RawContacts}.</td> 2198 * </tr> 2199 * <tr> 2200 * <td>int</td> 2201 * <td>{@link #AGGREGATION_MODE}</td> 2202 * <td>read-only</td> 2203 * <td>See {@link RawContacts}.</td> 2204 * </tr> 2205 * <tr> 2206 * <td>int</td> 2207 * <td>{@link #DELETED}</td> 2208 * <td>read-only</td> 2209 * <td>See {@link RawContacts}.</td> 2210 * </tr> 2211 * </table> 2212 * 2213 * <table class="jd-sumtable"> 2214 * <tr> 2215 * <th colspan='4'>Data</th> 2216 * </tr> 2217 * <tr> 2218 * <td style="width: 7em;">long</td> 2219 * <td style="width: 20em;">{@link #DATA_ID}</td> 2220 * <td style="width: 5em;">read-only</td> 2221 * <td>Data row ID. It will be null if the raw contact has no data rows.</td> 2222 * </tr> 2223 * <tr> 2224 * <td>String</td> 2225 * <td>{@link #MIMETYPE}</td> 2226 * <td>read-only</td> 2227 * <td>See {@link ContactsContract.Data}.</td> 2228 * </tr> 2229 * <tr> 2230 * <td>int</td> 2231 * <td>{@link #IS_PRIMARY}</td> 2232 * <td>read-only</td> 2233 * <td>See {@link ContactsContract.Data}.</td> 2234 * </tr> 2235 * <tr> 2236 * <td>int</td> 2237 * <td>{@link #IS_SUPER_PRIMARY}</td> 2238 * <td>read-only</td> 2239 * <td>See {@link ContactsContract.Data}.</td> 2240 * </tr> 2241 * <tr> 2242 * <td>int</td> 2243 * <td>{@link #DATA_VERSION}</td> 2244 * <td>read-only</td> 2245 * <td>See {@link ContactsContract.Data}.</td> 2246 * </tr> 2247 * <tr> 2248 * <td>Any type</td> 2249 * <td> 2250 * {@link #DATA1}<br> 2251 * {@link #DATA2}<br> 2252 * {@link #DATA3}<br> 2253 * {@link #DATA4}<br> 2254 * {@link #DATA5}<br> 2255 * {@link #DATA6}<br> 2256 * {@link #DATA7}<br> 2257 * {@link #DATA8}<br> 2258 * {@link #DATA9}<br> 2259 * {@link #DATA10}<br> 2260 * {@link #DATA11}<br> 2261 * {@link #DATA12}<br> 2262 * {@link #DATA13}<br> 2263 * {@link #DATA14}<br> 2264 * {@link #DATA15} 2265 * </td> 2266 * <td>read-only</td> 2267 * <td>See {@link ContactsContract.Data}.</td> 2268 * </tr> 2269 * <tr> 2270 * <td>Any type</td> 2271 * <td> 2272 * {@link #SYNC1}<br> 2273 * {@link #SYNC2}<br> 2274 * {@link #SYNC3}<br> 2275 * {@link #SYNC4} 2276 * </td> 2277 * <td>read-only</td> 2278 * <td>See {@link ContactsContract.Data}.</td> 2279 * </tr> 2280 * </table> 2281 */ 2282 public final static class RawContactsEntity 2283 implements BaseColumns, DataColumns, RawContactsColumns { 2284 /** 2285 * This utility class cannot be instantiated 2286 */ 2287 private RawContactsEntity() {} 2288 2289 /** 2290 * The content:// style URI for this table 2291 */ 2292 public static final Uri CONTENT_URI = 2293 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); 2294 2295 /** 2296 * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. 2297 */ 2298 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; 2299 2300 /** 2301 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward 2302 * Data.CONTENT_URI contains only exportable data. 2303 * 2304 * This flag is useful (currently) only for vCard exporter in Contacts app, which 2305 * needs to exclude "un-exportable" data from available data to export, while 2306 * Contacts app itself has priviledge to access all data including "un-expotable" 2307 * ones and providers return all of them regardless of the callers' intention. 2308 * <P>Type: INTEGER</p> 2309 * 2310 * @hide Maybe available only in Eclair and not really ready for public use. 2311 * TODO: remove, or implement this feature completely. As of now (Eclair), 2312 * we only use this flag in queryEntities(), not query(). 2313 */ 2314 public static final String FOR_EXPORT_ONLY = "for_export_only"; 2315 2316 /** 2317 * The ID of the data column. The value will be null if this raw contact has no data rows. 2318 * <P>Type: INTEGER</P> 2319 */ 2320 public static final String DATA_ID = "data_id"; 2321 } 2322 2323 /** 2324 * @see PhoneLookup 2325 */ 2326 protected interface PhoneLookupColumns { 2327 /** 2328 * The phone number as the user entered it. 2329 * <P>Type: TEXT</P> 2330 */ 2331 public static final String NUMBER = "number"; 2332 2333 /** 2334 * The type of phone number, for example Home or Work. 2335 * <P>Type: INTEGER</P> 2336 */ 2337 public static final String TYPE = "type"; 2338 2339 /** 2340 * The user defined label for the phone number. 2341 * <P>Type: TEXT</P> 2342 */ 2343 public static final String LABEL = "label"; 2344 } 2345 2346 /** 2347 * A table that represents the result of looking up a phone number, for 2348 * example for caller ID. To perform a lookup you must append the number you 2349 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly 2350 * optimized. 2351 * <pre> 2352 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); 2353 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... 2354 * </pre> 2355 * 2356 * <h3>Columns</h3> 2357 * 2358 * <table class="jd-sumtable"> 2359 * <tr> 2360 * <th colspan='4'>PhoneLookup</th> 2361 * </tr> 2362 * <tr> 2363 * <td>long</td> 2364 * <td>{@link #_ID}</td> 2365 * <td>read-only</td> 2366 * <td>Data row ID.</td> 2367 * </tr> 2368 * <tr> 2369 * <td>String</td> 2370 * <td>{@link #NUMBER}</td> 2371 * <td>read-only</td> 2372 * <td>Phone number.</td> 2373 * </tr> 2374 * <tr> 2375 * <td>String</td> 2376 * <td>{@link #TYPE}</td> 2377 * <td>read-only</td> 2378 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> 2379 * </tr> 2380 * <tr> 2381 * <td>String</td> 2382 * <td>{@link #LABEL}</td> 2383 * <td>read-only</td> 2384 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> 2385 * </tr> 2386 * </table> 2387 * <p> 2388 * Columns from the Contacts table are also available through a join. 2389 * </p> 2390 * <table class="jd-sumtable"> 2391 * <tr> 2392 * <th colspan='4'>Join with {@link Contacts}</th> 2393 * </tr> 2394 * <tr> 2395 * <td>String</td> 2396 * <td>{@link #LOOKUP_KEY}</td> 2397 * <td>read-only</td> 2398 * <td>See {@link ContactsContract.Contacts}</td> 2399 * </tr> 2400 * <tr> 2401 * <td>String</td> 2402 * <td>{@link #DISPLAY_NAME}</td> 2403 * <td>read-only</td> 2404 * <td>See {@link ContactsContract.Contacts}</td> 2405 * </tr> 2406 * <tr> 2407 * <td>long</td> 2408 * <td>{@link #PHOTO_ID}</td> 2409 * <td>read-only</td> 2410 * <td>See {@link ContactsContract.Contacts}.</td> 2411 * </tr> 2412 * <tr> 2413 * <td>int</td> 2414 * <td>{@link #IN_VISIBLE_GROUP}</td> 2415 * <td>read-only</td> 2416 * <td>See {@link ContactsContract.Contacts}.</td> 2417 * </tr> 2418 * <tr> 2419 * <td>int</td> 2420 * <td>{@link #HAS_PHONE_NUMBER}</td> 2421 * <td>read-only</td> 2422 * <td>See {@link ContactsContract.Contacts}.</td> 2423 * </tr> 2424 * <tr> 2425 * <td>int</td> 2426 * <td>{@link #TIMES_CONTACTED}</td> 2427 * <td>read-only</td> 2428 * <td>See {@link ContactsContract.Contacts}.</td> 2429 * </tr> 2430 * <tr> 2431 * <td>long</td> 2432 * <td>{@link #LAST_TIME_CONTACTED}</td> 2433 * <td>read-only</td> 2434 * <td>See {@link ContactsContract.Contacts}.</td> 2435 * </tr> 2436 * <tr> 2437 * <td>int</td> 2438 * <td>{@link #STARRED}</td> 2439 * <td>read-only</td> 2440 * <td>See {@link ContactsContract.Contacts}.</td> 2441 * </tr> 2442 * <tr> 2443 * <td>String</td> 2444 * <td>{@link #CUSTOM_RINGTONE}</td> 2445 * <td>read-only</td> 2446 * <td>See {@link ContactsContract.Contacts}.</td> 2447 * </tr> 2448 * <tr> 2449 * <td>int</td> 2450 * <td>{@link #SEND_TO_VOICEMAIL}</td> 2451 * <td>read-only</td> 2452 * <td>See {@link ContactsContract.Contacts}.</td> 2453 * </tr> 2454 * </table> 2455 */ 2456 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, 2457 ContactsColumns, ContactOptionsColumns { 2458 /** 2459 * This utility class cannot be instantiated 2460 */ 2461 private PhoneLookup() {} 2462 2463 /** 2464 * The content:// style URI for this table. Append the phone number you want to lookup 2465 * to this URI and query it to perform a lookup. For example: 2466 * <pre> 2467 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, Uri.encode(phoneNumber)); 2468 * </pre> 2469 */ 2470 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, 2471 "phone_lookup"); 2472 } 2473 2474 /** 2475 * Additional data mixed in with {@link StatusColumns} to link 2476 * back to specific {@link ContactsContract.Data#_ID} entries. 2477 * 2478 * @see StatusUpdates 2479 */ 2480 protected interface PresenceColumns { 2481 2482 /** 2483 * Reference to the {@link Data#_ID} entry that owns this presence. 2484 * <P>Type: INTEGER</P> 2485 */ 2486 public static final String DATA_ID = "presence_data_id"; 2487 2488 /** 2489 * See {@link CommonDataKinds.Im} for a list of defined protocol constants. 2490 * <p>Type: NUMBER</p> 2491 */ 2492 public static final String PROTOCOL = "protocol"; 2493 2494 /** 2495 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 2496 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 2497 * omitted if {@link #PROTOCOL} value is not 2498 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. 2499 * 2500 * <p>Type: NUMBER</p> 2501 */ 2502 public static final String CUSTOM_PROTOCOL = "custom_protocol"; 2503 2504 /** 2505 * The IM handle the presence item is for. The handle is scoped to 2506 * {@link #PROTOCOL}. 2507 * <P>Type: TEXT</P> 2508 */ 2509 public static final String IM_HANDLE = "im_handle"; 2510 2511 /** 2512 * The IM account for the local user that the presence data came from. 2513 * <P>Type: TEXT</P> 2514 */ 2515 public static final String IM_ACCOUNT = "im_account"; 2516 } 2517 2518 /** 2519 * <p> 2520 * A status update is linked to a {@link ContactsContract.Data} row and captures 2521 * the user's latest status update via the corresponding source, e.g. 2522 * "Having lunch" via "Google Talk". 2523 * </p> 2524 * <p> 2525 * There are two ways a status update can be inserted: by explicitly linking 2526 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row 2527 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 2528 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use 2529 * either. 2530 * </p> 2531 * <p> 2532 * You cannot use {@link ContentResolver#update} to change a status, but 2533 * {@link ContentResolver#insert} will replace the latests status if it already 2534 * exists. 2535 * </p> 2536 * <p> 2537 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses 2538 * for multiple contacts at once. 2539 * </p> 2540 * 2541 * <h3>Columns</h3> 2542 * <table class="jd-sumtable"> 2543 * <tr> 2544 * <th colspan='4'>StatusUpdates</th> 2545 * </tr> 2546 * <tr> 2547 * <td>long</td> 2548 * <td>{@link #DATA_ID}</td> 2549 * <td>read/write</td> 2550 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this 2551 * field is <i>not</i> specified, the provider will attempt to find a data row 2552 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and 2553 * {@link #IM_HANDLE} columns. 2554 * </td> 2555 * </tr> 2556 * <tr> 2557 * <td>long</td> 2558 * <td>{@link #PROTOCOL}</td> 2559 * <td>read/write</td> 2560 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> 2561 * </tr> 2562 * <tr> 2563 * <td>String</td> 2564 * <td>{@link #CUSTOM_PROTOCOL}</td> 2565 * <td>read/write</td> 2566 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value 2567 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or 2568 * omitted if {@link #PROTOCOL} value is not 2569 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> 2570 * </tr> 2571 * <tr> 2572 * <td>String</td> 2573 * <td>{@link #IM_HANDLE}</td> 2574 * <td>read/write</td> 2575 * <td> The IM handle the presence item is for. The handle is scoped to 2576 * {@link #PROTOCOL}.</td> 2577 * </tr> 2578 * <tr> 2579 * <td>String</td> 2580 * <td>{@link #IM_ACCOUNT}</td> 2581 * <td>read/write</td> 2582 * <td>The IM account for the local user that the presence data came from.</td> 2583 * </tr> 2584 * <tr> 2585 * <td>int</td> 2586 * <td>{@link #PRESENCE}</td> 2587 * <td>read/write</td> 2588 * <td>Contact IM presence status. The allowed values are: 2589 * <p> 2590 * <ul> 2591 * <li>{@link #OFFLINE}</li> 2592 * <li>{@link #INVISIBLE}</li> 2593 * <li>{@link #AWAY}</li> 2594 * <li>{@link #IDLE}</li> 2595 * <li>{@link #DO_NOT_DISTURB}</li> 2596 * <li>{@link #AVAILABLE}</li> 2597 * </ul> 2598 * </p> 2599 * <p> 2600 * Since presence status is inherently volatile, the content provider 2601 * may choose not to store this field in long-term storage. 2602 * </p> 2603 * </td> 2604 * </tr> 2605 * <tr> 2606 * <td>String</td> 2607 * <td>{@link #STATUS}</td> 2608 * <td>read/write</td> 2609 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> 2610 * </tr> 2611 * <tr> 2612 * <td>long</td> 2613 * <td>{@link #STATUS_TIMESTAMP}</td> 2614 * <td>read/write</td> 2615 * <td>The absolute time in milliseconds when the status was 2616 * entered by the user. If this value is not provided, the provider will follow 2617 * this logic: if there was no prior status update, the value will be left as null. 2618 * If there was a prior status update, the provider will default this field 2619 * to the current time.</td> 2620 * </tr> 2621 * <tr> 2622 * <td>String</td> 2623 * <td>{@link #STATUS_RES_PACKAGE}</td> 2624 * <td>read/write</td> 2625 * <td> The package containing resources for this status: label and icon.</td> 2626 * </tr> 2627 * <tr> 2628 * <td>long</td> 2629 * <td>{@link #STATUS_LABEL}</td> 2630 * <td>read/write</td> 2631 * <td>The resource ID of the label describing the source of contact status, 2632 * e.g. "Google Talk". This resource is scoped by the 2633 * {@link #STATUS_RES_PACKAGE}.</td> 2634 * </tr> 2635 * <tr> 2636 * <td>long</td> 2637 * <td>{@link #STATUS_ICON}</td> 2638 * <td>read/write</td> 2639 * <td>The resource ID of the icon for the source of contact status. This 2640 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> 2641 * </tr> 2642 * </table> 2643 */ 2644 public static class StatusUpdates implements StatusColumns, PresenceColumns { 2645 2646 /** 2647 * This utility class cannot be instantiated 2648 */ 2649 private StatusUpdates() {} 2650 2651 /** 2652 * The content:// style URI for this table 2653 */ 2654 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); 2655 2656 /** 2657 * Gets the resource ID for the proper presence icon. 2658 * 2659 * @param status the status to get the icon for 2660 * @return the resource ID for the proper presence icon 2661 */ 2662 public static final int getPresenceIconResourceId(int status) { 2663 switch (status) { 2664 case AVAILABLE: 2665 return android.R.drawable.presence_online; 2666 case IDLE: 2667 case AWAY: 2668 return android.R.drawable.presence_away; 2669 case DO_NOT_DISTURB: 2670 return android.R.drawable.presence_busy; 2671 case INVISIBLE: 2672 return android.R.drawable.presence_invisible; 2673 case OFFLINE: 2674 default: 2675 return android.R.drawable.presence_offline; 2676 } 2677 } 2678 2679 /** 2680 * Returns the precedence of the status code the higher number being the higher precedence. 2681 * 2682 * @param status The status code. 2683 * @return An integer representing the precedence, 0 being the lowest. 2684 */ 2685 public static final int getPresencePrecedence(int status) { 2686 // Keep this function here incase we want to enforce a different precedence than the 2687 // natural order of the status constants. 2688 return status; 2689 } 2690 2691 /** 2692 * The MIME type of {@link #CONTENT_URI} providing a directory of 2693 * status update details. 2694 */ 2695 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; 2696 2697 /** 2698 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single 2699 * status update detail. 2700 */ 2701 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; 2702 } 2703 2704 /** 2705 * @deprecated This old name was never meant to be made public. Do not use. 2706 */ 2707 @Deprecated 2708 public static final class Presence extends StatusUpdates { 2709 2710 } 2711 2712 /** 2713 * Container for definitions of common data types stored in the {@link ContactsContract.Data} 2714 * table. 2715 */ 2716 public static final class CommonDataKinds { 2717 /** 2718 * This utility class cannot be instantiated 2719 */ 2720 private CommonDataKinds() {} 2721 2722 /** 2723 * The {@link Data#RES_PACKAGE} value for common data that should be 2724 * shown using a default style. 2725 * 2726 * @hide RES_PACKAGE is hidden 2727 */ 2728 public static final String PACKAGE_COMMON = "common"; 2729 2730 /** 2731 * The base types that all "Typed" data kinds support. 2732 */ 2733 public interface BaseTypes { 2734 /** 2735 * A custom type. The custom label should be supplied by user. 2736 */ 2737 public static int TYPE_CUSTOM = 0; 2738 } 2739 2740 /** 2741 * Columns common across the specific types. 2742 */ 2743 protected interface CommonColumns extends BaseTypes { 2744 /** 2745 * The data for the contact method. 2746 * <P>Type: TEXT</P> 2747 */ 2748 public static final String DATA = DataColumns.DATA1; 2749 2750 /** 2751 * The type of data, for example Home or Work. 2752 * <P>Type: INTEGER</P> 2753 */ 2754 public static final String TYPE = DataColumns.DATA2; 2755 2756 /** 2757 * The user defined label for the the contact method. 2758 * <P>Type: TEXT</P> 2759 */ 2760 public static final String LABEL = DataColumns.DATA3; 2761 } 2762 2763 /** 2764 * A data kind representing the contact's proper name. You can use all 2765 * columns defined for {@link ContactsContract.Data} as well as the following aliases. 2766 * 2767 * <h2>Column aliases</h2> 2768 * <table class="jd-sumtable"> 2769 * <tr> 2770 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 2771 * </tr> 2772 * <tr> 2773 * <td>String</td> 2774 * <td>{@link #DISPLAY_NAME}</td> 2775 * <td>{@link #DATA1}</td> 2776 * <td></td> 2777 * </tr> 2778 * <tr> 2779 * <td>String</td> 2780 * <td>{@link #GIVEN_NAME}</td> 2781 * <td>{@link #DATA2}</td> 2782 * <td></td> 2783 * </tr> 2784 * <tr> 2785 * <td>String</td> 2786 * <td>{@link #FAMILY_NAME}</td> 2787 * <td>{@link #DATA3}</td> 2788 * <td></td> 2789 * </tr> 2790 * <tr> 2791 * <td>String</td> 2792 * <td>{@link #PREFIX}</td> 2793 * <td>{@link #DATA4}</td> 2794 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> 2795 * </tr> 2796 * <tr> 2797 * <td>String</td> 2798 * <td>{@link #MIDDLE_NAME}</td> 2799 * <td>{@link #DATA5}</td> 2800 * <td></td> 2801 * </tr> 2802 * <tr> 2803 * <td>String</td> 2804 * <td>{@link #SUFFIX}</td> 2805 * <td>{@link #DATA6}</td> 2806 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> 2807 * </tr> 2808 * <tr> 2809 * <td>String</td> 2810 * <td>{@link #PHONETIC_GIVEN_NAME}</td> 2811 * <td>{@link #DATA7}</td> 2812 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> 2813 * </tr> 2814 * <tr> 2815 * <td>String</td> 2816 * <td>{@link #PHONETIC_MIDDLE_NAME}</td> 2817 * <td>{@link #DATA8}</td> 2818 * <td></td> 2819 * </tr> 2820 * <tr> 2821 * <td>String</td> 2822 * <td>{@link #PHONETIC_FAMILY_NAME}</td> 2823 * <td>{@link #DATA9}</td> 2824 * <td></td> 2825 * </tr> 2826 * </table> 2827 */ 2828 public static final class StructuredName implements DataColumnsWithJoins { 2829 /** 2830 * This utility class cannot be instantiated 2831 */ 2832 private StructuredName() {} 2833 2834 /** MIME type used when storing this in data table. */ 2835 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; 2836 2837 /** 2838 * The name that should be used to display the contact. 2839 * <i>Unstructured component of the name should be consistent with 2840 * its structured representation.</i> 2841 * <p> 2842 * Type: TEXT 2843 */ 2844 public static final String DISPLAY_NAME = DATA1; 2845 2846 /** 2847 * The given name for the contact. 2848 * <P>Type: TEXT</P> 2849 */ 2850 public static final String GIVEN_NAME = DATA2; 2851 2852 /** 2853 * The family name for the contact. 2854 * <P>Type: TEXT</P> 2855 */ 2856 public static final String FAMILY_NAME = DATA3; 2857 2858 /** 2859 * The contact's honorific prefix, e.g. "Sir" 2860 * <P>Type: TEXT</P> 2861 */ 2862 public static final String PREFIX = DATA4; 2863 2864 /** 2865 * The contact's middle name 2866 * <P>Type: TEXT</P> 2867 */ 2868 public static final String MIDDLE_NAME = DATA5; 2869 2870 /** 2871 * The contact's honorific suffix, e.g. "Jr" 2872 */ 2873 public static final String SUFFIX = DATA6; 2874 2875 /** 2876 * The phonetic version of the given name for the contact. 2877 * <P>Type: TEXT</P> 2878 */ 2879 public static final String PHONETIC_GIVEN_NAME = DATA7; 2880 2881 /** 2882 * The phonetic version of the additional name for the contact. 2883 * <P>Type: TEXT</P> 2884 */ 2885 public static final String PHONETIC_MIDDLE_NAME = DATA8; 2886 2887 /** 2888 * The phonetic version of the family name for the contact. 2889 * <P>Type: TEXT</P> 2890 */ 2891 public static final String PHONETIC_FAMILY_NAME = DATA9; 2892 } 2893 2894 /** 2895 * <p>A data kind representing the contact's nickname. For example, for 2896 * Bob Parr ("Mr. Incredible"): 2897 * <pre> 2898 * ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); 2899 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 2900 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 2901 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 2902 * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") 2903 * .build()); 2904 * 2905 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 2906 * .withValue(Data.RAW_CONTACT_ID, rawContactId) 2907 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) 2908 * .withValue(Nickname.NAME, "Mr. Incredible") 2909 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) 2910 * .withValue(Nickname.LABEL, "Superhero") 2911 * .build()); 2912 * 2913 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 2914 * </pre> 2915 * </p> 2916 * <p> 2917 * You can use all columns defined for {@link ContactsContract.Data} as well as the 2918 * following aliases. 2919 * </p> 2920 * 2921 * <h2>Column aliases</h2> 2922 * <table class="jd-sumtable"> 2923 * <tr> 2924 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> 2925 * </tr> 2926 * <tr> 2927 * <td>String</td> 2928 * <td>{@link #NAME}</td> 2929 * <td>{@link #DATA1}</td> 2930 * <td></td> 2931 * </tr> 2932 * <tr> 2933 * <td>int</td> 2934 * <td>{@link #TYPE}</td> 2935 * <td>{@link #DATA2}</td> 2936 * <td> 2937 * Allowed values are: 2938 * <p> 2939 * <ul> 2940 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 2941 * <li>{@link #TYPE_DEFAULT}</li> 2942 * <li>{@link #TYPE_OTHER_NAME}</li> 2943 * <li>{@link #TYPE_MAINDEN_NAME}</li> 2944 * <li>{@link #TYPE_SHORT_NAME}</li> 2945 * <li>{@link #TYPE_INITIALS}</li> 2946 * </ul> 2947 * </p> 2948 * </td> 2949 * </tr> 2950 * <tr> 2951 * <td>String</td> 2952 * <td>{@link #LABEL}</td> 2953 * <td>{@link #DATA3}</td> 2954 * <td></td> 2955 * </tr> 2956 * </table> 2957 */ 2958 public static final class Nickname implements DataColumnsWithJoins, CommonColumns { 2959 /** 2960 * This utility class cannot be instantiated 2961 */ 2962 private Nickname() {} 2963 2964 /** MIME type used when storing this in data table. */ 2965 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; 2966 2967 public static final int TYPE_DEFAULT = 1; 2968 public static final int TYPE_OTHER_NAME = 2; 2969 public static final int TYPE_MAINDEN_NAME = 3; 2970 public static final int TYPE_SHORT_NAME = 4; 2971 public static final int TYPE_INITIALS = 5; 2972 2973 /** 2974 * The name itself 2975 */ 2976 public static final String NAME = DATA; 2977 } 2978 2979 /** 2980 * <p> 2981 * A data kind representing a telephone number. 2982 * </p> 2983 * <p> 2984 * You can use all columns defined for {@link ContactsContract.Data} as 2985 * well as the following aliases. 2986 * </p> 2987 * <h2>Column aliases</h2> 2988 * <table class="jd-sumtable"> 2989 * <tr> 2990 * <th>Type</th> 2991 * <th>Alias</th><th colspan='2'>Data column</th> 2992 * </tr> 2993 * <tr> 2994 * <td>String</td> 2995 * <td>{@link #NUMBER}</td> 2996 * <td>{@link #DATA1}</td> 2997 * <td></td> 2998 * </tr> 2999 * <tr> 3000 * <td>int</td> 3001 * <td>{@link #TYPE}</td> 3002 * <td>{@link #DATA2}</td> 3003 * <td>Allowed values are: 3004 * <p> 3005 * <ul> 3006 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3007 * <li>{@link #TYPE_HOME}</li> 3008 * <li>{@link #TYPE_MOBILE}</li> 3009 * <li>{@link #TYPE_WORK}</li> 3010 * <li>{@link #TYPE_FAX_WORK}</li> 3011 * <li>{@link #TYPE_FAX_HOME}</li> 3012 * <li>{@link #TYPE_PAGER}</li> 3013 * <li>{@link #TYPE_OTHER}</li> 3014 * <li>{@link #TYPE_CALLBACK}</li> 3015 * <li>{@link #TYPE_CAR}</li> 3016 * <li>{@link #TYPE_COMPANY_MAIN}</li> 3017 * <li>{@link #TYPE_ISDN}</li> 3018 * <li>{@link #TYPE_MAIN}</li> 3019 * <li>{@link #TYPE_OTHER_FAX}</li> 3020 * <li>{@link #TYPE_RADIO}</li> 3021 * <li>{@link #TYPE_TELEX}</li> 3022 * <li>{@link #TYPE_TTY_TDD}</li> 3023 * <li>{@link #TYPE_WORK_MOBILE}</li> 3024 * <li>{@link #TYPE_WORK_PAGER}</li> 3025 * <li>{@link #TYPE_ASSISTANT}</li> 3026 * <li>{@link #TYPE_MMS}</li> 3027 * </ul> 3028 * </p> 3029 * </td> 3030 * </tr> 3031 * <tr> 3032 * <td>String</td> 3033 * <td>{@link #LABEL}</td> 3034 * <td>{@link #DATA3}</td> 3035 * <td></td> 3036 * </tr> 3037 * </table> 3038 */ 3039 public static final class Phone implements DataColumnsWithJoins, CommonColumns { 3040 /** 3041 * This utility class cannot be instantiated 3042 */ 3043 private Phone() {} 3044 3045 /** MIME type used when storing this in data table. */ 3046 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2"; 3047 3048 /** 3049 * The MIME type of {@link #CONTENT_URI} providing a directory of 3050 * phones. 3051 */ 3052 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; 3053 3054 /** 3055 * The content:// style URI for all data records of the 3056 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 3057 * associated raw contact and aggregate contact data. 3058 */ 3059 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 3060 "phones"); 3061 3062 /** 3063 * The content:// style URL for phone lookup using a filter. The filter returns 3064 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 3065 * to display names as well as phone numbers. The filter argument should be passed 3066 * as an additional path segment after this URI. 3067 */ 3068 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 3069 "filter"); 3070 3071 public static final int TYPE_HOME = 1; 3072 public static final int TYPE_MOBILE = 2; 3073 public static final int TYPE_WORK = 3; 3074 public static final int TYPE_FAX_WORK = 4; 3075 public static final int TYPE_FAX_HOME = 5; 3076 public static final int TYPE_PAGER = 6; 3077 public static final int TYPE_OTHER = 7; 3078 public static final int TYPE_CALLBACK = 8; 3079 public static final int TYPE_CAR = 9; 3080 public static final int TYPE_COMPANY_MAIN = 10; 3081 public static final int TYPE_ISDN = 11; 3082 public static final int TYPE_MAIN = 12; 3083 public static final int TYPE_OTHER_FAX = 13; 3084 public static final int TYPE_RADIO = 14; 3085 public static final int TYPE_TELEX = 15; 3086 public static final int TYPE_TTY_TDD = 16; 3087 public static final int TYPE_WORK_MOBILE = 17; 3088 public static final int TYPE_WORK_PAGER = 18; 3089 public static final int TYPE_ASSISTANT = 19; 3090 public static final int TYPE_MMS = 20; 3091 3092 /** 3093 * The phone number as the user entered it. 3094 * <P>Type: TEXT</P> 3095 */ 3096 public static final String NUMBER = DATA; 3097 3098 /** 3099 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 3100 * @hide 3101 */ 3102 @Deprecated 3103 public static final CharSequence getDisplayLabel(Context context, int type, 3104 CharSequence label, CharSequence[] labelArray) { 3105 return getTypeLabel(context.getResources(), type, label); 3106 } 3107 3108 /** 3109 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. 3110 * @hide 3111 */ 3112 @Deprecated 3113 public static final CharSequence getDisplayLabel(Context context, int type, 3114 CharSequence label) { 3115 return getTypeLabel(context.getResources(), type, label); 3116 } 3117 3118 /** 3119 * Return the string resource that best describes the given 3120 * {@link #TYPE}. Will always return a valid resource. 3121 */ 3122 public static final int getTypeLabelResource(int type) { 3123 switch (type) { 3124 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; 3125 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; 3126 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; 3127 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; 3128 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; 3129 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; 3130 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; 3131 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; 3132 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; 3133 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; 3134 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; 3135 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; 3136 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; 3137 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; 3138 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; 3139 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; 3140 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; 3141 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; 3142 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; 3143 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; 3144 default: return com.android.internal.R.string.phoneTypeCustom; 3145 } 3146 } 3147 3148 /** 3149 * Return a {@link CharSequence} that best describes the given type, 3150 * possibly substituting the given {@link #LABEL} value 3151 * for {@link #TYPE_CUSTOM}. 3152 */ 3153 public static final CharSequence getTypeLabel(Resources res, int type, 3154 CharSequence label) { 3155 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { 3156 return label; 3157 } else { 3158 final int labelRes = getTypeLabelResource(type); 3159 return res.getText(labelRes); 3160 } 3161 } 3162 } 3163 3164 /** 3165 * <p> 3166 * A data kind representing an email address. 3167 * </p> 3168 * <p> 3169 * You can use all columns defined for {@link ContactsContract.Data} as 3170 * well as the following aliases. 3171 * </p> 3172 * <h2>Column aliases</h2> 3173 * <table class="jd-sumtable"> 3174 * <tr> 3175 * <th>Type</th> 3176 * <th>Alias</th><th colspan='2'>Data column</th> 3177 * </tr> 3178 * <tr> 3179 * <td>String</td> 3180 * <td>{@link #DATA}</td> 3181 * <td>{@link #DATA1}</td> 3182 * <td>Email address itself.</td> 3183 * </tr> 3184 * <tr> 3185 * <td>int</td> 3186 * <td>{@link #TYPE}</td> 3187 * <td>{@link #DATA2}</td> 3188 * <td>Allowed values are: 3189 * <p> 3190 * <ul> 3191 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3192 * <li>{@link #TYPE_HOME}</li> 3193 * <li>{@link #TYPE_WORK}</li> 3194 * <li>{@link #TYPE_OTHER}</li> 3195 * <li>{@link #TYPE_MOBILE}</li> 3196 * </ul> 3197 * </p> 3198 * </td> 3199 * </tr> 3200 * <tr> 3201 * <td>String</td> 3202 * <td>{@link #LABEL}</td> 3203 * <td>{@link #DATA3}</td> 3204 * <td></td> 3205 * </tr> 3206 * </table> 3207 */ 3208 public static final class Email implements DataColumnsWithJoins, CommonColumns { 3209 /** 3210 * This utility class cannot be instantiated 3211 */ 3212 private Email() {} 3213 3214 /** MIME type used when storing this in data table. */ 3215 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2"; 3216 3217 /** 3218 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. 3219 */ 3220 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; 3221 3222 /** 3223 * The content:// style URI for all data records of the 3224 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the 3225 * associated raw contact and aggregate contact data. 3226 */ 3227 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 3228 "emails"); 3229 3230 /** 3231 * <p> 3232 * The content:// style URL for looking up data rows by email address. The 3233 * lookup argument, an email address, should be passed as an additional path segment 3234 * after this URI. 3235 * </p> 3236 * <p>Example: 3237 * <pre> 3238 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); 3239 * Cursor c = getContentResolver().query(uri, 3240 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, 3241 * null, null, null); 3242 * </pre> 3243 * </p> 3244 */ 3245 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, 3246 "lookup"); 3247 3248 /** 3249 * <p> 3250 * The content:// style URL for email lookup using a filter. The filter returns 3251 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied 3252 * to display names as well as email addresses. The filter argument should be passed 3253 * as an additional path segment after this URI. 3254 * </p> 3255 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" 3256 * as well as "Bob Parr (incredible@android.com)". 3257 * <pre> 3258 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); 3259 * Cursor c = getContentResolver().query(uri, 3260 * new String[]{Email.DISPLAY_NAME, Email.DATA}, 3261 * null, null, null); 3262 * </pre> 3263 * </p> 3264 */ 3265 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, 3266 "filter"); 3267 3268 /** 3269 * The email address. 3270 * <P>Type: TEXT</P> 3271 * @hide TODO: Unhide in a separate CL 3272 */ 3273 public static final String ADDRESS = DATA1; 3274 3275 public static final int TYPE_HOME = 1; 3276 public static final int TYPE_WORK = 2; 3277 public static final int TYPE_OTHER = 3; 3278 public static final int TYPE_MOBILE = 4; 3279 3280 /** 3281 * The display name for the email address 3282 * <P>Type: TEXT</P> 3283 */ 3284 public static final String DISPLAY_NAME = DATA4; 3285 3286 /** 3287 * Return the string resource that best describes the given 3288 * {@link #TYPE}. Will always return a valid resource. 3289 */ 3290 public static final int getTypeLabelResource(int type) { 3291 switch (type) { 3292 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; 3293 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; 3294 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; 3295 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; 3296 default: return com.android.internal.R.string.emailTypeCustom; 3297 } 3298 } 3299 3300 /** 3301 * Return a {@link CharSequence} that best describes the given type, 3302 * possibly substituting the given {@link #LABEL} value 3303 * for {@link #TYPE_CUSTOM}. 3304 */ 3305 public static final CharSequence getTypeLabel(Resources res, int type, 3306 CharSequence label) { 3307 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 3308 return label; 3309 } else { 3310 final int labelRes = getTypeLabelResource(type); 3311 return res.getText(labelRes); 3312 } 3313 } 3314 } 3315 3316 /** 3317 * <p> 3318 * A data kind representing a postal addresses. 3319 * </p> 3320 * <p> 3321 * You can use all columns defined for {@link ContactsContract.Data} as 3322 * well as the following aliases. 3323 * </p> 3324 * <h2>Column aliases</h2> 3325 * <table class="jd-sumtable"> 3326 * <tr> 3327 * <th>Type</th> 3328 * <th>Alias</th><th colspan='2'>Data column</th> 3329 * </tr> 3330 * <tr> 3331 * <td>String</td> 3332 * <td>{@link #FORMATTED_ADDRESS}</td> 3333 * <td>{@link #DATA1}</td> 3334 * <td></td> 3335 * </tr> 3336 * <tr> 3337 * <td>int</td> 3338 * <td>{@link #TYPE}</td> 3339 * <td>{@link #DATA2}</td> 3340 * <td>Allowed values are: 3341 * <p> 3342 * <ul> 3343 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3344 * <li>{@link #TYPE_HOME}</li> 3345 * <li>{@link #TYPE_WORK}</li> 3346 * <li>{@link #TYPE_OTHER}</li> 3347 * </ul> 3348 * </p> 3349 * </td> 3350 * </tr> 3351 * <tr> 3352 * <td>String</td> 3353 * <td>{@link #LABEL}</td> 3354 * <td>{@link #DATA3}</td> 3355 * <td></td> 3356 * </tr> 3357 * <tr> 3358 * <td>String</td> 3359 * <td>{@link #STREET}</td> 3360 * <td>{@link #DATA4}</td> 3361 * <td></td> 3362 * </tr> 3363 * <tr> 3364 * <td>String</td> 3365 * <td>{@link #POBOX}</td> 3366 * <td>{@link #DATA5}</td> 3367 * <td>Post Office Box number</td> 3368 * </tr> 3369 * <tr> 3370 * <td>String</td> 3371 * <td>{@link #NEIGHBORHOOD}</td> 3372 * <td>{@link #DATA6}</td> 3373 * <td></td> 3374 * </tr> 3375 * <tr> 3376 * <td>String</td> 3377 * <td>{@link #CITY}</td> 3378 * <td>{@link #DATA7}</td> 3379 * <td></td> 3380 * </tr> 3381 * <tr> 3382 * <td>String</td> 3383 * <td>{@link #REGION}</td> 3384 * <td>{@link #DATA8}</td> 3385 * <td></td> 3386 * </tr> 3387 * <tr> 3388 * <td>String</td> 3389 * <td>{@link #POSTCODE}</td> 3390 * <td>{@link #DATA9}</td> 3391 * <td></td> 3392 * </tr> 3393 * <tr> 3394 * <td>String</td> 3395 * <td>{@link #COUNTRY}</td> 3396 * <td>{@link #DATA10}</td> 3397 * <td></td> 3398 * </tr> 3399 * </table> 3400 */ 3401 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns { 3402 /** 3403 * This utility class cannot be instantiated 3404 */ 3405 private StructuredPostal() { 3406 } 3407 3408 /** MIME type used when storing this in data table. */ 3409 public static final String CONTENT_ITEM_TYPE = 3410 "vnd.android.cursor.item/postal-address_v2"; 3411 3412 /** 3413 * The MIME type of {@link #CONTENT_URI} providing a directory of 3414 * postal addresses. 3415 */ 3416 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2"; 3417 3418 /** 3419 * The content:// style URI for all data records of the 3420 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. 3421 */ 3422 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, 3423 "postals"); 3424 3425 public static final int TYPE_HOME = 1; 3426 public static final int TYPE_WORK = 2; 3427 public static final int TYPE_OTHER = 3; 3428 3429 /** 3430 * The full, unstructured postal address. <i>This field must be 3431 * consistent with any structured data.</i> 3432 * <p> 3433 * Type: TEXT 3434 */ 3435 public static final String FORMATTED_ADDRESS = DATA; 3436 3437 /** 3438 * Can be street, avenue, road, etc. This element also includes the 3439 * house number and room/apartment/flat/floor number. 3440 * <p> 3441 * Type: TEXT 3442 */ 3443 public static final String STREET = DATA4; 3444 3445 /** 3446 * Covers actual P.O. boxes, drawers, locked bags, etc. This is 3447 * usually but not always mutually exclusive with street. 3448 * <p> 3449 * Type: TEXT 3450 */ 3451 public static final String POBOX = DATA5; 3452 3453 /** 3454 * This is used to disambiguate a street address when a city 3455 * contains more than one street with the same name, or to specify a 3456 * small place whose mail is routed through a larger postal town. In 3457 * China it could be a county or a minor city. 3458 * <p> 3459 * Type: TEXT 3460 */ 3461 public static final String NEIGHBORHOOD = DATA6; 3462 3463 /** 3464 * Can be city, village, town, borough, etc. This is the postal town 3465 * and not necessarily the place of residence or place of business. 3466 * <p> 3467 * Type: TEXT 3468 */ 3469 public static final String CITY = DATA7; 3470 3471 /** 3472 * A state, province, county (in Ireland), Land (in Germany), 3473 * departement (in France), etc. 3474 * <p> 3475 * Type: TEXT 3476 */ 3477 public static final String REGION = DATA8; 3478 3479 /** 3480 * Postal code. Usually country-wide, but sometimes specific to the 3481 * city (e.g. "2" in "Dublin 2, Ireland" addresses). 3482 * <p> 3483 * Type: TEXT 3484 */ 3485 public static final String POSTCODE = DATA9; 3486 3487 /** 3488 * The name or code of the country. 3489 * <p> 3490 * Type: TEXT 3491 */ 3492 public static final String COUNTRY = DATA10; 3493 3494 /** 3495 * Return the string resource that best describes the given 3496 * {@link #TYPE}. Will always return a valid resource. 3497 */ 3498 public static final int getTypeLabelResource(int type) { 3499 switch (type) { 3500 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; 3501 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; 3502 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; 3503 default: return com.android.internal.R.string.postalTypeCustom; 3504 } 3505 } 3506 3507 /** 3508 * Return a {@link CharSequence} that best describes the given type, 3509 * possibly substituting the given {@link #LABEL} value 3510 * for {@link #TYPE_CUSTOM}. 3511 */ 3512 public static final CharSequence getTypeLabel(Resources res, int type, 3513 CharSequence label) { 3514 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 3515 return label; 3516 } else { 3517 final int labelRes = getTypeLabelResource(type); 3518 return res.getText(labelRes); 3519 } 3520 } 3521 } 3522 3523 /** 3524 * <p> 3525 * A data kind representing an IM address 3526 * </p> 3527 * <p> 3528 * You can use all columns defined for {@link ContactsContract.Data} as 3529 * well as the following aliases. 3530 * </p> 3531 * <h2>Column aliases</h2> 3532 * <table class="jd-sumtable"> 3533 * <tr> 3534 * <th>Type</th> 3535 * <th>Alias</th><th colspan='2'>Data column</th> 3536 * </tr> 3537 * <tr> 3538 * <td>String</td> 3539 * <td>{@link #DATA}</td> 3540 * <td>{@link #DATA1}</td> 3541 * <td></td> 3542 * </tr> 3543 * <tr> 3544 * <td>int</td> 3545 * <td>{@link #TYPE}</td> 3546 * <td>{@link #DATA2}</td> 3547 * <td>Allowed values are: 3548 * <p> 3549 * <ul> 3550 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3551 * <li>{@link #TYPE_HOME}</li> 3552 * <li>{@link #TYPE_WORK}</li> 3553 * <li>{@link #TYPE_OTHER}</li> 3554 * </ul> 3555 * </p> 3556 * </td> 3557 * </tr> 3558 * <tr> 3559 * <td>String</td> 3560 * <td>{@link #LABEL}</td> 3561 * <td>{@link #DATA3}</td> 3562 * <td></td> 3563 * </tr> 3564 * <tr> 3565 * <td>String</td> 3566 * <td>{@link #PROTOCOL}</td> 3567 * <td>{@link #DATA5}</td> 3568 * <td> 3569 * <p> 3570 * Allowed values: 3571 * <ul> 3572 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name 3573 * as {@link #CUSTOM_PROTOCOL}.</li> 3574 * <li>{@link #PROTOCOL_AIM}</li> 3575 * <li>{@link #PROTOCOL_MSN}</li> 3576 * <li>{@link #PROTOCOL_YAHOO}</li> 3577 * <li>{@link #PROTOCOL_SKYPE}</li> 3578 * <li>{@link #PROTOCOL_QQ}</li> 3579 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> 3580 * <li>{@link #PROTOCOL_ICQ}</li> 3581 * <li>{@link #PROTOCOL_JABBER}</li> 3582 * <li>{@link #PROTOCOL_NETMEETING}</li> 3583 * </ul> 3584 * </p> 3585 * </td> 3586 * </tr> 3587 * <tr> 3588 * <td>String</td> 3589 * <td>{@link #CUSTOM_PROTOCOL}</td> 3590 * <td>{@link #DATA6}</td> 3591 * <td></td> 3592 * </tr> 3593 * </table> 3594 */ 3595 public static final class Im implements DataColumnsWithJoins, CommonColumns { 3596 /** 3597 * This utility class cannot be instantiated 3598 */ 3599 private Im() {} 3600 3601 /** MIME type used when storing this in data table. */ 3602 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; 3603 3604 public static final int TYPE_HOME = 1; 3605 public static final int TYPE_WORK = 2; 3606 public static final int TYPE_OTHER = 3; 3607 3608 /** 3609 * This column should be populated with one of the defined 3610 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this 3611 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} 3612 * should contain the name of the custom protocol. 3613 */ 3614 public static final String PROTOCOL = DATA5; 3615 3616 public static final String CUSTOM_PROTOCOL = DATA6; 3617 3618 /* 3619 * The predefined IM protocol types. 3620 */ 3621 public static final int PROTOCOL_CUSTOM = -1; 3622 public static final int PROTOCOL_AIM = 0; 3623 public static final int PROTOCOL_MSN = 1; 3624 public static final int PROTOCOL_YAHOO = 2; 3625 public static final int PROTOCOL_SKYPE = 3; 3626 public static final int PROTOCOL_QQ = 4; 3627 public static final int PROTOCOL_GOOGLE_TALK = 5; 3628 public static final int PROTOCOL_ICQ = 6; 3629 public static final int PROTOCOL_JABBER = 7; 3630 public static final int PROTOCOL_NETMEETING = 8; 3631 3632 /** 3633 * Return the string resource that best describes the given 3634 * {@link #TYPE}. Will always return a valid resource. 3635 */ 3636 public static final int getTypeLabelResource(int type) { 3637 switch (type) { 3638 case TYPE_HOME: return com.android.internal.R.string.imTypeHome; 3639 case TYPE_WORK: return com.android.internal.R.string.imTypeWork; 3640 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; 3641 default: return com.android.internal.R.string.imTypeCustom; 3642 } 3643 } 3644 3645 /** 3646 * Return a {@link CharSequence} that best describes the given type, 3647 * possibly substituting the given {@link #LABEL} value 3648 * for {@link #TYPE_CUSTOM}. 3649 */ 3650 public static final CharSequence getTypeLabel(Resources res, int type, 3651 CharSequence label) { 3652 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 3653 return label; 3654 } else { 3655 final int labelRes = getTypeLabelResource(type); 3656 return res.getText(labelRes); 3657 } 3658 } 3659 3660 /** 3661 * Return the string resource that best describes the given 3662 * {@link #PROTOCOL}. Will always return a valid resource. 3663 */ 3664 public static final int getProtocolLabelResource(int type) { 3665 switch (type) { 3666 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; 3667 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; 3668 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; 3669 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; 3670 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; 3671 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; 3672 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; 3673 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; 3674 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; 3675 default: return com.android.internal.R.string.imProtocolCustom; 3676 } 3677 } 3678 3679 /** 3680 * Return a {@link CharSequence} that best describes the given 3681 * protocol, possibly substituting the given 3682 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. 3683 */ 3684 public static final CharSequence getProtocolLabel(Resources res, int type, 3685 CharSequence label) { 3686 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { 3687 return label; 3688 } else { 3689 final int labelRes = getProtocolLabelResource(type); 3690 return res.getText(labelRes); 3691 } 3692 } 3693 } 3694 3695 /** 3696 * <p> 3697 * A data kind representing an organization. 3698 * </p> 3699 * <p> 3700 * You can use all columns defined for {@link ContactsContract.Data} as 3701 * well as the following aliases. 3702 * </p> 3703 * <h2>Column aliases</h2> 3704 * <table class="jd-sumtable"> 3705 * <tr> 3706 * <th>Type</th> 3707 * <th>Alias</th><th colspan='2'>Data column</th> 3708 * </tr> 3709 * <tr> 3710 * <td>String</td> 3711 * <td>{@link #COMPANY}</td> 3712 * <td>{@link #DATA1}</td> 3713 * <td></td> 3714 * </tr> 3715 * <tr> 3716 * <td>int</td> 3717 * <td>{@link #TYPE}</td> 3718 * <td>{@link #DATA2}</td> 3719 * <td>Allowed values are: 3720 * <p> 3721 * <ul> 3722 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3723 * <li>{@link #TYPE_WORK}</li> 3724 * <li>{@link #TYPE_OTHER}</li> 3725 * </ul> 3726 * </p> 3727 * </td> 3728 * </tr> 3729 * <tr> 3730 * <td>String</td> 3731 * <td>{@link #LABEL}</td> 3732 * <td>{@link #DATA3}</td> 3733 * <td></td> 3734 * </tr> 3735 * <tr> 3736 * <td>String</td> 3737 * <td>{@link #TITLE}</td> 3738 * <td>{@link #DATA4}</td> 3739 * <td></td> 3740 * </tr> 3741 * <tr> 3742 * <td>String</td> 3743 * <td>{@link #DEPARTMENT}</td> 3744 * <td>{@link #DATA5}</td> 3745 * <td></td> 3746 * </tr> 3747 * <tr> 3748 * <td>String</td> 3749 * <td>{@link #JOB_DESCRIPTION}</td> 3750 * <td>{@link #DATA6}</td> 3751 * <td></td> 3752 * </tr> 3753 * <tr> 3754 * <td>String</td> 3755 * <td>{@link #SYMBOL}</td> 3756 * <td>{@link #DATA7}</td> 3757 * <td></td> 3758 * </tr> 3759 * <tr> 3760 * <td>String</td> 3761 * <td>{@link #PHONETIC_NAME}</td> 3762 * <td>{@link #DATA8}</td> 3763 * <td></td> 3764 * </tr> 3765 * <tr> 3766 * <td>String</td> 3767 * <td>{@link #OFFICE_LOCATION}</td> 3768 * <td>{@link #DATA9}</td> 3769 * <td></td> 3770 * </tr> 3771 * </table> 3772 */ 3773 public static final class Organization implements DataColumnsWithJoins, CommonColumns { 3774 /** 3775 * This utility class cannot be instantiated 3776 */ 3777 private Organization() {} 3778 3779 /** MIME type used when storing this in data table. */ 3780 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; 3781 3782 public static final int TYPE_WORK = 1; 3783 public static final int TYPE_OTHER = 2; 3784 3785 /** 3786 * The company as the user entered it. 3787 * <P>Type: TEXT</P> 3788 */ 3789 public static final String COMPANY = DATA; 3790 3791 /** 3792 * The position title at this company as the user entered it. 3793 * <P>Type: TEXT</P> 3794 */ 3795 public static final String TITLE = DATA4; 3796 3797 /** 3798 * The department at this company as the user entered it. 3799 * <P>Type: TEXT</P> 3800 */ 3801 public static final String DEPARTMENT = DATA5; 3802 3803 /** 3804 * The job description at this company as the user entered it. 3805 * <P>Type: TEXT</P> 3806 */ 3807 public static final String JOB_DESCRIPTION = DATA6; 3808 3809 /** 3810 * The symbol of this company as the user entered it. 3811 * <P>Type: TEXT</P> 3812 */ 3813 public static final String SYMBOL = DATA7; 3814 3815 /** 3816 * The phonetic name of this company as the user entered it. 3817 * <P>Type: TEXT</P> 3818 */ 3819 public static final String PHONETIC_NAME = DATA8; 3820 3821 /** 3822 * The office location of this organization. 3823 * <P>Type: TEXT</P> 3824 */ 3825 public static final String OFFICE_LOCATION = DATA9; 3826 3827 /** 3828 * Return the string resource that best describes the given 3829 * {@link #TYPE}. Will always return a valid resource. 3830 */ 3831 public static final int getTypeLabelResource(int type) { 3832 switch (type) { 3833 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; 3834 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; 3835 default: return com.android.internal.R.string.orgTypeCustom; 3836 } 3837 } 3838 3839 /** 3840 * Return a {@link CharSequence} that best describes the given type, 3841 * possibly substituting the given {@link #LABEL} value 3842 * for {@link #TYPE_CUSTOM}. 3843 */ 3844 public static final CharSequence getTypeLabel(Resources res, int type, 3845 CharSequence label) { 3846 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { 3847 return label; 3848 } else { 3849 final int labelRes = getTypeLabelResource(type); 3850 return res.getText(labelRes); 3851 } 3852 } 3853 } 3854 3855 /** 3856 * <p> 3857 * A data kind representing a relation. 3858 * </p> 3859 * <p> 3860 * You can use all columns defined for {@link ContactsContract.Data} as 3861 * well as the following aliases. 3862 * </p> 3863 * <h2>Column aliases</h2> 3864 * <table class="jd-sumtable"> 3865 * <tr> 3866 * <th>Type</th> 3867 * <th>Alias</th><th colspan='2'>Data column</th> 3868 * </tr> 3869 * <tr> 3870 * <td>String</td> 3871 * <td>{@link #NAME}</td> 3872 * <td>{@link #DATA1}</td> 3873 * <td></td> 3874 * </tr> 3875 * <tr> 3876 * <td>int</td> 3877 * <td>{@link #TYPE}</td> 3878 * <td>{@link #DATA2}</td> 3879 * <td>Allowed values are: 3880 * <p> 3881 * <ul> 3882 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3883 * <li>{@link #TYPE_ASSISTANT}</li> 3884 * <li>{@link #TYPE_BROTHER}</li> 3885 * <li>{@link #TYPE_CHILD}</li> 3886 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> 3887 * <li>{@link #TYPE_FATHER}</li> 3888 * <li>{@link #TYPE_FRIEND}</li> 3889 * <li>{@link #TYPE_MANAGER}</li> 3890 * <li>{@link #TYPE_MOTHER}</li> 3891 * <li>{@link #TYPE_PARENT}</li> 3892 * <li>{@link #TYPE_PARTNER}</li> 3893 * <li>{@link #TYPE_REFERRED_BY}</li> 3894 * <li>{@link #TYPE_RELATIVE}</li> 3895 * <li>{@link #TYPE_SISTER}</li> 3896 * <li>{@link #TYPE_SPOUSE}</li> 3897 * </ul> 3898 * </p> 3899 * </td> 3900 * </tr> 3901 * <tr> 3902 * <td>String</td> 3903 * <td>{@link #LABEL}</td> 3904 * <td>{@link #DATA3}</td> 3905 * <td></td> 3906 * </tr> 3907 * </table> 3908 */ 3909 public static final class Relation implements DataColumnsWithJoins, CommonColumns { 3910 /** 3911 * This utility class cannot be instantiated 3912 */ 3913 private Relation() {} 3914 3915 /** MIME type used when storing this in data table. */ 3916 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; 3917 3918 public static final int TYPE_ASSISTANT = 1; 3919 public static final int TYPE_BROTHER = 2; 3920 public static final int TYPE_CHILD = 3; 3921 public static final int TYPE_DOMESTIC_PARTNER = 4; 3922 public static final int TYPE_FATHER = 5; 3923 public static final int TYPE_FRIEND = 6; 3924 public static final int TYPE_MANAGER = 7; 3925 public static final int TYPE_MOTHER = 8; 3926 public static final int TYPE_PARENT = 9; 3927 public static final int TYPE_PARTNER = 10; 3928 public static final int TYPE_REFERRED_BY = 11; 3929 public static final int TYPE_RELATIVE = 12; 3930 public static final int TYPE_SISTER = 13; 3931 public static final int TYPE_SPOUSE = 14; 3932 3933 /** 3934 * The name of the relative as the user entered it. 3935 * <P>Type: TEXT</P> 3936 */ 3937 public static final String NAME = DATA; 3938 } 3939 3940 /** 3941 * <p> 3942 * A data kind representing an event. 3943 * </p> 3944 * <p> 3945 * You can use all columns defined for {@link ContactsContract.Data} as 3946 * well as the following aliases. 3947 * </p> 3948 * <h2>Column aliases</h2> 3949 * <table class="jd-sumtable"> 3950 * <tr> 3951 * <th>Type</th> 3952 * <th>Alias</th><th colspan='2'>Data column</th> 3953 * </tr> 3954 * <tr> 3955 * <td>String</td> 3956 * <td>{@link #START_DATE}</td> 3957 * <td>{@link #DATA1}</td> 3958 * <td></td> 3959 * </tr> 3960 * <tr> 3961 * <td>int</td> 3962 * <td>{@link #TYPE}</td> 3963 * <td>{@link #DATA2}</td> 3964 * <td>Allowed values are: 3965 * <p> 3966 * <ul> 3967 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 3968 * <li>{@link #TYPE_ANNIVERSARY}</li> 3969 * <li>{@link #TYPE_OTHER}</li> 3970 * <li>{@link #TYPE_BIRTHDAY}</li> 3971 * </ul> 3972 * </p> 3973 * </td> 3974 * </tr> 3975 * <tr> 3976 * <td>String</td> 3977 * <td>{@link #LABEL}</td> 3978 * <td>{@link #DATA3}</td> 3979 * <td></td> 3980 * </tr> 3981 * </table> 3982 */ 3983 public static final class Event implements DataColumnsWithJoins, CommonColumns { 3984 /** 3985 * This utility class cannot be instantiated 3986 */ 3987 private Event() {} 3988 3989 /** MIME type used when storing this in data table. */ 3990 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event"; 3991 3992 public static final int TYPE_ANNIVERSARY = 1; 3993 public static final int TYPE_OTHER = 2; 3994 public static final int TYPE_BIRTHDAY = 3; 3995 3996 /** 3997 * The event start date as the user entered it. 3998 * <P>Type: TEXT</P> 3999 */ 4000 public static final String START_DATE = DATA; 4001 4002 /** 4003 * Return the string resource that best describes the given 4004 * {@link #TYPE}. Will always return a valid resource. 4005 */ 4006 public static int getTypeResource(Integer type) { 4007 if (type == null) { 4008 return com.android.internal.R.string.eventTypeOther; 4009 } 4010 switch (type) { 4011 case TYPE_ANNIVERSARY: 4012 return com.android.internal.R.string.eventTypeAnniversary; 4013 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; 4014 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; 4015 default: return com.android.internal.R.string.eventTypeOther; 4016 } 4017 } 4018 } 4019 4020 /** 4021 * <p> 4022 * A data kind representing an photo for the contact. 4023 * </p> 4024 * <p> 4025 * Some sync adapters will choose to download photos in a separate 4026 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} 4027 * through {@link ContactsContract.Data#SYNC4} to store temporary 4028 * data, e.g. the image URL or ID, state of download, server-side version 4029 * of the image. It is allowed for the {@link #PHOTO} to be null. 4030 * </p> 4031 * <p> 4032 * You can use all columns defined for {@link ContactsContract.Data} as 4033 * well as the following aliases. 4034 * </p> 4035 * <h2>Column aliases</h2> 4036 * <table class="jd-sumtable"> 4037 * <tr> 4038 * <th>Type</th> 4039 * <th>Alias</th><th colspan='2'>Data column</th> 4040 * </tr> 4041 * <tr> 4042 * <td>BLOB</td> 4043 * <td>{@link #PHOTO}</td> 4044 * <td>{@link #DATA15}</td> 4045 * <td>By convention, binary data is stored in DATA15.</td> 4046 * </tr> 4047 * </table> 4048 */ 4049 public static final class Photo implements DataColumnsWithJoins { 4050 /** 4051 * This utility class cannot be instantiated 4052 */ 4053 private Photo() {} 4054 4055 /** MIME type used when storing this in data table. */ 4056 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; 4057 4058 /** 4059 * Thumbnail photo of the raw contact. This is the raw bytes of an image 4060 * that could be inflated using {@link android.graphics.BitmapFactory}. 4061 * <p> 4062 * Type: BLOB 4063 */ 4064 public static final String PHOTO = DATA15; 4065 } 4066 4067 /** 4068 * <p> 4069 * Notes about the contact. 4070 * </p> 4071 * <p> 4072 * You can use all columns defined for {@link ContactsContract.Data} as 4073 * well as the following aliases. 4074 * </p> 4075 * <h2>Column aliases</h2> 4076 * <table class="jd-sumtable"> 4077 * <tr> 4078 * <th>Type</th> 4079 * <th>Alias</th><th colspan='2'>Data column</th> 4080 * </tr> 4081 * <tr> 4082 * <td>String</td> 4083 * <td>{@link #NOTE}</td> 4084 * <td>{@link #DATA1}</td> 4085 * <td></td> 4086 * </tr> 4087 * </table> 4088 */ 4089 public static final class Note implements DataColumnsWithJoins { 4090 /** 4091 * This utility class cannot be instantiated 4092 */ 4093 private Note() {} 4094 4095 /** MIME type used when storing this in data table. */ 4096 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; 4097 4098 /** 4099 * The note text. 4100 * <P>Type: TEXT</P> 4101 */ 4102 public static final String NOTE = DATA1; 4103 } 4104 4105 /** 4106 * <p> 4107 * Group Membership. 4108 * </p> 4109 * <p> 4110 * You can use all columns defined for {@link ContactsContract.Data} as 4111 * well as the following aliases. 4112 * </p> 4113 * <h2>Column aliases</h2> 4114 * <table class="jd-sumtable"> 4115 * <tr> 4116 * <th>Type</th> 4117 * <th>Alias</th><th colspan='2'>Data column</th> 4118 * </tr> 4119 * <tr> 4120 * <td>long</td> 4121 * <td>{@link #GROUP_ROW_ID}</td> 4122 * <td>{@link #DATA1}</td> 4123 * <td></td> 4124 * </tr> 4125 * <tr> 4126 * <td>String</td> 4127 * <td>{@link #GROUP_SOURCE_ID}</td> 4128 * <td>none</td> 4129 * <td> 4130 * <p> 4131 * The sourceid of the group that this group membership refers to. 4132 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when 4133 * inserting a row. 4134 * </p> 4135 * <p> 4136 * If this field is specified, the provider will first try to 4137 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group 4138 * is found, it will use the corresponding row id. If the group is not 4139 * found, it will create one. 4140 * </td> 4141 * </tr> 4142 * </table> 4143 */ 4144 public static final class GroupMembership implements DataColumnsWithJoins { 4145 /** 4146 * This utility class cannot be instantiated 4147 */ 4148 private GroupMembership() {} 4149 4150 /** MIME type used when storing this in data table. */ 4151 public static final String CONTENT_ITEM_TYPE = 4152 "vnd.android.cursor.item/group_membership"; 4153 4154 /** 4155 * The row id of the group that this group membership refers to. Exactly one of 4156 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. 4157 * <P>Type: INTEGER</P> 4158 */ 4159 public static final String GROUP_ROW_ID = DATA1; 4160 4161 /** 4162 * The sourceid of the group that this group membership refers to. Exactly one of 4163 * this or {@link #GROUP_ROW_ID} must be set when inserting a row. 4164 * <P>Type: TEXT</P> 4165 */ 4166 public static final String GROUP_SOURCE_ID = "group_sourceid"; 4167 } 4168 4169 /** 4170 * <p> 4171 * A data kind representing a website related to the contact. 4172 * </p> 4173 * <p> 4174 * You can use all columns defined for {@link ContactsContract.Data} as 4175 * well as the following aliases. 4176 * </p> 4177 * <h2>Column aliases</h2> 4178 * <table class="jd-sumtable"> 4179 * <tr> 4180 * <th>Type</th> 4181 * <th>Alias</th><th colspan='2'>Data column</th> 4182 * </tr> 4183 * <tr> 4184 * <td>String</td> 4185 * <td>{@link #URL}</td> 4186 * <td>{@link #DATA1}</td> 4187 * <td></td> 4188 * </tr> 4189 * <tr> 4190 * <td>int</td> 4191 * <td>{@link #TYPE}</td> 4192 * <td>{@link #DATA2}</td> 4193 * <td>Allowed values are: 4194 * <p> 4195 * <ul> 4196 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> 4197 * <li>{@link #TYPE_HOMEPAGE}</li> 4198 * <li>{@link #TYPE_BLOG}</li> 4199 * <li>{@link #TYPE_PROFILE}</li> 4200 * <li>{@link #TYPE_HOME}</li> 4201 * <li>{@link #TYPE_WORK}</li> 4202 * <li>{@link #TYPE_FTP}</li> 4203 * <li>{@link #TYPE_OTHER}</li> 4204 * </ul> 4205 * </p> 4206 * </td> 4207 * </tr> 4208 * <tr> 4209 * <td>String</td> 4210 * <td>{@link #LABEL}</td> 4211 * <td>{@link #DATA3}</td> 4212 * <td></td> 4213 * </tr> 4214 * </table> 4215 */ 4216 public static final class Website implements DataColumnsWithJoins, CommonColumns { 4217 /** 4218 * This utility class cannot be instantiated 4219 */ 4220 private Website() {} 4221 4222 /** MIME type used when storing this in data table. */ 4223 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; 4224 4225 public static final int TYPE_HOMEPAGE = 1; 4226 public static final int TYPE_BLOG = 2; 4227 public static final int TYPE_PROFILE = 3; 4228 public static final int TYPE_HOME = 4; 4229 public static final int TYPE_WORK = 5; 4230 public static final int TYPE_FTP = 6; 4231 public static final int TYPE_OTHER = 7; 4232 4233 /** 4234 * The website URL string. 4235 * <P>Type: TEXT</P> 4236 */ 4237 public static final String URL = DATA; 4238 } 4239 } 4240 4241 /** 4242 * @see Groups 4243 */ 4244 protected interface GroupsColumns { 4245 /** 4246 * The display title of this group. 4247 * <p> 4248 * Type: TEXT 4249 */ 4250 public static final String TITLE = "title"; 4251 4252 /** 4253 * The package name to use when creating {@link Resources} objects for 4254 * this group. This value is only designed for use when building user 4255 * interfaces, and should not be used to infer the owner. 4256 * 4257 * @hide 4258 */ 4259 public static final String RES_PACKAGE = "res_package"; 4260 4261 /** 4262 * The display title of this group to load as a resource from 4263 * {@link #RES_PACKAGE}, which may be localized. 4264 * <P>Type: TEXT</P> 4265 * 4266 * @hide 4267 */ 4268 public static final String TITLE_RES = "title_res"; 4269 4270 /** 4271 * Notes about the group. 4272 * <p> 4273 * Type: TEXT 4274 */ 4275 public static final String NOTES = "notes"; 4276 4277 /** 4278 * The ID of this group if it is a System Group, i.e. a group that has a special meaning 4279 * to the sync adapter, null otherwise. 4280 * <P>Type: TEXT</P> 4281 */ 4282 public static final String SYSTEM_ID = "system_id"; 4283 4284 /** 4285 * The total number of {@link Contacts} that have 4286 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only 4287 * present when querying {@link Groups#CONTENT_SUMMARY_URI}. 4288 * <p> 4289 * Type: INTEGER 4290 */ 4291 public static final String SUMMARY_COUNT = "summ_count"; 4292 4293 /** 4294 * The total number of {@link Contacts} that have both 4295 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. 4296 * Read-only value that is only present when querying 4297 * {@link Groups#CONTENT_SUMMARY_URI}. 4298 * <p> 4299 * Type: INTEGER 4300 */ 4301 public static final String SUMMARY_WITH_PHONES = "summ_phones"; 4302 4303 /** 4304 * Flag indicating if the contacts belonging to this group should be 4305 * visible in any user interface. 4306 * <p> 4307 * Type: INTEGER (boolean) 4308 */ 4309 public static final String GROUP_VISIBLE = "group_visible"; 4310 4311 /** 4312 * The "deleted" flag: "0" by default, "1" if the row has been marked 4313 * for deletion. When {@link android.content.ContentResolver#delete} is 4314 * called on a group, it is marked for deletion. The sync adaptor 4315 * deletes the group on the server and then calls ContactResolver.delete 4316 * once more, this time setting the the 4317 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to 4318 * finalize the data removal. 4319 * <P>Type: INTEGER</P> 4320 */ 4321 public static final String DELETED = "deleted"; 4322 4323 /** 4324 * Whether this group should be synced if the SYNC_EVERYTHING settings 4325 * is false for this group's account. 4326 * <p> 4327 * Type: INTEGER (boolean) 4328 */ 4329 public static final String SHOULD_SYNC = "should_sync"; 4330 } 4331 4332 /** 4333 * Constants for the groups table. Only per-account groups are supported. 4334 * <h2>Columns</h2> 4335 * <table class="jd-sumtable"> 4336 * <tr> 4337 * <th colspan='4'>Groups</th> 4338 * </tr> 4339 * <tr> 4340 * <td>long</td> 4341 * <td>{@link #_ID}</td> 4342 * <td>read-only</td> 4343 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. 4344 * In other words, it would be a really bad idea to delete and reinsert a 4345 * group. A sync adapter should always do an update instead.</td> 4346 * </tr> 4347 * <tr> 4348 * <td>String</td> 4349 * <td>{@link #TITLE}</td> 4350 * <td>read/write</td> 4351 * <td>The display title of this group.</td> 4352 * </tr> 4353 * <tr> 4354 * <td>String</td> 4355 * <td>{@link #NOTES}</td> 4356 * <td>read/write</td> 4357 * <td>Notes about the group.</td> 4358 * </tr> 4359 * <tr> 4360 * <td>String</td> 4361 * <td>{@link #SYSTEM_ID}</td> 4362 * <td>read/write</td> 4363 * <td>The ID of this group if it is a System Group, i.e. a group that has a 4364 * special meaning to the sync adapter, null otherwise.</td> 4365 * </tr> 4366 * <tr> 4367 * <td>int</td> 4368 * <td>{@link #SUMMARY_COUNT}</td> 4369 * <td>read-only</td> 4370 * <td>The total number of {@link Contacts} that have 4371 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value 4372 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> 4373 * </tr> 4374 * <tr> 4375 * <td>int</td> 4376 * <td>{@link #SUMMARY_WITH_PHONES}</td> 4377 * <td>read-only</td> 4378 * <td>The total number of {@link Contacts} that have both 4379 * {@link CommonDataKinds.GroupMembership} in this group, and also have 4380 * phone numbers. Read-only value that is only present when querying 4381 * {@link Groups#CONTENT_SUMMARY_URI}.</td> 4382 * </tr> 4383 * <tr> 4384 * <td>int</td> 4385 * <td>{@link #GROUP_VISIBLE}</td> 4386 * <td>read-only</td> 4387 * <td>Flag indicating if the contacts belonging to this group should be 4388 * visible in any user interface. Allowed values: 0 and 1.</td> 4389 * </tr> 4390 * <tr> 4391 * <td>int</td> 4392 * <td>{@link #DELETED}</td> 4393 * <td>read/write</td> 4394 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked 4395 * for deletion. When {@link android.content.ContentResolver#delete} is 4396 * called on a group, it is marked for deletion. The sync adaptor deletes 4397 * the group on the server and then calls ContactResolver.delete once more, 4398 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} 4399 * query parameter to finalize the data removal.</td> 4400 * </tr> 4401 * <tr> 4402 * <td>int</td> 4403 * <td>{@link #SHOULD_SYNC}</td> 4404 * <td>read/write</td> 4405 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings 4406 * is false for this group's account.</td> 4407 * </tr> 4408 * </table> 4409 */ 4410 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { 4411 /** 4412 * This utility class cannot be instantiated 4413 */ 4414 private Groups() { 4415 } 4416 4417 /** 4418 * The content:// style URI for this table 4419 */ 4420 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); 4421 4422 /** 4423 * The content:// style URI for this table joined with details data from 4424 * {@link ContactsContract.Data}. 4425 */ 4426 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, 4427 "groups_summary"); 4428 4429 /** 4430 * The MIME type of a directory of groups. 4431 */ 4432 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; 4433 4434 /** 4435 * The MIME type of a single group. 4436 */ 4437 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; 4438 4439 public static EntityIterator newEntityIterator(Cursor cursor) { 4440 return new EntityIteratorImpl(cursor); 4441 } 4442 4443 private static class EntityIteratorImpl extends CursorEntityIterator { 4444 public EntityIteratorImpl(Cursor cursor) { 4445 super(cursor); 4446 } 4447 4448 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { 4449 // we expect the cursor is already at the row we need to read from 4450 final ContentValues values = new ContentValues(); 4451 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); 4452 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); 4453 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); 4454 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); 4455 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); 4456 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); 4457 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); 4458 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); 4459 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); 4460 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); 4461 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); 4462 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); 4463 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); 4464 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); 4465 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); 4466 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); 4467 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); 4468 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); 4469 cursor.moveToNext(); 4470 return new Entity(values); 4471 } 4472 } 4473 } 4474 4475 /** 4476 * <p> 4477 * Constants for the contact aggregation exceptions table, which contains 4478 * aggregation rules overriding those used by automatic aggregation. This 4479 * type only supports query and update. Neither insert nor delete are 4480 * supported. 4481 * </p> 4482 * <h2>Columns</h2> 4483 * <table class="jd-sumtable"> 4484 * <tr> 4485 * <th colspan='4'>AggregationExceptions</th> 4486 * </tr> 4487 * <tr> 4488 * <td>int</td> 4489 * <td>{@link #TYPE}</td> 4490 * <td>read/write</td> 4491 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, 4492 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> 4493 * </tr> 4494 * <tr> 4495 * <td>long</td> 4496 * <td>{@link #RAW_CONTACT_ID1}</td> 4497 * <td>read/write</td> 4498 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that 4499 * the rule applies to.</td> 4500 * </tr> 4501 * <tr> 4502 * <td>long</td> 4503 * <td>{@link #RAW_CONTACT_ID2}</td> 4504 * <td>read/write</td> 4505 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact 4506 * that the rule applies to.</td> 4507 * </tr> 4508 * </table> 4509 */ 4510 public static final class AggregationExceptions implements BaseColumns { 4511 /** 4512 * This utility class cannot be instantiated 4513 */ 4514 private AggregationExceptions() {} 4515 4516 /** 4517 * The content:// style URI for this table 4518 */ 4519 public static final Uri CONTENT_URI = 4520 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); 4521 4522 /** 4523 * The MIME type of {@link #CONTENT_URI} providing a directory of data. 4524 */ 4525 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; 4526 4527 /** 4528 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception 4529 */ 4530 public static final String CONTENT_ITEM_TYPE = 4531 "vnd.android.cursor.item/aggregation_exception"; 4532 4533 /** 4534 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or 4535 * {@link #TYPE_AUTOMATIC}. 4536 * 4537 * <P>Type: INTEGER</P> 4538 */ 4539 public static final String TYPE = "type"; 4540 4541 /** 4542 * Allows the provider to automatically decide whether the specified raw contacts should 4543 * be included in the same aggregate contact or not. 4544 */ 4545 public static final int TYPE_AUTOMATIC = 0; 4546 4547 /** 4548 * Makes sure that the specified raw contacts are included in the same 4549 * aggregate contact. 4550 */ 4551 public static final int TYPE_KEEP_TOGETHER = 1; 4552 4553 /** 4554 * Makes sure that the specified raw contacts are NOT included in the same 4555 * aggregate contact. 4556 */ 4557 public static final int TYPE_KEEP_SEPARATE = 2; 4558 4559 /** 4560 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. 4561 */ 4562 public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; 4563 4564 /** 4565 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule 4566 * applies to. 4567 */ 4568 public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; 4569 } 4570 4571 /** 4572 * @see Settings 4573 */ 4574 protected interface SettingsColumns { 4575 /** 4576 * The name of the account instance to which this row belongs. 4577 * <P>Type: TEXT</P> 4578 */ 4579 public static final String ACCOUNT_NAME = "account_name"; 4580 4581 /** 4582 * The type of account to which this row belongs, which when paired with 4583 * {@link #ACCOUNT_NAME} identifies a specific account. 4584 * <P>Type: TEXT</P> 4585 */ 4586 public static final String ACCOUNT_TYPE = "account_type"; 4587 4588 /** 4589 * Depending on the mode defined by the sync-adapter, this flag controls 4590 * the top-level sync behavior for this data source. 4591 * <p> 4592 * Type: INTEGER (boolean) 4593 */ 4594 public static final String SHOULD_SYNC = "should_sync"; 4595 4596 /** 4597 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} 4598 * entries should be visible in any user interface. 4599 * <p> 4600 * Type: INTEGER (boolean) 4601 */ 4602 public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; 4603 4604 /** 4605 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any 4606 * {@link Groups#SHOULD_SYNC} under this account have been marked as 4607 * unsynced. 4608 */ 4609 public static final String ANY_UNSYNCED = "any_unsynced"; 4610 4611 /** 4612 * Read-only count of {@link Contacts} from a specific source that have 4613 * no {@link CommonDataKinds.GroupMembership} entries. 4614 * <p> 4615 * Type: INTEGER 4616 */ 4617 public static final String UNGROUPED_COUNT = "summ_count"; 4618 4619 /** 4620 * Read-only count of {@link Contacts} from a specific source that have 4621 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. 4622 * <p> 4623 * Type: INTEGER 4624 */ 4625 public static final String UNGROUPED_WITH_PHONES = "summ_phones"; 4626 } 4627 4628 /** 4629 * <p> 4630 * Contacts-specific settings for various {@link Account}'s. 4631 * </p> 4632 * <h2>Columns</h2> 4633 * <table class="jd-sumtable"> 4634 * <tr> 4635 * <th colspan='4'>Settings</th> 4636 * </tr> 4637 * <tr> 4638 * <td>String</td> 4639 * <td>{@link #ACCOUNT_NAME}</td> 4640 * <td>read/write-once</td> 4641 * <td>The name of the account instance to which this row belongs.</td> 4642 * </tr> 4643 * <tr> 4644 * <td>String</td> 4645 * <td>{@link #ACCOUNT_TYPE}</td> 4646 * <td>read/write-once</td> 4647 * <td>The type of account to which this row belongs, which when paired with 4648 * {@link #ACCOUNT_NAME} identifies a specific account.</td> 4649 * </tr> 4650 * <tr> 4651 * <td>int</td> 4652 * <td>{@link #SHOULD_SYNC}</td> 4653 * <td>read/write</td> 4654 * <td>Depending on the mode defined by the sync-adapter, this flag controls 4655 * the top-level sync behavior for this data source.</td> 4656 * </tr> 4657 * <tr> 4658 * <td>int</td> 4659 * <td>{@link #UNGROUPED_VISIBLE}</td> 4660 * <td>read/write</td> 4661 * <td>Flag indicating if contacts without any 4662 * {@link CommonDataKinds.GroupMembership} entries should be visible in any 4663 * user interface.</td> 4664 * </tr> 4665 * <tr> 4666 * <td>int</td> 4667 * <td>{@link #ANY_UNSYNCED}</td> 4668 * <td>read-only</td> 4669 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any 4670 * {@link Groups#SHOULD_SYNC} under this account have been marked as 4671 * unsynced.</td> 4672 * </tr> 4673 * <tr> 4674 * <td>int</td> 4675 * <td>{@link #UNGROUPED_COUNT}</td> 4676 * <td>read-only</td> 4677 * <td>Read-only count of {@link Contacts} from a specific source that have 4678 * no {@link CommonDataKinds.GroupMembership} entries.</td> 4679 * </tr> 4680 * <tr> 4681 * <td>int</td> 4682 * <td>{@link #UNGROUPED_WITH_PHONES}</td> 4683 * <td>read-only</td> 4684 * <td>Read-only count of {@link Contacts} from a specific source that have 4685 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone 4686 * numbers.</td> 4687 * </tr> 4688 * </table> 4689 */ 4690 4691 public static final class Settings implements SettingsColumns { 4692 /** 4693 * This utility class cannot be instantiated 4694 */ 4695 private Settings() { 4696 } 4697 4698 /** 4699 * The content:// style URI for this table 4700 */ 4701 public static final Uri CONTENT_URI = 4702 Uri.withAppendedPath(AUTHORITY_URI, "settings"); 4703 4704 /** 4705 * The MIME-type of {@link #CONTENT_URI} providing a directory of 4706 * settings. 4707 */ 4708 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; 4709 4710 /** 4711 * The MIME-type of {@link #CONTENT_URI} providing a single setting. 4712 */ 4713 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; 4714 } 4715 4716 /** 4717 * Helper methods to display QuickContact dialogs that allow users to pivot on 4718 * a specific {@link Contacts} entry. 4719 */ 4720 public static final class QuickContact { 4721 /** 4722 * Action used to trigger person pivot dialog. 4723 * @hide 4724 */ 4725 public static final String ACTION_QUICK_CONTACT = 4726 "com.android.contacts.action.QUICK_CONTACT"; 4727 4728 /** 4729 * Extra used to specify pivot dialog location in screen coordinates. 4730 * @hide 4731 */ 4732 public static final String EXTRA_TARGET_RECT = "target_rect"; 4733 4734 /** 4735 * Extra used to specify size of pivot dialog. 4736 * @hide 4737 */ 4738 public static final String EXTRA_MODE = "mode"; 4739 4740 /** 4741 * Extra used to indicate a list of specific MIME-types to exclude and 4742 * not display. Stored as a {@link String} array. 4743 * @hide 4744 */ 4745 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; 4746 4747 /** 4748 * Small QuickContact mode, usually presented with minimal actions. 4749 */ 4750 public static final int MODE_SMALL = 1; 4751 4752 /** 4753 * Medium QuickContact mode, includes actions and light summary describing 4754 * the {@link Contacts} entry being shown. This may include social 4755 * status and presence details. 4756 */ 4757 public static final int MODE_MEDIUM = 2; 4758 4759 /** 4760 * Large QuickContact mode, includes actions and larger, card-like summary 4761 * of the {@link Contacts} entry being shown. This may include detailed 4762 * information, such as a photo. 4763 */ 4764 public static final int MODE_LARGE = 3; 4765 4766 /** 4767 * Trigger a dialog that lists the various methods of interacting with 4768 * the requested {@link Contacts} entry. This may be based on available 4769 * {@link ContactsContract.Data} rows under that contact, and may also 4770 * include social status and presence details. 4771 * 4772 * @param context The parent {@link Context} that may be used as the 4773 * parent for this dialog. 4774 * @param target Specific {@link View} from your layout that this dialog 4775 * should be centered around. In particular, if the dialog 4776 * has a "callout" arrow, it will be pointed and centered 4777 * around this {@link View}. 4778 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 4779 * {@link Uri} that describes a specific contact to feature 4780 * in this dialog. 4781 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 4782 * {@link #MODE_LARGE}, indicating the desired dialog size, 4783 * when supported. 4784 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 4785 * to exclude when showing this dialog. For example, when 4786 * already viewing the contact details card, this can be used 4787 * to omit the details entry from the dialog. 4788 */ 4789 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, 4790 String[] excludeMimes) { 4791 // Find location and bounds of target view 4792 final int[] location = new int[2]; 4793 target.getLocationOnScreen(location); 4794 4795 final Rect rect = new Rect(); 4796 rect.left = location[0]; 4797 rect.top = location[1]; 4798 rect.right = rect.left + target.getWidth(); 4799 rect.bottom = rect.top + target.getHeight(); 4800 4801 // Trigger with obtained rectangle 4802 showQuickContact(context, rect, lookupUri, mode, excludeMimes); 4803 } 4804 4805 /** 4806 * Trigger a dialog that lists the various methods of interacting with 4807 * the requested {@link Contacts} entry. This may be based on available 4808 * {@link ContactsContract.Data} rows under that contact, and may also 4809 * include social status and presence details. 4810 * 4811 * @param context The parent {@link Context} that may be used as the 4812 * parent for this dialog. 4813 * @param target Specific {@link Rect} that this dialog should be 4814 * centered around, in screen coordinates. In particular, if 4815 * the dialog has a "callout" arrow, it will be pointed and 4816 * centered around this {@link Rect}. 4817 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style 4818 * {@link Uri} that describes a specific contact to feature 4819 * in this dialog. 4820 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or 4821 * {@link #MODE_LARGE}, indicating the desired dialog size, 4822 * when supported. 4823 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types 4824 * to exclude when showing this dialog. For example, when 4825 * already viewing the contact details card, this can be used 4826 * to omit the details entry from the dialog. 4827 */ 4828 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, 4829 String[] excludeMimes) { 4830 // Launch pivot dialog through intent for now 4831 final Intent intent = new Intent(ACTION_QUICK_CONTACT); 4832 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP 4833 | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 4834 4835 intent.setData(lookupUri); 4836 intent.putExtra(EXTRA_TARGET_RECT, target); 4837 intent.putExtra(EXTRA_MODE, mode); 4838 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); 4839 context.startActivity(intent); 4840 } 4841 } 4842 4843 /** 4844 * Contains helper classes used to create or manage {@link android.content.Intent Intents} 4845 * that involve contacts. 4846 */ 4847 public static final class Intents { 4848 /** 4849 * This is the intent that is fired when a search suggestion is clicked on. 4850 */ 4851 public static final String SEARCH_SUGGESTION_CLICKED = 4852 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; 4853 4854 /** 4855 * This is the intent that is fired when a search suggestion for dialing a number 4856 * is clicked on. 4857 */ 4858 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = 4859 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; 4860 4861 /** 4862 * This is the intent that is fired when a search suggestion for creating a contact 4863 * is clicked on. 4864 */ 4865 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = 4866 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; 4867 4868 /** 4869 * Starts an Activity that lets the user pick a contact to attach an image to. 4870 * After picking the contact it launches the image cropper in face detection mode. 4871 */ 4872 public static final String ATTACH_IMAGE = 4873 "com.android.contacts.action.ATTACH_IMAGE"; 4874 4875 /** 4876 * Takes as input a data URI with a mailto: or tel: scheme. If a single 4877 * contact exists with the given data it will be shown. If no contact 4878 * exists, a dialog will ask the user if they want to create a new 4879 * contact with the provided details filled in. If multiple contacts 4880 * share the data the user will be prompted to pick which contact they 4881 * want to view. 4882 * <p> 4883 * For <code>mailto:</code> URIs, the scheme specific portion must be a 4884 * raw email address, such as one built using 4885 * {@link Uri#fromParts(String, String, String)}. 4886 * <p> 4887 * For <code>tel:</code> URIs, the scheme specific portion is compared 4888 * to existing numbers using the standard caller ID lookup algorithm. 4889 * The number must be properly encoded, for example using 4890 * {@link Uri#fromParts(String, String, String)}. 4891 * <p> 4892 * Any extras from the {@link Insert} class will be passed along to the 4893 * create activity if there are no contacts to show. 4894 * <p> 4895 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip 4896 * prompting the user when the contact doesn't exist. 4897 */ 4898 public static final String SHOW_OR_CREATE_CONTACT = 4899 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; 4900 4901 /** 4902 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new 4903 * contact if no matching contact found. Otherwise, default behavior is 4904 * to prompt user with dialog before creating. 4905 * <p> 4906 * Type: BOOLEAN 4907 */ 4908 public static final String EXTRA_FORCE_CREATE = 4909 "com.android.contacts.action.FORCE_CREATE"; 4910 4911 /** 4912 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact 4913 * description to be shown when prompting user about creating a new 4914 * contact. 4915 * <p> 4916 * Type: STRING 4917 */ 4918 public static final String EXTRA_CREATE_DESCRIPTION = 4919 "com.android.contacts.action.CREATE_DESCRIPTION"; 4920 4921 /** 4922 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 4923 * dialog location using screen coordinates. When not specified, the 4924 * dialog will be centered. 4925 * 4926 * @hide 4927 */ 4928 @Deprecated 4929 public static final String EXTRA_TARGET_RECT = "target_rect"; 4930 4931 /** 4932 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a 4933 * desired dialog style, usually a variation on size. One of 4934 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. 4935 * 4936 * @hide 4937 */ 4938 @Deprecated 4939 public static final String EXTRA_MODE = "mode"; 4940 4941 /** 4942 * Value for {@link #EXTRA_MODE} to show a small-sized dialog. 4943 * 4944 * @hide 4945 */ 4946 @Deprecated 4947 public static final int MODE_SMALL = 1; 4948 4949 /** 4950 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. 4951 * 4952 * @hide 4953 */ 4954 @Deprecated 4955 public static final int MODE_MEDIUM = 2; 4956 4957 /** 4958 * Value for {@link #EXTRA_MODE} to show a large-sized dialog. 4959 * 4960 * @hide 4961 */ 4962 @Deprecated 4963 public static final int MODE_LARGE = 3; 4964 4965 /** 4966 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate 4967 * a list of specific MIME-types to exclude and not display. Stored as a 4968 * {@link String} array. 4969 * 4970 * @hide 4971 */ 4972 @Deprecated 4973 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; 4974 4975 /** 4976 * Intents related to the Contacts app UI. 4977 * 4978 * @hide 4979 */ 4980 public static final class UI { 4981 /** 4982 * The action for the default contacts list tab. 4983 */ 4984 public static final String LIST_DEFAULT = 4985 "com.android.contacts.action.LIST_DEFAULT"; 4986 4987 /** 4988 * The action for the contacts list tab. 4989 */ 4990 public static final String LIST_GROUP_ACTION = 4991 "com.android.contacts.action.LIST_GROUP"; 4992 4993 /** 4994 * When in LIST_GROUP_ACTION mode, this is the group to display. 4995 */ 4996 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; 4997 4998 /** 4999 * The action for the all contacts list tab. 5000 */ 5001 public static final String LIST_ALL_CONTACTS_ACTION = 5002 "com.android.contacts.action.LIST_ALL_CONTACTS"; 5003 5004 /** 5005 * The action for the contacts with phone numbers list tab. 5006 */ 5007 public static final String LIST_CONTACTS_WITH_PHONES_ACTION = 5008 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; 5009 5010 /** 5011 * The action for the starred contacts list tab. 5012 */ 5013 public static final String LIST_STARRED_ACTION = 5014 "com.android.contacts.action.LIST_STARRED"; 5015 5016 /** 5017 * The action for the frequent contacts list tab. 5018 */ 5019 public static final String LIST_FREQUENT_ACTION = 5020 "com.android.contacts.action.LIST_FREQUENT"; 5021 5022 /** 5023 * The action for the "strequent" contacts list tab. It first lists the starred 5024 * contacts in alphabetical order and then the frequent contacts in descending 5025 * order of the number of times they have been contacted. 5026 */ 5027 public static final String LIST_STREQUENT_ACTION = 5028 "com.android.contacts.action.LIST_STREQUENT"; 5029 5030 /** 5031 * A key for to be used as an intent extra to set the activity 5032 * title to a custom String value. 5033 */ 5034 public static final String TITLE_EXTRA_KEY = 5035 "com.android.contacts.extra.TITLE_EXTRA"; 5036 5037 /** 5038 * Activity Action: Display a filtered list of contacts 5039 * <p> 5040 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for 5041 * filtering 5042 * <p> 5043 * Output: Nothing. 5044 */ 5045 public static final String FILTER_CONTACTS_ACTION = 5046 "com.android.contacts.action.FILTER_CONTACTS"; 5047 5048 /** 5049 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} 5050 * intents to supply the text on which to filter. 5051 */ 5052 public static final String FILTER_TEXT_EXTRA_KEY = 5053 "com.android.contacts.extra.FILTER_TEXT"; 5054 } 5055 5056 /** 5057 * Convenience class that contains string constants used 5058 * to create contact {@link android.content.Intent Intents}. 5059 */ 5060 public static final class Insert { 5061 /** The action code to use when adding a contact */ 5062 public static final String ACTION = Intent.ACTION_INSERT; 5063 5064 /** 5065 * If present, forces a bypass of quick insert mode. 5066 */ 5067 public static final String FULL_MODE = "full_mode"; 5068 5069 /** 5070 * The extra field for the contact name. 5071 * <P>Type: String</P> 5072 */ 5073 public static final String NAME = "name"; 5074 5075 // TODO add structured name values here. 5076 5077 /** 5078 * The extra field for the contact phonetic name. 5079 * <P>Type: String</P> 5080 */ 5081 public static final String PHONETIC_NAME = "phonetic_name"; 5082 5083 /** 5084 * The extra field for the contact company. 5085 * <P>Type: String</P> 5086 */ 5087 public static final String COMPANY = "company"; 5088 5089 /** 5090 * The extra field for the contact job title. 5091 * <P>Type: String</P> 5092 */ 5093 public static final String JOB_TITLE = "job_title"; 5094 5095 /** 5096 * The extra field for the contact notes. 5097 * <P>Type: String</P> 5098 */ 5099 public static final String NOTES = "notes"; 5100 5101 /** 5102 * The extra field for the contact phone number. 5103 * <P>Type: String</P> 5104 */ 5105 public static final String PHONE = "phone"; 5106 5107 /** 5108 * The extra field for the contact phone number type. 5109 * <P>Type: Either an integer value from 5110 * {@link CommonDataKinds.Phone}, 5111 * or a string specifying a custom label.</P> 5112 */ 5113 public static final String PHONE_TYPE = "phone_type"; 5114 5115 /** 5116 * The extra field for the phone isprimary flag. 5117 * <P>Type: boolean</P> 5118 */ 5119 public static final String PHONE_ISPRIMARY = "phone_isprimary"; 5120 5121 /** 5122 * The extra field for an optional second contact phone number. 5123 * <P>Type: String</P> 5124 */ 5125 public static final String SECONDARY_PHONE = "secondary_phone"; 5126 5127 /** 5128 * The extra field for an optional second contact phone number type. 5129 * <P>Type: Either an integer value from 5130 * {@link CommonDataKinds.Phone}, 5131 * or a string specifying a custom label.</P> 5132 */ 5133 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; 5134 5135 /** 5136 * The extra field for an optional third contact phone number. 5137 * <P>Type: String</P> 5138 */ 5139 public static final String TERTIARY_PHONE = "tertiary_phone"; 5140 5141 /** 5142 * The extra field for an optional third contact phone number type. 5143 * <P>Type: Either an integer value from 5144 * {@link CommonDataKinds.Phone}, 5145 * or a string specifying a custom label.</P> 5146 */ 5147 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; 5148 5149 /** 5150 * The extra field for the contact email address. 5151 * <P>Type: String</P> 5152 */ 5153 public static final String EMAIL = "email"; 5154 5155 /** 5156 * The extra field for the contact email type. 5157 * <P>Type: Either an integer value from 5158 * {@link CommonDataKinds.Email} 5159 * or a string specifying a custom label.</P> 5160 */ 5161 public static final String EMAIL_TYPE = "email_type"; 5162 5163 /** 5164 * The extra field for the email isprimary flag. 5165 * <P>Type: boolean</P> 5166 */ 5167 public static final String EMAIL_ISPRIMARY = "email_isprimary"; 5168 5169 /** 5170 * The extra field for an optional second contact email address. 5171 * <P>Type: String</P> 5172 */ 5173 public static final String SECONDARY_EMAIL = "secondary_email"; 5174 5175 /** 5176 * The extra field for an optional second contact email type. 5177 * <P>Type: Either an integer value from 5178 * {@link CommonDataKinds.Email} 5179 * or a string specifying a custom label.</P> 5180 */ 5181 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; 5182 5183 /** 5184 * The extra field for an optional third contact email address. 5185 * <P>Type: String</P> 5186 */ 5187 public static final String TERTIARY_EMAIL = "tertiary_email"; 5188 5189 /** 5190 * The extra field for an optional third contact email type. 5191 * <P>Type: Either an integer value from 5192 * {@link CommonDataKinds.Email} 5193 * or a string specifying a custom label.</P> 5194 */ 5195 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; 5196 5197 /** 5198 * The extra field for the contact postal address. 5199 * <P>Type: String</P> 5200 */ 5201 public static final String POSTAL = "postal"; 5202 5203 /** 5204 * The extra field for the contact postal address type. 5205 * <P>Type: Either an integer value from 5206 * {@link CommonDataKinds.StructuredPostal} 5207 * or a string specifying a custom label.</P> 5208 */ 5209 public static final String POSTAL_TYPE = "postal_type"; 5210 5211 /** 5212 * The extra field for the postal isprimary flag. 5213 * <P>Type: boolean</P> 5214 */ 5215 public static final String POSTAL_ISPRIMARY = "postal_isprimary"; 5216 5217 /** 5218 * The extra field for an IM handle. 5219 * <P>Type: String</P> 5220 */ 5221 public static final String IM_HANDLE = "im_handle"; 5222 5223 /** 5224 * The extra field for the IM protocol 5225 */ 5226 public static final String IM_PROTOCOL = "im_protocol"; 5227 5228 /** 5229 * The extra field for the IM isprimary flag. 5230 * <P>Type: boolean</P> 5231 */ 5232 public static final String IM_ISPRIMARY = "im_isprimary"; 5233 } 5234 } 5235 5236} 5237