blob: 48d53457248507714c94db73c55d0aecde715e57 [file] [log] [blame]
Evan Millar088b2912009-05-28 15:24:37 -07001/*
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
Jeff Sharkey7b6771a2009-08-17 01:59:54 -070019import android.accounts.Account;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070020import android.content.ContentProviderClient;
21import android.content.ContentProviderOperation;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070022import android.content.ContentResolver;
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -070023import android.content.ContentUris;
Jeff Hamilton85abdc52009-09-22 12:41:45 -050024import android.content.ContentValues;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070025import android.content.Context;
Fred Quintana328c0e72009-12-07 14:52:28 -080026import android.content.CursorEntityIterator;
Fred Quintana328c0e72009-12-07 14:52:28 -080027import android.content.Entity;
Tom O'Neill244327e22010-01-08 11:11:15 -080028import android.content.EntityIterator;
29import android.content.Intent;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -070030import android.content.res.Resources;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070031import android.database.Cursor;
Fred Quintana328c0e72009-12-07 14:52:28 -080032import android.database.DatabaseUtils;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070033import android.graphics.Rect;
Evan Millar088b2912009-05-28 15:24:37 -070034import android.net.Uri;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070035import android.os.RemoteException;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070036import android.text.TextUtils;
Jeff Sharkeya503f6f2009-12-08 21:50:14 -080037import android.util.DisplayMetrics;
Fred Quintanac4516a72009-09-03 12:14:06 -070038import android.util.Pair;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070039import android.view.View;
Evan Millar088b2912009-05-28 15:24:37 -070040
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070041import java.io.ByteArrayInputStream;
42import java.io.InputStream;
43
Evan Millar088b2912009-05-28 15:24:37 -070044/**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080045 * <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>
Dirk Dougherty4e7db252010-01-05 17:03:39 -080055 * <ul>
56 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080057 * A row in the {@link Data} table can store any kind of personal data, such
58 * as a phone number or email addresses. The set of data kinds that can be
59 * stored in this table is open-ended. There is a predefined set of common
60 * kinds, but any application can add its own data kinds.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080061 * </li>
62 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080063 * A row in the {@link RawContacts} table represents a set of data describing a
64 * person and associated with a single account (for example, one of the user's
65 * Gmail accounts).
Dirk Dougherty4e7db252010-01-05 17:03:39 -080066 * </li>
67 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080068 * A row in the {@link Contacts} table represents an aggregate of one or more
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080069 * RawContacts presumably describing the same person. When data in or associated with
70 * the RawContacts table is changed, the affected aggregate contacts are updated as
71 * necessary.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080072 * </li>
73 * </ul>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080074 * <p>
75 * Other tables include:
76 * </p>
Dirk Dougherty4e7db252010-01-05 17:03:39 -080077 * <ul>
78 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080079 * {@link Groups}, which contains information about raw contact groups
80 * such as Gmail contact groups. The
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080081 * current API does not support the notion of groups spanning multiple accounts.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080082 * </li>
83 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080084 * {@link StatusUpdates}, which contains social status updates including IM
85 * availability.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080086 * </li>
87 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080088 * {@link AggregationExceptions}, which is used for manual aggregation and
89 * disaggregation of raw contacts
Dirk Dougherty4e7db252010-01-05 17:03:39 -080090 * </li>
91 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080092 * {@link Settings}, which contains visibility and sync settings for accounts
93 * and groups.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080094 * </li>
95 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080096 * {@link SyncState}, which contains free-form data maintained on behalf of sync
97 * adapters
Dirk Dougherty4e7db252010-01-05 17:03:39 -080098 * </li>
99 * <li>
100 * {@link PhoneLookup}, which is used for quick caller-ID lookup</li>
101 * </ul>
Evan Millar088b2912009-05-28 15:24:37 -0700102 */
Jeff Hamilton0c232122009-09-24 00:26:50 -0500103@SuppressWarnings("unused")
Evan Millar088b2912009-05-28 15:24:37 -0700104public final class ContactsContract {
105 /** The authority for the contacts provider */
106 public static final String AUTHORITY = "com.android.contacts";
107 /** A content:// style uri to the authority for the contacts provider */
108 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
109
Fred Quintana33f889a2009-09-14 17:31:26 -0700110 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800111 * An optional URI parameter for insert, update, or delete queries
112 * that allows the caller
Fred Quintana33f889a2009-09-14 17:31:26 -0700113 * to specify that it is a sync adapter. The default value is false. If true
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800114 * {@link RawContacts#DIRTY} is not automatically set and the
115 * "syncToNetwork" parameter is set to false when calling
116 * {@link
117 * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
118 * This prevents an unnecessary extra synchronization, see the discussion of
119 * the delete operation in {@link RawContacts}.
Fred Quintana33f889a2009-09-14 17:31:26 -0700120 */
121 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
122
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500123 /**
Evan Millar49da15f2009-09-29 12:02:56 -0700124 * A query parameter key used to specify the package that is requesting a query.
125 * This is used for restricting data based on package name.
126 *
127 * @hide
128 */
129 public static final String REQUESTING_PACKAGE_PARAM_KEY = "requesting_package";
130
131 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700132 * Query parameter that should be used by the client to access a specific
133 * {@link Directory}. The parameter value should be the _ID of the corresponding
134 * directory, e.g.
135 * {@code content://com.android.contacts/data/emails/filter/acme?directory=3}
136 *
137 * @hide
138 */
139 public static final String DIRECTORY_PARAM_KEY = "directory";
140
141
142 /**
Dmitri Plotnikov2a650dd2010-01-26 17:28:52 -0800143 * @hide
144 */
145 public static final class Preferences {
146
147 /**
148 * A key in the {@link android.provider.Settings android.provider.Settings} provider
149 * that stores the preferred sorting order for contacts (by given name vs. by family name).
150 *
151 * @hide
152 */
153 public static final String SORT_ORDER = "android.contacts.SORT_ORDER";
154
155 /**
156 * The value for the SORT_ORDER key corresponding to sorting by given name first.
157 *
158 * @hide
159 */
160 public static final int SORT_ORDER_PRIMARY = 1;
161
162 /**
163 * The value for the SORT_ORDER key corresponding to sorting by family name first.
164 *
165 * @hide
166 */
167 public static final int SORT_ORDER_ALTERNATIVE = 2;
168
169 /**
170 * A key in the {@link android.provider.Settings android.provider.Settings} provider
171 * that stores the preferred display order for contacts (given name first vs. family
172 * name first).
173 *
174 * @hide
175 */
176 public static final String DISPLAY_ORDER = "android.contacts.DISPLAY_ORDER";
177
178 /**
179 * The value for the DISPLAY_ORDER key corresponding to showing the given name first.
180 *
181 * @hide
182 */
183 public static final int DISPLAY_ORDER_PRIMARY = 1;
184
185 /**
186 * The value for the DISPLAY_ORDER key corresponding to showing the family name first.
187 *
188 * @hide
189 */
190 public static final int DISPLAY_ORDER_ALTERNATIVE = 2;
191 }
192
193 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700194 * A Directory represents a contacts corpus, e.g. Local contacts,
195 * Google Apps Global Address List or Corporate Global Address List.
196 * <p>
197 * A Directory is implemented as a content provider with its unique authority and
198 * the same API as the main Contacts Provider. However, there is no expectation that
199 * every directory provider will implement this Contract in its entirety. If a
200 * directory provider does not have an implementation for a specific request, it
201 * should throw an UnsupportedOperationException.
202 * </p>
203 * <p>
204 * The most important use case for Directories is search. A Directory provider is
205 * expected to support at least {@link Contacts#CONTENT_FILTER_URI
206 * Contacts#CONTENT_FILTER_URI}. If a Directory provider wants to participate
207 * in email and phone lookup functionalities, it should also implement
208 * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI}
209 * and
210 * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}.
211 * </p>
212 * <p>
213 * A directory provider should return NULL for every projection field it does not
214 * recognize, rather than throwing an exception. This way it will not be broken
215 * if ContactsContract is extended with new fields in the future.
216 * </p>
217 * <p>
218 * The client interacts with a directory via Contacts Provider by supplying an
219 * optional {@code directory=} query parameter.
220 * <p>
221 * <p>
222 * When the Contacts Provider receives the request, it transforms the URI and forwards
223 * the request to the corresponding directory content provider.
224 * The URI is transformed in the following fashion:
225 * <ul>
226 * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li>
227 * <li>The {@code accountName=} and {@code accountType=} parameters are added or
228 * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li>
229 * <li>If the URI is missing a {@link ContactsContract#REQUESTING_PACKAGE_PARAM_KEY}
230 * parameter, this parameter is added.</li>
231 * </ul>
232 * </p>
233 * <p>
234 * Clients should send directory requests to Contacts Provider and let it
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700235 * forward them to the respective providers rather than constructing
236 * directory provider URIs by themselves. This level of indirection allows
237 * Contacts Provider to implement additional system-level features and
238 * optimizations. Access to Contacts Provider is protected by the
239 * READ_CONTACTS permission, but access to the directory provider is not.
240 * Therefore directory providers must reject requests coming from clients
241 * other than the Contacts Provider itself. An easy way to prevent such
242 * unauthorized access is to check the name of the calling package:
243 * <pre>
244 * private boolean isCallerAllowed() {
245 * PackageManager pm = getContext().getPackageManager();
246 * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) {
247 * if (packageName.equals("com.android.providers.contacts")) {
248 * return true;
249 * }
250 * }
251 * return false;
252 * }
253 * </pre>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700254 * </p>
255 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700256 * The Directory table is read-only and is maintained by the Contacts Provider
257 * automatically.
258 * </p>
259 * <p>It always has at least these two rows:
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700260 * <ul>
261 * <li>
262 * The local directory. It has {@link Directory#_ID Directory._ID} =
263 * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally
264 * stored contacts. The same can be achieved by omitting the {@code directory=}
265 * parameter altogether.
266 * </li>
267 * <li>
268 * The local invisible contacts. The corresponding directory ID is
269 * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}.
270 * </li>
271 * </ul>
272 * </p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700273 * <p>Custom Directories are discovered by the Contacts Provider following this procedure:
274 * <ul>
275 * <li>It finds all installed content providers with meta data identifying them
276 * as directory providers in AndroidManifest.xml:
277 * <code>
278 * &lt;meta-data android:name="android.content.ContactDirectory"
279 * android:value="true" /&gt;
280 * </code>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700281 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700282 * This tag should be placed inside the corresponding content provider declaration.
283 * </p>
284 * </li>
285 * <li>
286 * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI}
287 * query to each of the directory authorities. A directory provider must implement
288 * this query and return a list of directories. Each directory returned by
289 * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and
290 * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned
291 * automatically, the _ID field will not be part of the query projection.
292 * </li>
293 * <li>Contacts Provider compiles directory lists received from all directory
294 * providers into one, assigns each individual directory a globally unique ID and
295 * stores all directory records in the Directory table.
296 * </li>
297 * </ul>
298 * </p>
299 * <p>Contacts Provider automatically interrogates newly installed or replaced packages.
300 * Thus simply installing a package containing a directory provider is sufficient
301 * to have that provider registered. A package supplying a directory provider does
302 * not have to contain launchable activities.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700303 * </p>
304 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700305 * Every row in the Directory table is automatically associated with the corresponding package
306 * (apk). If the package is later uninstalled, all corresponding directory rows
307 * are automatically removed from the Contacts Provider.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700308 * </p>
309 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700310 * When the list of directories handled by a directory provider changes
311 * (for instance when the user adds a new Directory account), the directory provider
312 * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change.
313 * In response, the Contacts Provider will requery the directory provider to obtain the
314 * new list of directories.
315 * </p>
316 * <p>
317 * A directory row can be optionally associated with an existing account
318 * (see {@link android.accounts.AccountManager}). If the account is later removed,
319 * the corresponding directory rows are
320 * automatically removed from the Contacts Provider.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700321 * </p>
322 *
323 * @hide
324 */
325 public static final class Directory implements BaseColumns {
326
327 /**
328 * Not instantiable.
329 */
330 private Directory() {
331 }
332
333 /**
334 * The content:// style URI for this table. Requests to this URI can be
335 * performed on the UI thread because they are always unblocking.
336 *
337 * @hide
338 */
339 public static final Uri CONTENT_URI =
340 Uri.withAppendedPath(AUTHORITY_URI, "directories");
341
342 /**
343 * The MIME-type of {@link #CONTENT_URI} providing a directory of
344 * contact directories.
345 *
346 * @hide
347 */
348 public static final String CONTENT_TYPE =
349 "vnd.android.cursor.dir/contact_directories";
350
351 /**
352 * The MIME type of a {@link #CONTENT_URI} item.
353 */
354 public static final String CONTENT_ITEM_TYPE =
355 "vnd.android.cursor.item/contact_directory";
356
357 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700358 * _ID of the default directory, which represents locally stored contacts.
359 *
360 * @hide
361 */
362 public static final long DEFAULT = 0;
363
364 /**
365 * _ID of the directory that represents locally stored invisible contacts.
366 *
367 * @hide
368 */
369 public static final long LOCAL_INVISIBLE = 1;
370
371 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700372 * The name of the package that owns this directory. Contacts Provider
373 * fill it in with the name of the package containing the directory provider.
374 * If the package is later uninstalled, the directories it owns are
375 * automatically removed from this table.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700376 *
377 * <p>TYPE: TEXT</p>
378 *
379 * @hide
380 */
381 public static final String PACKAGE_NAME = "packageName";
382
383 /**
384 * The type of directory captured as a resource ID in the context of the
385 * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory"
386 *
387 * <p>TYPE: INTEGER</p>
388 *
389 * @hide
390 */
391 public static final String TYPE_RESOURCE_ID = "typeResourceId";
392
393 /**
394 * An optional name that can be used in the UI to represent this directory,
395 * e.g. "Acme Corp"
396 * <p>TYPE: text</p>
397 *
398 * @hide
399 */
400 public static final String DISPLAY_NAME = "displayName";
401
402 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700403 * <p>
404 * The authority of the Directory Provider. Contacts Provider will
405 * use this authority to forward requests to the directory provider.
406 * A directory provider can leave this column empty - Contacts Provider will fill it in.
407 * </p>
408 * <p>
409 * Clients of this API should not send requests directly to this authority.
410 * All directory requests must be routed through Contacts Provider.
411 * </p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700412 *
413 * <p>TYPE: text</p>
414 *
415 * @hide
416 */
417 public static final String DIRECTORY_AUTHORITY = "authority";
418
419 /**
420 * The account type which this directory is associated.
421 *
422 * <p>TYPE: text</p>
423 *
424 * @hide
425 */
426 public static final String ACCOUNT_TYPE = "accountType";
427
428 /**
429 * The account with which this directory is associated. If the account is later
430 * removed, the directories it owns are automatically removed from this table.
431 *
432 * <p>TYPE: text</p>
433 *
434 * @hide
435 */
436 public static final String ACCOUNT_NAME = "accountName";
437
438 /**
439 * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT},
440 * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the
441 * directory has for data exported from it. Clients must obey this setting.
442 *
443 * @hide
444 */
445 public static final String EXPORT_SUPPORT = "exportSupport";
446
447 /**
448 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
449 * does not allow any data to be copied out of it.
450 *
451 * @hide
452 */
453 public static final int EXPORT_SUPPORT_NONE = 0;
454
455 /**
456 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
457 * allow its data copied only to the account specified by
458 * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}.
459 *
460 * @hide
461 */
462 public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1;
463
464 /**
465 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
466 * allow its data copied to any contacts account.
467 *
468 * @hide
469 */
470 public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2;
471
472 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700473 * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY},
474 * {@link #SHORTCUT_SUPPORT_FULL}, This is the expectation the directory
475 * has for shortcuts created for its elements. Clients must obey this setting.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700476 *
477 * @hide
478 */
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700479 public static final String SHORTCUT_SUPPORT = "shortcutSupport";
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700480
481 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700482 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
483 * does not allow any shortcuts created for its contacts.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700484 *
485 * @hide
486 */
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700487 public static final int SHORTCUT_SUPPORT_NONE = 0;
488
489 /**
490 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
491 * allow creation of shortcuts for data items like email, phone or postal address,
492 * but not the entire contact.
493 *
494 * @hide
495 */
496 public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1;
497
498 /**
499 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
500 * allow creation of shortcuts for contact as well as their constituent elements.
501 *
502 * @hide
503 */
504 public static final int SHORTCUT_SUPPORT_FULL = 2;
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700505
506 /**
507 * Notifies the system of a change in the list of directories handled by
508 * a particular directory provider. The Contacts provider will turn around
509 * and send a query to the directory provider for the full list of directories,
510 * which will replace the previous list.
511 *
512 * @hide
513 */
514 public static void notifyDirectoryChange(ContentResolver resolver) {
515 // This is done to trigger a query by Contacts Provider back to the directory provider.
516 // No data needs to be sent back, because the provider can infer the calling
517 // package from binder.
518 ContentValues contentValues = new ContentValues();
519 resolver.update(Directory.CONTENT_URI, contentValues, null, null);
520 }
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700521 }
522
523 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500524 * @hide should be removed when users are updated to refer to SyncState
525 * @deprecated use SyncState instead
526 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700527 @Deprecated
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700528 public interface SyncStateColumns extends SyncStateContract.Columns {
529 }
530
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500531 /**
532 * A table provided for sync adapters to use for storing private sync state data.
533 *
534 * @see SyncStateContract
535 */
536 public static final class SyncState implements SyncStateContract.Columns {
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700537 /**
538 * This utility class cannot be instantiated
539 */
540 private SyncState() {}
541
542 public static final String CONTENT_DIRECTORY =
543 SyncStateContract.Constants.CONTENT_DIRECTORY;
544
545 /**
546 * The content:// style URI for this table
547 */
548 public static final Uri CONTENT_URI =
549 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
550
551 /**
552 * @see android.provider.SyncStateContract.Helpers#get
553 */
554 public static byte[] get(ContentProviderClient provider, Account account)
555 throws RemoteException {
556 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
557 }
558
559 /**
Fred Quintanac4516a72009-09-03 12:14:06 -0700560 * @see android.provider.SyncStateContract.Helpers#get
561 */
562 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
563 throws RemoteException {
564 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
565 }
566
567 /**
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700568 * @see android.provider.SyncStateContract.Helpers#set
569 */
570 public static void set(ContentProviderClient provider, Account account, byte[] data)
571 throws RemoteException {
572 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
573 }
574
575 /**
576 * @see android.provider.SyncStateContract.Helpers#newSetOperation
577 */
578 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
579 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
580 }
581 }
582
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700583 /**
584 * Generic columns for use by sync adapters. The specific functions of
585 * these columns are private to the sync adapter. Other clients of the API
586 * should not attempt to either read or write this column.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800587 *
588 * @see RawContacts
589 * @see Groups
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700590 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700591 protected interface BaseSyncColumns {
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700592
593 /** Generic column for use by sync adapters. */
594 public static final String SYNC1 = "sync1";
595 /** Generic column for use by sync adapters. */
596 public static final String SYNC2 = "sync2";
597 /** Generic column for use by sync adapters. */
598 public static final String SYNC3 = "sync3";
599 /** Generic column for use by sync adapters. */
600 public static final String SYNC4 = "sync4";
601 }
602
603 /**
604 * Columns that appear when each row of a table belongs to a specific
605 * account, including sync information that an account may need.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800606 *
607 * @see RawContacts
608 * @see Groups
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700609 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700610 protected interface SyncColumns extends BaseSyncColumns {
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700611 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500612 * The name of the account instance to which this row belongs, which when paired with
613 * {@link #ACCOUNT_TYPE} identifies a specific account.
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700614 * <P>Type: TEXT</P>
615 */
616 public static final String ACCOUNT_NAME = "account_name";
617
618 /**
619 * The type of account to which this row belongs, which when paired with
620 * {@link #ACCOUNT_NAME} identifies a specific account.
621 * <P>Type: TEXT</P>
622 */
623 public static final String ACCOUNT_TYPE = "account_type";
624
625 /**
626 * String that uniquely identifies this row to its source account.
627 * <P>Type: TEXT</P>
628 */
629 public static final String SOURCE_ID = "sourceid";
630
631 /**
632 * Version number that is updated whenever this row or its related data
633 * changes.
634 * <P>Type: INTEGER</P>
635 */
636 public static final String VERSION = "version";
637
638 /**
639 * Flag indicating that {@link #VERSION} has changed, and this row needs
640 * to be synchronized by its owning account.
641 * <P>Type: INTEGER (boolean)</P>
642 */
643 public static final String DIRTY = "dirty";
644 }
645
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800646 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800647 * Columns of {@link ContactsContract.Contacts} that track the user's
648 * preferences for, or interactions with, the contact.
649 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800650 * @see Contacts
651 * @see RawContacts
652 * @see ContactsContract.Data
653 * @see PhoneLookup
654 * @see ContactsContract.Contacts.AggregationSuggestions
655 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700656 protected interface ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700657 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500658 * The number of times a contact has been contacted
Evan Millar088b2912009-05-28 15:24:37 -0700659 * <P>Type: INTEGER</P>
660 */
661 public static final String TIMES_CONTACTED = "times_contacted";
662
663 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500664 * The last time a contact was contacted.
Evan Millar088b2912009-05-28 15:24:37 -0700665 * <P>Type: INTEGER</P>
666 */
667 public static final String LAST_TIME_CONTACTED = "last_time_contacted";
668
669 /**
670 * Is the contact starred?
671 * <P>Type: INTEGER (boolean)</P>
672 */
673 public static final String STARRED = "starred";
674
675 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800676 * URI for a custom ringtone associated with the contact. If null or missing,
677 * the default ringtone is used.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700678 * <P>Type: TEXT (URI to the ringtone)</P>
679 */
680 public static final String CUSTOM_RINGTONE = "custom_ringtone";
681
682 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800683 * Whether the contact should always be sent to voicemail. If missing,
684 * defaults to false.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700685 * <P>Type: INTEGER (0 for false, 1 for true)</P>
686 */
687 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700688 }
689
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800690 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800691 * Columns of {@link ContactsContract.Contacts} that refer to intrinsic
692 * properties of the contact, as opposed to the user-specified options
693 * found in {@link ContactOptionsColumns}.
694 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800695 * @see Contacts
696 * @see ContactsContract.Data
697 * @see PhoneLookup
698 * @see ContactsContract.Contacts.AggregationSuggestions
699 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700700 protected interface ContactsColumns {
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700701 /**
702 * The display name for the contact.
703 * <P>Type: TEXT</P>
704 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -0800705 public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY;
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700706
707 /**
Dmitri Plotnikov96186082009-12-01 14:35:04 -0800708 * Reference to the row in the RawContacts table holding the contact name.
709 * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P>
710 * @hide
711 */
712 public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
713
714 /**
Evan Millar088b2912009-05-28 15:24:37 -0700715 * Reference to the row in the data table holding the photo.
716 * <P>Type: INTEGER REFERENCES data(_id)</P>
717 */
718 public static final String PHOTO_ID = "photo_id";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700719
720 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700721 * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -0700722 * any {@link CommonDataKinds.GroupMembership} for this contact.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700723 */
724 public static final String IN_VISIBLE_GROUP = "in_visible_group";
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700725
726 /**
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700727 * An indicator of whether this contact has at least one phone number. "1" if there is
728 * at least one phone number, "0" otherwise.
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700729 * <P>Type: INTEGER</P>
730 */
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700731 public static final String HAS_PHONE_NUMBER = "has_phone_number";
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700732
733 /**
734 * An opaque value that contains hints on how to find the contact if
735 * its row id changed as a result of a sync or aggregation.
736 */
737 public static final String LOOKUP_KEY = "lookup";
Evan Millar088b2912009-05-28 15:24:37 -0700738 }
739
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800740 /**
741 * @see Contacts
742 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700743 protected interface ContactStatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700744 /**
745 * Contact presence status. See {@link StatusUpdates} for individual status
746 * definitions.
747 * <p>Type: NUMBER</p>
748 */
749 public static final String CONTACT_PRESENCE = "contact_presence";
750
751 /**
Vasu Norifb5bccf2010-07-19 14:11:54 -0700752 * Contact Chat Capabilities. See {@link StatusUpdates} for individual
Vasu Nori5b31498ba12010-07-12 15:13:37 -0700753 * definitions.
754 * <p>Type: NUMBER</p>
755 */
756 public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability";
757
758 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700759 * Contact's latest status update.
760 * <p>Type: TEXT</p>
761 */
762 public static final String CONTACT_STATUS = "contact_status";
763
764 /**
765 * The absolute time in milliseconds when the latest status was
766 * inserted/updated.
767 * <p>Type: NUMBER</p>
768 */
769 public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
770
771 /**
772 * The package containing resources for this status: label and icon.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800773 * <p>Type: TEXT</p>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700774 */
775 public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
776
777 /**
778 * The resource ID of the label describing the source of contact
779 * status, e.g. "Google Talk". This resource is scoped by the
780 * {@link #CONTACT_STATUS_RES_PACKAGE}.
781 * <p>Type: NUMBER</p>
782 */
783 public static final String CONTACT_STATUS_LABEL = "contact_status_label";
784
785 /**
786 * The resource ID of the icon for the source of contact status. This
787 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
788 * <p>Type: NUMBER</p>
789 */
790 public static final String CONTACT_STATUS_ICON = "contact_status_icon";
791 }
792
Evan Millar088b2912009-05-28 15:24:37 -0700793 /**
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800794 * Constants for various styles of combining given name, family name etc into
795 * a full name. For example, the western tradition follows the pattern
796 * 'given name' 'middle name' 'family name' with the alternative pattern being
797 * 'family name', 'given name' 'middle name'. The CJK tradition is
798 * 'family name' 'middle name' 'given name', with Japanese favoring a space between
799 * the names and Chinese omitting the space.
800 * @hide
801 */
802 public interface FullNameStyle {
803 public static final int UNDEFINED = 0;
804 public static final int WESTERN = 1;
805
806 /**
807 * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
808 * which specific language it belongs to: Chinese, Japanese or Korean.
809 */
810 public static final int CJK = 2;
811
812 public static final int CHINESE = 3;
813 public static final int JAPANESE = 4;
814 public static final int KOREAN = 5;
815 }
816
817 /**
818 * Constants for various styles of capturing the pronunciation of a person's name.
819 * @hide
820 */
821 public interface PhoneticNameStyle {
822 public static final int UNDEFINED = 0;
823
824 /**
825 * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
826 * shown in UIs, but used for searches and sorting.
827 */
828 public static final int PINYIN = 3;
829
830 /**
831 * Hiragana and Katakana are two common styles of writing out the pronunciation
832 * of a Japanese names.
833 */
834 public static final int JAPANESE = 4;
835
836 /**
837 * Hangul is the Korean phonetic alphabet.
838 */
839 public static final int KOREAN = 5;
840 }
841
842 /**
843 * Types of data used to produce the display name for a contact. Listed in the order
844 * of increasing priority.
845 *
846 * @hide
847 */
848 public interface DisplayNameSources {
849 public static final int UNDEFINED = 0;
850 public static final int EMAIL = 10;
851 public static final int PHONE = 20;
852 public static final int ORGANIZATION = 30;
853 public static final int NICKNAME = 35;
854 public static final int STRUCTURED_NAME = 40;
855 }
856
857 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800858 * Contact name and contact name metadata columns in the RawContacts table.
859 *
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800860 * @see Contacts
861 * @see RawContacts
862 * @hide
863 */
864 protected interface ContactNameColumns {
865
866 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800867 * The kind of data that is used as the display name for the contact, such as
868 * structured name or email address. See DisplayNameSources.
869 *
870 * TODO: convert DisplayNameSources to a link after it is un-hidden
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800871 */
872 public static final String DISPLAY_NAME_SOURCE = "display_name_source";
873
874 /**
Tom O'Neill093a8702010-01-15 16:20:34 -0800875 * <p>
876 * The standard text shown as the contact's display name, based on the best
877 * available information for the contact (for example, it might be the email address
878 * if the name is not available).
879 * The information actually used to compute the name is stored in
880 * {@link #DISPLAY_NAME_SOURCE}.
881 * </p>
882 * <p>
883 * A contacts provider is free to choose whatever representation makes most
884 * sense for its target market.
885 * For example in the default Android Open Source Project implementation,
886 * if the display name is
887 * based on the structured name and the structured name follows
888 * the Western full-name style, then this field contains the "given name first"
889 * version of the full name.
890 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800891 *
892 * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800893 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -0800894 public static final String DISPLAY_NAME_PRIMARY = "display_name";
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800895
896 /**
Tom O'Neill093a8702010-01-15 16:20:34 -0800897 * <p>
898 * An alternative representation of the display name, such as "family name first"
899 * instead of "given name first" for Western names. If an alternative is not
900 * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}.
901 * </p>
902 * <p>
903 * A contacts provider is free to provide alternatives as necessary for
904 * its target market.
905 * For example the default Android Open Source Project contacts provider
906 * currently provides an
907 * alternative in a single case: if the display name is
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800908 * based on the structured name and the structured name follows
Tom O'Neill093a8702010-01-15 16:20:34 -0800909 * the Western full name style, then the field contains the "family name first"
910 * version of the full name.
911 * Other cases may be added later.
912 * </p>
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800913 */
914 public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
915
916 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800917 * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See
Dmitri Plotnikov3170f9a2009-12-15 13:54:28 -0800918 * PhoneticNameStyle.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800919 *
920 * TODO: convert PhoneticNameStyle to a link after it is un-hidden
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800921 */
922 public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
923
924 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800925 * <p>
926 * Pronunciation of the full name in the phonetic alphabet specified by
927 * {@link #PHONETIC_NAME_STYLE}.
928 * </p>
929 * <p>
930 * The value may be set manually by the user.
931 * This capability is is of interest only in countries
932 * with commonly used phonetic
933 * alphabets, such as Japan and Korea. See PhoneticNameStyle.
934 * </p>
935 *
936 * TODO: convert PhoneticNameStyle to a link after it is un-hidden
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800937 */
938 public static final String PHONETIC_NAME = "phonetic_name";
939
940 /**
941 * Sort key that takes into account locale-based traditions for sorting
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800942 * names in address books. The default
943 * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names
944 * the sort key is the name's Pinyin spelling, and for Japanese names
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800945 * it is the Hiragana version of the phonetic name.
946 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -0800947 public static final String SORT_KEY_PRIMARY = "sort_key";
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800948
949 /**
950 * Sort key based on the alternative representation of the full name,
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800951 * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names,
Dmitri Plotnikov2a650dd2010-01-26 17:28:52 -0800952 * it is the one using the "family name first" format.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800953 */
954 public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
955 }
956
957 /**
Dmitri Plotnikov53de9042010-02-17 10:57:19 -0800958 * URI parameter and cursor extras that return counts of rows grouped by the
959 * address book index, which is usually the first letter of the sort key.
960 * When this parameter is supplied, the row counts are returned in the
961 * cursor extras bundle.
962 *
963 * @hide
964 */
965 public final static class ContactCounts {
966
967 /**
968 * Add this query parameter to a URI to get back row counts grouped by
969 * the address book index as cursor extras. For most languages it is the
970 * first letter of the sort key. This parameter does not affect the main
971 * content of the cursor.
972 *
973 * @hide
974 */
975 public static final String ADDRESS_BOOK_INDEX_EXTRAS = "address_book_index_extras";
976
977 /**
978 * The array of address book index titles, which are returned in the
979 * same order as the data in the cursor.
980 * <p>TYPE: String[]</p>
981 *
982 * @hide
983 */
984 public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "address_book_index_titles";
985
986 /**
987 * The array of group counts for the corresponding group. Contains the same number
988 * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
989 * <p>TYPE: int[]</p>
990 *
991 * @hide
992 */
993 public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "address_book_index_counts";
994 }
995
996 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800997 * Constants for the contacts table, which contains a record per aggregate
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500998 * of raw contacts representing the same person.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800999 * <h3>Operations</h3>
1000 * <dl>
1001 * <dt><b>Insert</b></dt>
1002 * <dd>A Contact cannot be created explicitly. When a raw contact is
1003 * inserted, the provider will first try to find a Contact representing the
1004 * same person. If one is found, the raw contact's
1005 * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
1006 * Contact. If no match is found, the provider automatically inserts a new
1007 * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
1008 * of the newly inserted raw contact.</dd>
1009 * <dt><b>Update</b></dt>
1010 * <dd>Only certain columns of Contact are modifiable:
1011 * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
1012 * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
1013 * these columns on the Contact also changes them on all constituent raw
1014 * contacts.</dd>
1015 * <dt><b>Delete</b></dt>
1016 * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
1017 * deletes all constituent raw contacts. The corresponding sync adapters
1018 * will notice the deletions of their respective raw contacts and remove
1019 * them from their back end storage.</dd>
1020 * <dt><b>Query</b></dt>
1021 * <dd>
1022 * <ul>
1023 * <li>If you need to read an individual contact, consider using
1024 * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
1025 * <li>If you need to look up a contact by the phone number, use
1026 * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
1027 * which is optimized for this purpose.</li>
1028 * <li>If you need to look up a contact by partial name, e.g. to produce
1029 * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
1030 * <li>If you need to look up a contact by some data element like email
1031 * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
1032 * The result will contain contact ID, name etc.
1033 * </ul>
1034 * </dd>
1035 * </dl>
1036 * <h2>Columns</h2>
1037 * <table class="jd-sumtable">
1038 * <tr>
1039 * <th colspan='4'>Contacts</th>
1040 * </tr>
1041 * <tr>
1042 * <td>long</td>
1043 * <td>{@link #_ID}</td>
1044 * <td>read-only</td>
1045 * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
1046 * </tr>
1047 * <tr>
1048 * <td>String</td>
1049 * <td>{@link #LOOKUP_KEY}</td>
1050 * <td>read-only</td>
1051 * <td>An opaque value that contains hints on how to find the contact if its
1052 * row id changed as a result of a sync or aggregation.</td>
1053 * </tr>
1054 * <tr>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001055 * <td>long</td>
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001056 * <td>NAME_RAW_CONTACT_ID</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001057 * <td>read-only</td>
1058 * <td>The ID of the raw contact that contributes the display name
1059 * to the aggregate contact. During aggregation one of the constituent
1060 * raw contacts is chosen using a heuristic: a longer name or a name
1061 * with more diacritic marks or more upper case characters is chosen.</td>
1062 * </tr>
1063 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001064 * <td>String</td>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001065 * <td>DISPLAY_NAME_PRIMARY</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001066 * <td>read-only</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001067 * <td>The display name for the contact. It is the display name
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001068 * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001069 * column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001070 * </tr>
1071 * <tr>
1072 * <td>long</td>
1073 * <td>{@link #PHOTO_ID}</td>
1074 * <td>read-only</td>
1075 * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
1076 * That row has the mime type
1077 * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
1078 * is computed automatically based on the
1079 * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
1080 * that mime type.</td>
1081 * </tr>
1082 * <tr>
1083 * <td>int</td>
1084 * <td>{@link #IN_VISIBLE_GROUP}</td>
1085 * <td>read-only</td>
1086 * <td>An indicator of whether this contact is supposed to be visible in the
1087 * UI. "1" if the contact has at least one raw contact that belongs to a
1088 * visible group; "0" otherwise.</td>
1089 * </tr>
1090 * <tr>
1091 * <td>int</td>
1092 * <td>{@link #HAS_PHONE_NUMBER}</td>
1093 * <td>read-only</td>
1094 * <td>An indicator of whether this contact has at least one phone number.
1095 * "1" if there is at least one phone number, "0" otherwise.</td>
1096 * </tr>
1097 * <tr>
1098 * <td>int</td>
1099 * <td>{@link #TIMES_CONTACTED}</td>
1100 * <td>read/write</td>
1101 * <td>The number of times the contact has been contacted. See
1102 * {@link #markAsContacted}. When raw contacts are aggregated, this field is
1103 * computed automatically as the maximum number of times contacted among all
1104 * constituent raw contacts. Setting this field automatically changes the
1105 * corresponding field on all constituent raw contacts.</td>
1106 * </tr>
1107 * <tr>
1108 * <td>long</td>
1109 * <td>{@link #LAST_TIME_CONTACTED}</td>
1110 * <td>read/write</td>
1111 * <td>The timestamp of the last time the contact was contacted. See
1112 * {@link #markAsContacted}. Setting this field also automatically
1113 * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
1114 * this field is computed automatically as the latest time contacted of all
1115 * constituent raw contacts. Setting this field automatically changes the
1116 * corresponding field on all constituent raw contacts.</td>
1117 * </tr>
1118 * <tr>
1119 * <td>int</td>
1120 * <td>{@link #STARRED}</td>
1121 * <td>read/write</td>
1122 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
1123 * When raw contacts are aggregated, this field is automatically computed:
1124 * if any constituent raw contacts are starred, then this field is set to
1125 * '1'. Setting this field automatically changes the corresponding field on
1126 * all constituent raw contacts.</td>
1127 * </tr>
1128 * <tr>
1129 * <td>String</td>
1130 * <td>{@link #CUSTOM_RINGTONE}</td>
1131 * <td>read/write</td>
1132 * <td>A custom ringtone associated with a contact. Typically this is the
1133 * URI returned by an activity launched with the
1134 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
1135 * </tr>
1136 * <tr>
1137 * <td>int</td>
1138 * <td>{@link #SEND_TO_VOICEMAIL}</td>
1139 * <td>read/write</td>
1140 * <td>An indicator of whether calls from this contact should be forwarded
1141 * directly to voice mail ('1') or not ('0'). When raw contacts are
1142 * aggregated, this field is automatically computed: if <i>all</i>
1143 * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
1144 * to '1'. Setting this field automatically changes the corresponding field
1145 * on all constituent raw contacts.</td>
1146 * </tr>
1147 * <tr>
1148 * <td>int</td>
1149 * <td>{@link #CONTACT_PRESENCE}</td>
1150 * <td>read-only</td>
1151 * <td>Contact IM presence status. See {@link StatusUpdates} for individual
1152 * status definitions. Automatically computed as the highest presence of all
1153 * constituent raw contacts. The provider may choose not to store this value
1154 * in persistent storage. The expectation is that presence status will be
1155 * updated on a regular basic.</td>
1156 * </tr>
1157 * <tr>
1158 * <td>String</td>
1159 * <td>{@link #CONTACT_STATUS}</td>
1160 * <td>read-only</td>
1161 * <td>Contact's latest status update. Automatically computed as the latest
1162 * of all constituent raw contacts' status updates.</td>
1163 * </tr>
1164 * <tr>
1165 * <td>long</td>
1166 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
1167 * <td>read-only</td>
1168 * <td>The absolute time in milliseconds when the latest status was
1169 * inserted/updated.</td>
1170 * </tr>
1171 * <tr>
1172 * <td>String</td>
1173 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
1174 * <td>read-only</td>
1175 * <td> The package containing resources for this status: label and icon.</td>
1176 * </tr>
1177 * <tr>
1178 * <td>long</td>
1179 * <td>{@link #CONTACT_STATUS_LABEL}</td>
1180 * <td>read-only</td>
1181 * <td>The resource ID of the label describing the source of contact status,
1182 * e.g. "Google Talk". This resource is scoped by the
1183 * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1184 * </tr>
1185 * <tr>
1186 * <td>long</td>
1187 * <td>{@link #CONTACT_STATUS_ICON}</td>
1188 * <td>read-only</td>
1189 * <td>The resource ID of the icon for the source of contact status. This
1190 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1191 * </tr>
1192 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07001193 */
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07001194 public static class Contacts implements BaseColumns, ContactsColumns,
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001195 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
Evan Millar088b2912009-05-28 15:24:37 -07001196 /**
1197 * This utility class cannot be instantiated
1198 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001199 private Contacts() {}
Evan Millar088b2912009-05-28 15:24:37 -07001200
1201 /**
1202 * The content:// style URI for this table
1203 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001204 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
Evan Millar088b2912009-05-28 15:24:37 -07001205
1206 /**
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001207 * A content:// style URI for this table that should be used to create
1208 * shortcuts or otherwise create long-term links to contacts. This URI
1209 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
1210 * It can optionally also have a "/" and last known contact ID appended after
1211 * that. This "complete" format is an important optimization and is highly recommended.
1212 * <p>
1213 * As long as the contact's row ID remains the same, this URI is
1214 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
1215 * as a result of a sync or aggregation, this URI will look up the
1216 * contact using indirect information (sync IDs or constituent raw
1217 * contacts).
1218 * <p>
1219 * Lookup key should be appended unencoded - it is stored in the encoded
1220 * form, ready for use in a URI.
1221 */
1222 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1223 "lookup");
1224
1225 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001226 * Base {@link Uri} for referencing a single {@link Contacts} entry,
Jeff Sharkey8f767342009-09-28 18:22:46 -07001227 * created by appending {@link #LOOKUP_KEY} using
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001228 * {@link Uri#withAppendedPath(Uri, String)}. Provides
1229 * {@link OpenableColumns} columns when queried, or returns the
1230 * referenced contact formatted as a vCard when opened through
1231 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1232 */
1233 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1234 "as_vcard");
1235
1236 /**
Daniel Lehmann63e91402010-03-12 13:44:31 -08001237 * Base {@link Uri} for referencing multiple {@link Contacts} entry,
1238 * created by appending {@link #LOOKUP_KEY} using
1239 * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
1240 * encoded and joined with the colon (":") seperator. The resulting string
1241 * has to be encoded again. Provides
1242 * {@link OpenableColumns} columns when queried, or returns the
1243 * referenced contact formatted as a vCard when opened through
1244 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1245 *
1246 * This is private API because we do not have a well-defined way to
1247 * specify several entities yet. The format of this Uri might change in the future
1248 * or the Uri might be completely removed.
1249 *
1250 * @hide
1251 */
1252 public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1253 "as_multi_vcard");
1254
1255 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001256 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
1257 * requested {@link Contacts} entry.
1258 *
1259 * @param contactUri A {@link #CONTENT_URI} row, or an existing
1260 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001261 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001262 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
1263 final Cursor c = resolver.query(contactUri, new String[] {
1264 Contacts.LOOKUP_KEY, Contacts._ID
1265 }, null, null, null);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001266 if (c == null) {
1267 return null;
1268 }
1269
1270 try {
1271 if (c.moveToFirst()) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001272 final String lookupKey = c.getString(0);
1273 final long contactId = c.getLong(1);
1274 return getLookupUri(contactId, lookupKey);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001275 }
1276 } finally {
1277 c.close();
1278 }
1279 return null;
1280 }
1281
1282 /**
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001283 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001284 * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001285 */
1286 public static Uri getLookupUri(long contactId, String lookupKey) {
1287 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
1288 lookupKey), contactId);
1289 }
1290
1291 /**
Dmitri Plotnikovb5759b52009-09-01 15:58:40 -07001292 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
1293 * <p>
1294 * Returns null if the contact cannot be found.
1295 */
1296 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
1297 if (lookupUri == null) {
1298 return null;
1299 }
1300
1301 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
1302 if (c == null) {
1303 return null;
1304 }
1305
1306 try {
1307 if (c.moveToFirst()) {
1308 long contactId = c.getLong(0);
1309 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1310 }
1311 } finally {
1312 c.close();
1313 }
1314 return null;
1315 }
1316
1317 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001318 * Mark a contact as having been contacted. This updates the
1319 * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED} for the
1320 * contact, plus the corresponding values of any associated raw
1321 * contacts.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001322 *
1323 * @param resolver the ContentResolver to use
1324 * @param contactId the person who was contacted
1325 */
1326 public static void markAsContacted(ContentResolver resolver, long contactId) {
1327 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
1328 ContentValues values = new ContentValues();
1329 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
1330 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
1331 resolver.update(uri, values, null, null);
1332 }
1333
1334 /**
Evan Millar161dd862009-06-12 16:02:43 -07001335 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001336 * {@link #CONTENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001337 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -07001338 * as an additional path segment after this URI.
1339 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001340 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
1341 CONTENT_URI, "filter");
1342
Evan Millardc2da5f2009-06-18 16:07:13 -07001343 /**
1344 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001345 * {@link ContactsContract.Data}, filtered to include only starred contacts
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001346 * and the most frequently contacted contacts.
Evan Millardc2da5f2009-06-18 16:07:13 -07001347 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001348 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
1349 CONTENT_URI, "strequent");
1350
Evan Millardc2da5f2009-06-18 16:07:13 -07001351 /**
1352 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001353 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001354 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -07001355 * as an additional path segment after this URI.
1356 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001357 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
1358 CONTENT_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001359
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001360 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
1361 CONTENT_URI, "group");
1362
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001363 /**
Evan Millar088b2912009-05-28 15:24:37 -07001364 * The MIME type of {@link #CONTENT_URI} providing a directory of
1365 * people.
1366 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001367 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001368
1369 /**
1370 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1371 * person.
1372 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001373 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001374
1375 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001376 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1377 * person.
1378 */
1379 public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
1380
1381 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001382 * A sub-directory of a single contact that contains all of the constituent raw contact
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001383 * {@link ContactsContract.Data} rows.
Evan Millar088b2912009-05-28 15:24:37 -07001384 */
Fred Quintana8851e162009-08-05 21:06:45 -07001385 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07001386 /**
1387 * no public constructor since this is a utility class
1388 */
1389 private Data() {}
1390
1391 /**
1392 * The directory twig for this sub-table
1393 */
1394 public static final String CONTENT_DIRECTORY = "data";
1395 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001396
1397 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001398 * <p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001399 * A sub-directory of a contact that contains all of its
1400 * {@link ContactsContract.RawContacts} as well as
1401 * {@link ContactsContract.Data} rows. To access this directory append
1402 * {@link #CONTENT_DIRECTORY} to the contact URI.
1403 * </p>
1404 * <p>
1405 * Entity has three ID fields: {@link #CONTACT_ID} for the contact,
1406 * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for
1407 * the data rows. Entity always contains at least one row per
1408 * constituent raw contact, even if there are no actual data rows. In
1409 * this case the {@link #DATA_ID} field will be null.
1410 * </p>
1411 * <p>
1412 * Entity reads all data for the entire contact in one transaction, to
1413 * guarantee consistency. There is significant data duplication
1414 * in the Entity (each row repeats all Contact columns and all RawContact
1415 * columns), so the benefits of transactional consistency should be weighed
1416 * against the cost of transferring large amounts of denormalized data
1417 * from the Provider.
1418 * </p>
1419 *
1420 * @hide
1421 */
1422 public static final class Entity implements BaseColumns, ContactsColumns,
1423 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns,
1424 StatusColumns, ContactOptionsColumns, ContactStatusColumns {
1425 /**
1426 * no public constructor since this is a utility class
1427 */
1428 private Entity() {
1429 }
1430
1431 /**
1432 * The directory twig for this sub-table
1433 */
1434 public static final String CONTENT_DIRECTORY = "entities";
1435
1436 /**
1437 * The ID of the raw contact row.
1438 * <P>Type: INTEGER</P>
1439 */
1440 public static final String RAW_CONTACT_ID = "raw_contact_id";
1441
1442 /**
1443 * The ID of the data row. The value will be null if this raw contact has no
1444 * data rows.
1445 * <P>Type: INTEGER</P>
1446 */
1447 public static final String DATA_ID = "data_id";
1448 }
1449
1450 /**
1451 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001452 * A <i>read-only</i> sub-directory of a single contact aggregate that
1453 * contains all aggregation suggestions (other contacts). The
1454 * aggregation suggestions are computed based on approximate data
1455 * matches with this contact.
1456 * </p>
1457 * <p>
1458 * <i>Note: this query may be expensive! If you need to use it in bulk,
1459 * make sure the user experience is acceptable when the query runs for a
1460 * long time.</i>
1461 * <p>
1462 * Usage example:
1463 *
1464 * <pre>
1465 * Uri uri = Contacts.CONTENT_URI.buildUpon()
1466 * .appendEncodedPath(String.valueOf(contactId))
1467 * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
1468 * .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
1469 * .build()
1470 * Cursor cursor = getContentResolver().query(suggestionsUri,
1471 * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
1472 * null, null, null);
1473 * </pre>
1474 *
1475 * </p>
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001476 */
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001477 // TODO: add ContactOptionsColumns, ContactStatusColumns
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001478 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001479 /**
1480 * No public constructor since this is a utility class
1481 */
1482 private AggregationSuggestions() {}
1483
1484 /**
Dmitri Plotnikov0fc02442009-09-21 13:26:28 -07001485 * The directory twig for this sub-table. The URI can be followed by an optional
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001486 * type-to-filter, similar to
1487 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001488 */
1489 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001490 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001491
1492 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001493 * A <i>read-only</i> sub-directory of a single contact that contains
1494 * the contact's primary photo.
1495 * <p>
1496 * Usage example:
1497 *
1498 * <pre>
1499 * public InputStream openPhoto(long contactId) {
1500 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1501 * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
1502 * Cursor cursor = getContentResolver().query(photoUri,
1503 * new String[] {Contacts.Photo.PHOTO}, null, null, null);
1504 * if (cursor == null) {
1505 * return null;
1506 * }
1507 * try {
1508 * if (cursor.moveToFirst()) {
1509 * byte[] data = cursor.getBlob(0);
1510 * if (data != null) {
1511 * return new ByteArrayInputStream(data);
1512 * }
1513 * }
1514 * } finally {
1515 * cursor.close();
1516 * }
1517 * return null;
1518 * }
1519 * </pre>
1520 *
1521 * </p>
1522 * <p>You should also consider using the convenience method
1523 * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri)}
1524 * </p>
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001525 */
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001526 // TODO: change DataColumns to DataColumnsWithJoins
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001527 public static final class Photo implements BaseColumns, DataColumns {
1528 /**
1529 * no public constructor since this is a utility class
1530 */
1531 private Photo() {}
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07001532
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001533 /**
1534 * The directory twig for this sub-table
1535 */
1536 public static final String CONTENT_DIRECTORY = "photo";
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001537
1538 /**
1539 * Thumbnail photo of the raw contact. This is the raw bytes of an image
1540 * that could be inflated using {@link android.graphics.BitmapFactory}.
1541 * <p>
1542 * Type: BLOB
1543 * @hide TODO: Unhide in a separate CL
1544 */
1545 public static final String PHOTO = DATA15;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001546 }
1547
1548 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001549 * Opens an InputStream for the contacts's default photo and returns the
1550 * photo as a byte stream. If there is not photo null will be returned.
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001551 *
1552 * @param contactUri the contact whose photo should be used
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001553 * @return an InputStream of the photo, or null if no photo is present
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001554 */
1555 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001556 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07001557 if (photoUri == null) {
1558 return null;
1559 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001560 Cursor cursor = cr.query(photoUri,
1561 new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
1562 try {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07001563 if (cursor == null || !cursor.moveToNext()) {
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001564 return null;
1565 }
1566 byte[] data = cursor.getBlob(0);
1567 if (data == null) {
1568 return null;
1569 }
1570 return new ByteArrayInputStream(data);
1571 } finally {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07001572 if (cursor != null) {
1573 cursor.close();
1574 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001575 }
1576 }
Evan Millar088b2912009-05-28 15:24:37 -07001577 }
1578
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07001579 protected interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001580 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001581 * A reference to the {@link ContactsContract.Contacts#_ID} that this
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001582 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001583 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -07001584 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001585 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -07001586
1587 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001588 * Flag indicating that this {@link RawContacts} entry and its children have
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001589 * been restricted to specific platform apps.
1590 * <P>Type: INTEGER (boolean)</P>
1591 *
1592 * @hide until finalized in future platform release
1593 */
1594 public static final String IS_RESTRICTED = "is_restricted";
1595
1596 /**
1597 * The aggregation mode for this contact.
1598 * <P>Type: INTEGER</P>
1599 */
1600 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07001601
1602 /**
1603 * The "deleted" flag: "0" by default, "1" if the row has been marked
1604 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07001605 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001606 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07001607 * then calls ContactResolver.delete once more, this time passing the
Fred Quintana33f889a2009-09-14 17:31:26 -07001608 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
1609 * the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07001610 * <P>Type: INTEGER</P>
1611 */
1612 public static final String DELETED = "deleted";
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08001613
1614 /**
1615 * The "name_verified" flag: "1" means that the name fields on this raw
1616 * contact can be trusted and therefore should be used for the entire
1617 * aggregated contact.
1618 * <p>
1619 * If an aggregated contact contains more than one raw contact with a
1620 * verified name, one of those verified names is chosen at random.
1621 * If an aggregated contact contains no verified names, the
1622 * name is chosen randomly from the constituent raw contacts.
1623 * </p>
1624 * <p>
1625 * Updating this flag from "0" to "1" automatically resets it to "0" on
1626 * all other raw contacts in the same aggregated contact.
1627 * </p>
1628 * <p>
1629 * Sync adapters should only specify a value for this column when
1630 * inserting a raw contact and leave it out when doing an update.
1631 * </p>
1632 * <p>
1633 * The default value is "0"
1634 * </p>
1635 * <p>Type: INTEGER</p>
1636 *
1637 * @hide
1638 */
1639 public static final String NAME_VERIFIED = "name_verified";
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07001640
1641 /**
1642 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
1643 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
1644 * <P>Type: INTEGER</P>
Dmitri Plotnikove270c512010-07-16 10:46:00 -07001645 * @hide
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07001646 */
Dmitri Plotnikov86fe8392010-07-16 11:19:46 -07001647 public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001648 }
1649
1650 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001651 * Constants for the raw contacts table, which contains one row of contact
1652 * information for each person in each synced account. Sync adapters and
1653 * contact management apps
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07001654 * are the primary consumers of this API.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001655 *
1656 * <h3>Aggregation</h3>
1657 * <p>
1658 * As soon as a raw contact is inserted or whenever its constituent data
1659 * changes, the provider will check if the raw contact matches other
1660 * existing raw contacts and if so will aggregate it with those. The
1661 * aggregation is reflected in the {@link RawContacts} table by the change of the
1662 * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
1663 * </p>
1664 * <p>
1665 * Changes to the structured name, organization, phone number, email address,
1666 * or nickname trigger a re-aggregation.
1667 * </p>
1668 * <p>
1669 * See also {@link AggregationExceptions} for a mechanism to control
1670 * aggregation programmatically.
1671 * </p>
1672 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001673 * <h3>Operations</h3>
1674 * <dl>
1675 * <dt><b>Insert</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001676 * <dd>
1677 * <p>
1678 * Raw contacts can be inserted incrementally or in a batch.
1679 * The incremental method is more traditional but less efficient.
1680 * It should be used
1681 * only if no {@link Data} values are available at the time the raw contact is created:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001682 * <pre>
1683 * ContentValues values = new ContentValues();
1684 * values.put(RawContacts.ACCOUNT_TYPE, accountType);
1685 * values.put(RawContacts.ACCOUNT_NAME, accountName);
1686 * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
1687 * long rawContactId = ContentUris.parseId(rawContactUri);
1688 * </pre>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001689 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001690 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001691 * Once {@link Data} values become available, insert those.
1692 * For example, here's how you would insert a name:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001693 *
1694 * <pre>
1695 * values.clear();
1696 * values.put(Data.RAW_CONTACT_ID, rawContactId);
1697 * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
1698 * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
1699 * getContentResolver().insert(Data.CONTENT_URI, values);
1700 * </pre>
1701 * </p>
1702 * <p>
1703 * The batch method is by far preferred. It inserts the raw contact and its
1704 * constituent data rows in a single database transaction
1705 * and causes at most one aggregation pass.
1706 * <pre>
1707 * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001708 * ...
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001709 * int rawContactInsertIndex = ops.size();
1710 * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
1711 * .withValue(RawContacts.ACCOUNT_TYPE, accountType)
1712 * .withValue(RawContacts.ACCOUNT_NAME, accountName)
1713 * .build());
1714 *
1715 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
1716 * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
1717 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
1718 * .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
1719 * .build());
1720 *
1721 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
1722 * </pre>
1723 * </p>
1724 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001725 * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
1726 * to refer to the as-yet-unknown index value of the raw contact inserted in the
1727 * first operation.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001728 * </p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001729 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001730 * <dt><b>Update</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001731 * <dd><p>
1732 * Raw contacts can be updated incrementally or in a batch.
1733 * Batch mode should be used whenever possible.
1734 * The procedures and considerations are analogous to those documented above for inserts.
1735 * </p></dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001736 * <dt><b>Delete</b></dt>
1737 * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
1738 * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001739 * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
1740 * itself is also deleted automatically.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001741 * </p>
1742 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001743 * The invocation of {@code resolver.delete(...)}, does not immediately delete
1744 * a raw contacts row.
1745 * Instead, it sets the {@link #DELETED} flag on the raw contact and
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001746 * removes the raw contact from its aggregate contact.
1747 * The sync adapter then deletes the raw contact from the server and
1748 * finalizes phone-side deletion by calling {@code resolver.delete(...)}
Fred Quintana328c0e72009-12-07 14:52:28 -08001749 * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001750 * <p>Some sync adapters are read-only, meaning that they only sync server-side
1751 * changes to the phone, but not the reverse. If one of those raw contacts
1752 * is marked for deletion, it will remain on the phone. However it will be
1753 * effectively invisible, because it will not be part of any aggregate contact.
1754 * </dd>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001755 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001756 * <dt><b>Query</b></dt>
1757 * <dd>
1758 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001759 * It is easy to find all raw contacts in a Contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001760 * <pre>
1761 * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
1762 * new String[]{RawContacts._ID},
1763 * RawContacts.CONTACT_ID + "=?",
1764 * new String[]{String.valueOf(contactId)}, null);
1765 * </pre>
1766 * </p>
1767 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001768 * To find raw contacts within a specific account,
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001769 * you can either put the account name and type in the selection or pass them as query
1770 * parameters. The latter approach is preferable, especially when you can reuse the
1771 * URI:
1772 * <pre>
1773 * Uri rawContactUri = RawContacts.URI.buildUpon()
1774 * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
1775 * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
1776 * .build();
1777 * Cursor c1 = getContentResolver().query(rawContactUri,
1778 * RawContacts.STARRED + "&lt;&gt;0", null, null, null);
1779 * ...
1780 * Cursor c2 = getContentResolver().query(rawContactUri,
1781 * RawContacts.DELETED + "&lt;&gt;0", null, null, null);
1782 * </pre>
1783 * </p>
1784 * <p>The best way to read a raw contact along with all the data associated with it is
1785 * by using the {@link Entity} directory. If the raw contact has data rows,
1786 * the Entity cursor will contain a row for each data row. If the raw contact has no
1787 * data rows, the cursor will still contain one row with the raw contact-level information.
1788 * <pre>
1789 * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
1790 * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
1791 * Cursor c = getContentResolver().query(entityUri,
1792 * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
1793 * null, null, null);
1794 * try {
1795 * while (c.moveToNext()) {
1796 * String sourceId = c.getString(0);
1797 * if (!c.isNull(1)) {
1798 * String mimeType = c.getString(2);
1799 * String data = c.getString(3);
1800 * ...
1801 * }
1802 * }
1803 * } finally {
1804 * c.close();
1805 * }
1806 * </pre>
1807 * </p>
1808 * </dd>
1809 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001810 * <h2>Columns</h2>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001811 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001812 * <table class="jd-sumtable">
1813 * <tr>
1814 * <th colspan='4'>RawContacts</th>
1815 * </tr>
1816 * <tr>
1817 * <td>long</td>
1818 * <td>{@link #_ID}</td>
1819 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001820 * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
1821 * it is much better for a sync adapter to update a raw contact rather than to delete and
1822 * re-insert it.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001823 * </tr>
1824 * <tr>
1825 * <td>long</td>
1826 * <td>{@link #CONTACT_ID}</td>
1827 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001828 * <td>The ID of the row in the {@link ContactsContract.Contacts} table
1829 * that this raw contact belongs
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001830 * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
1831 * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
1832 * </tr>
1833 * <tr>
1834 * <td>int</td>
1835 * <td>{@link #AGGREGATION_MODE}</td>
1836 * <td>read/write</td>
1837 * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
1838 * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
1839 * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
1840 * </tr>
1841 * <tr>
1842 * <td>int</td>
1843 * <td>{@link #DELETED}</td>
1844 * <td>read/write</td>
1845 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
1846 * for deletion. When {@link android.content.ContentResolver#delete} is
1847 * called on a raw contact, it is marked for deletion and removed from its
1848 * aggregate contact. The sync adaptor deletes the raw contact on the server and
1849 * then calls ContactResolver.delete once more, this time passing the
1850 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
1851 * the data removal.</td>
1852 * </tr>
1853 * <tr>
1854 * <td>int</td>
1855 * <td>{@link #TIMES_CONTACTED}</td>
1856 * <td>read/write</td>
1857 * <td>The number of times the contact has been contacted. To have an effect
1858 * on the corresponding value of the aggregate contact, this field
1859 * should be set at the time the raw contact is inserted.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001860 * After that, this value is typically updated via
1861 * {@link ContactsContract.Contacts#markAsContacted}.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001862 * </tr>
1863 * <tr>
1864 * <td>long</td>
1865 * <td>{@link #LAST_TIME_CONTACTED}</td>
1866 * <td>read/write</td>
1867 * <td>The timestamp of the last time the contact was contacted. To have an effect
1868 * on the corresponding value of the aggregate contact, this field
1869 * should be set at the time the raw contact is inserted.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001870 * After that, this value is typically updated via
1871 * {@link ContactsContract.Contacts#markAsContacted}.
1872 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001873 * </tr>
1874 * <tr>
1875 * <td>int</td>
1876 * <td>{@link #STARRED}</td>
1877 * <td>read/write</td>
1878 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001879 * Changing this field immediately affects the corresponding aggregate contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001880 * if any raw contacts in that aggregate contact are starred, then the contact
1881 * itself is marked as starred.</td>
1882 * </tr>
1883 * <tr>
1884 * <td>String</td>
1885 * <td>{@link #CUSTOM_RINGTONE}</td>
1886 * <td>read/write</td>
1887 * <td>A custom ringtone associated with a raw contact. Typically this is the
1888 * URI returned by an activity launched with the
1889 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
1890 * To have an effect on the corresponding value of the aggregate contact, this field
1891 * should be set at the time the raw contact is inserted. To set a custom
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001892 * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
1893 * Contacts.CUSTOM_RINGTONE}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001894 * instead.</td>
1895 * </tr>
1896 * <tr>
1897 * <td>int</td>
1898 * <td>{@link #SEND_TO_VOICEMAIL}</td>
1899 * <td>read/write</td>
1900 * <td>An indicator of whether calls from this raw contact should be forwarded
1901 * directly to voice mail ('1') or not ('0'). To have an effect
1902 * on the corresponding value of the aggregate contact, this field
1903 * should be set at the time the raw contact is inserted.</td>
1904 * </tr>
1905 * <tr>
1906 * <td>String</td>
1907 * <td>{@link #ACCOUNT_NAME}</td>
1908 * <td>read/write-once</td>
1909 * <td>The name of the account instance to which this row belongs, which when paired with
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001910 * {@link #ACCOUNT_TYPE} identifies a specific account.
1911 * For example, this will be the Gmail address if it is a Google account.
1912 * It should be set at the time
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001913 * the raw contact is inserted and never changed afterwards.</td>
1914 * </tr>
1915 * <tr>
1916 * <td>String</td>
1917 * <td>{@link #ACCOUNT_TYPE}</td>
1918 * <td>read/write-once</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001919 * <td>
1920 * <p>
1921 * The type of account to which this row belongs, which when paired with
1922 * {@link #ACCOUNT_NAME} identifies a specific account.
1923 * It should be set at the time
1924 * the raw contact is inserted and never changed afterwards.
1925 * </p>
1926 * <p>
1927 * To ensure uniqueness, new account types should be chosen according to the
1928 * Java package naming convention. Thus a Google account is of type "com.google".
1929 * </p>
1930 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001931 * </tr>
1932 * <tr>
1933 * <td>String</td>
1934 * <td>{@link #SOURCE_ID}</td>
1935 * <td>read/write</td>
1936 * <td>String that uniquely identifies this row to its source account.
1937 * Typically it is set at the time the raw contact is inserted and never
1938 * changed afterwards. The one notable exception is a new raw contact: it
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001939 * will have an account name and type, but no source id. This
1940 * indicates to the sync adapter that a new contact needs to be created
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001941 * server-side and its ID stored in the corresponding SOURCE_ID field on
1942 * the phone.
1943 * </td>
1944 * </tr>
1945 * <tr>
1946 * <td>int</td>
1947 * <td>{@link #VERSION}</td>
1948 * <td>read-only</td>
1949 * <td>Version number that is updated whenever this row or its related data
1950 * changes. This field can be used for optimistic locking of a raw contact.
1951 * </td>
1952 * </tr>
1953 * <tr>
1954 * <td>int</td>
1955 * <td>{@link #DIRTY}</td>
1956 * <td>read/write</td>
1957 * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
1958 * to be synchronized by its owning account. The value is set to "1" automatically
1959 * whenever the raw contact changes, unless the URI has the
1960 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
1961 * The sync adapter should always supply this query parameter to prevent
1962 * unnecessary synchronization: user changes some data on the server,
1963 * the sync adapter updates the contact on the phone (without the
1964 * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
1965 * which triggers a sync to bring the changes to the server.
1966 * </td>
1967 * </tr>
1968 * <tr>
1969 * <td>String</td>
1970 * <td>{@link #SYNC1}</td>
1971 * <td>read/write</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001972 * <td>Generic column provided for arbitrary use by sync adapters.
1973 * The content provider
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001974 * stores this information on behalf of the sync adapter but does not
1975 * interpret it in any way.
1976 * </td>
1977 * </tr>
1978 * <tr>
1979 * <td>String</td>
1980 * <td>{@link #SYNC2}</td>
1981 * <td>read/write</td>
1982 * <td>Generic column for use by sync adapters.
1983 * </td>
1984 * </tr>
1985 * <tr>
1986 * <td>String</td>
1987 * <td>{@link #SYNC3}</td>
1988 * <td>read/write</td>
1989 * <td>Generic column for use by sync adapters.
1990 * </td>
1991 * </tr>
1992 * <tr>
1993 * <td>String</td>
1994 * <td>{@link #SYNC4}</td>
1995 * <td>read/write</td>
1996 * <td>Generic column for use by sync adapters.
1997 * </td>
1998 * </tr>
1999 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002000 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002001 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08002002 ContactOptionsColumns, ContactNameColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002003 /**
2004 * This utility class cannot be instantiated
2005 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002006 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002007 }
2008
2009 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002010 * The content:// style URI for this table, which requests a directory of
2011 * raw contact rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07002012 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002013 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -07002014
2015 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002016 * The MIME type of the results from {@link #CONTENT_URI} when a specific
2017 * ID value is not provided, and multiple raw contacts may be returned.
Evan Millar088b2912009-05-28 15:24:37 -07002018 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002019 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002020
2021 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002022 * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
2023 * yielding a subdirectory of a single person.
Evan Millar088b2912009-05-28 15:24:37 -07002024 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002025 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002026
2027 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002028 * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002029 */
2030 public static final int AGGREGATION_MODE_DEFAULT = 0;
2031
2032 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002033 * Do not use.
2034 *
Tom O'Neill7d92d5a2010-01-15 08:42:31 -08002035 * TODO: deprecate in favor of {@link #AGGREGATION_MODE_DEFAULT}
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002036 */
Omari Stephensbc9aa772009-09-08 19:10:53 -07002037 public static final int AGGREGATION_MODE_IMMEDIATE = 1;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002038
2039 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002040 * <p>
2041 * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
2042 * Changes to the raw contact will update the associated aggregate contact but will not
2043 * result in any change in how the contact is aggregated. Similar to
2044 * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
2045 * {@link Contacts} aggregate.
2046 * </p>
2047 * <p>
2048 * This can be used to postpone aggregation until after a series of updates, for better
2049 * performance and/or user experience.
2050 * </p>
2051 * <p>
2052 * Note that changing
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002053 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002054 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
2055 * subsequent
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002056 * change to the raw contact's data will.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002057 * </p>
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002058 */
2059 public static final int AGGREGATION_MODE_SUSPENDED = 2;
2060
2061 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002062 * <p>
2063 * Aggregation mode: never aggregate this raw contact. The raw contact will not
2064 * have a corresponding {@link Contacts} aggregate and therefore will not be included in
2065 * {@link Contacts} query results.
2066 * </p>
2067 * <p>
2068 * For example, this mode can be used for a raw contact that is marked for deletion while
2069 * waiting for the deletion to occur on the server side.
2070 * </p>
2071 *
2072 * @see #AGGREGATION_MODE_SUSPENDED
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002073 */
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002074 public static final int AGGREGATION_MODE_DISABLED = 3;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002075
2076 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -05002077 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
2078 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
2079 * entry of the given {@link RawContacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002080 */
2081 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
2082 // TODO: use a lighter query by joining rawcontacts with contacts in provider
2083 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
2084 final Cursor cursor = resolver.query(dataUri, new String[] {
2085 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
2086 }, null, null, null);
2087
2088 Uri lookupUri = null;
2089 try {
2090 if (cursor != null && cursor.moveToFirst()) {
2091 final long contactId = cursor.getLong(0);
2092 final String lookupKey = cursor.getString(1);
2093 return Contacts.getLookupUri(contactId, lookupKey);
2094 }
2095 } finally {
2096 if (cursor != null) cursor.close();
2097 }
2098 return lookupUri;
2099 }
2100
2101 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002102 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002103 * {@link ContactsContract.Data} rows. To access this directory
2104 * append {@link Data#CONTENT_DIRECTORY} to the contact URI.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002105 *
Tom O'Neill7d92d5a2010-01-15 08:42:31 -08002106 * TODO: deprecate in favor of {@link RawContacts.Entity}.
Evan Millar088b2912009-05-28 15:24:37 -07002107 */
2108 public static final class Data implements BaseColumns, DataColumns {
2109 /**
2110 * no public constructor since this is a utility class
2111 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002112 private Data() {
2113 }
Evan Millar088b2912009-05-28 15:24:37 -07002114
2115 /**
2116 * The directory twig for this sub-table
2117 */
2118 public static final String CONTENT_DIRECTORY = "data";
2119 }
Fred Quintana5bba6322009-10-05 14:21:12 -07002120
2121 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002122 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002123 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002124 * {@link ContactsContract.Data} rows. To access this directory append
Ken Shirriff930ab3d2009-12-11 11:12:44 -08002125 * {@link #CONTENT_DIRECTORY} to the contact URI. See
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002126 * {@link RawContactsEntity} for a stand-alone table containing the same
2127 * data.
2128 * </p>
2129 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002130 * Entity has two ID fields: {@link #_ID} for the raw contact
2131 * and {@link #DATA_ID} for the data rows.
2132 * Entity always contains at least one row, even if there are no
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002133 * actual data rows. In this case the {@link #DATA_ID} field will be
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002134 * null.
2135 * </p>
2136 * <p>
2137 * Entity reads all
2138 * data for a raw contact in one transaction, to guarantee
2139 * consistency.
2140 * </p>
Fred Quintana5bba6322009-10-05 14:21:12 -07002141 */
2142 public static final class Entity implements BaseColumns, DataColumns {
2143 /**
2144 * no public constructor since this is a utility class
2145 */
2146 private Entity() {
2147 }
2148
2149 /**
2150 * The directory twig for this sub-table
2151 */
2152 public static final String CONTENT_DIRECTORY = "entity";
2153
2154 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07002155 * The ID of the data row. The value will be null if this raw contact has no
Fred Quintana5bba6322009-10-05 14:21:12 -07002156 * data rows.
2157 * <P>Type: INTEGER</P>
2158 */
2159 public static final String DATA_ID = "data_id";
2160 }
Fred Quintana328c0e72009-12-07 14:52:28 -08002161
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002162 /**
2163 * TODO: javadoc
2164 * @param cursor
2165 * @return
2166 */
Fred Quintana328c0e72009-12-07 14:52:28 -08002167 public static EntityIterator newEntityIterator(Cursor cursor) {
2168 return new EntityIteratorImpl(cursor);
2169 }
2170
2171 private static class EntityIteratorImpl extends CursorEntityIterator {
2172 private static final String[] DATA_KEYS = new String[]{
2173 Data.DATA1,
2174 Data.DATA2,
2175 Data.DATA3,
2176 Data.DATA4,
2177 Data.DATA5,
2178 Data.DATA6,
2179 Data.DATA7,
2180 Data.DATA8,
2181 Data.DATA9,
2182 Data.DATA10,
2183 Data.DATA11,
2184 Data.DATA12,
2185 Data.DATA13,
2186 Data.DATA14,
2187 Data.DATA15,
2188 Data.SYNC1,
2189 Data.SYNC2,
2190 Data.SYNC3,
2191 Data.SYNC4};
2192
2193 public EntityIteratorImpl(Cursor cursor) {
2194 super(cursor);
2195 }
2196
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08002197 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08002198 public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
2199 throws RemoteException {
2200 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
2201 final long rawContactId = cursor.getLong(columnRawContactId);
2202
2203 // we expect the cursor is already at the row we need to read from
2204 ContentValues cv = new ContentValues();
2205 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
2206 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
2207 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
2208 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
2209 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
2210 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
2211 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
2212 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
2213 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
2214 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
2215 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
2216 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
2217 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
2218 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, IS_RESTRICTED);
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002219 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED);
Fred Quintana328c0e72009-12-07 14:52:28 -08002220 android.content.Entity contact = new android.content.Entity(cv);
2221
2222 // read data rows until the contact id changes
2223 do {
2224 if (rawContactId != cursor.getLong(columnRawContactId)) {
2225 break;
2226 }
2227 // add the data to to the contact
2228 cv = new ContentValues();
2229 cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
2230 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2231 Data.RES_PACKAGE);
2232 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
2233 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
2234 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
2235 Data.IS_SUPER_PRIMARY);
2236 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
2237 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2238 CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
2239 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2240 Data.DATA_VERSION);
2241 for (String key : DATA_KEYS) {
2242 final int columnIndex = cursor.getColumnIndexOrThrow(key);
Daniel Lehmann156add92010-07-19 18:01:10 -07002243 switch (cursor.getType(columnIndex)) {
2244 case Cursor.FIELD_TYPE_NULL:
2245 // don't put anything
2246 break;
2247 case Cursor.FIELD_TYPE_INTEGER:
2248 case Cursor.FIELD_TYPE_FLOAT:
2249 case Cursor.FIELD_TYPE_STRING:
Fred Quintana274dc9d2009-12-11 13:17:08 -08002250 cv.put(key, cursor.getString(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07002251 break;
2252 case Cursor.FIELD_TYPE_BLOB:
Fred Quintana274dc9d2009-12-11 13:17:08 -08002253 cv.put(key, cursor.getBlob(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07002254 break;
2255 default:
2256 throw new IllegalStateException("Invalid or unhandled data type");
Fred Quintana328c0e72009-12-07 14:52:28 -08002257 }
Fred Quintana328c0e72009-12-07 14:52:28 -08002258 }
2259 contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
2260 } while (cursor.moveToNext());
2261
2262 return contact;
2263 }
2264
2265 }
Evan Millar088b2912009-05-28 15:24:37 -07002266 }
2267
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002268 /**
2269 * Social status update columns.
2270 *
2271 * @see StatusUpdates
2272 * @see ContactsContract.Data
2273 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002274 protected interface StatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07002275 /**
Dmitri Plotnikova60479d2009-09-27 20:16:31 -07002276 * Contact's latest presence level.
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07002277 * <P>Type: INTEGER (one of the values below)</P>
2278 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002279 public static final String PRESENCE = "mode";
2280
2281 /**
2282 * @deprecated use {@link #PRESENCE}
2283 */
2284 @Deprecated
2285 public static final String PRESENCE_STATUS = PRESENCE;
2286
Tom O'Neill244327e22010-01-08 11:11:15 -08002287 /**
2288 * An allowed value of {@link #PRESENCE}.
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002289 */
2290 int OFFLINE = 0;
Tom O'Neill244327e22010-01-08 11:11:15 -08002291
2292 /**
2293 * An allowed value of {@link #PRESENCE}.
2294 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002295 int INVISIBLE = 1;
Tom O'Neill244327e22010-01-08 11:11:15 -08002296
2297 /**
2298 * An allowed value of {@link #PRESENCE}.
2299 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002300 int AWAY = 2;
Tom O'Neill244327e22010-01-08 11:11:15 -08002301
2302 /**
2303 * An allowed value of {@link #PRESENCE}.
2304 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002305 int IDLE = 3;
Tom O'Neill244327e22010-01-08 11:11:15 -08002306
2307 /**
2308 * An allowed value of {@link #PRESENCE}.
2309 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002310 int DO_NOT_DISTURB = 4;
Tom O'Neill244327e22010-01-08 11:11:15 -08002311
2312 /**
2313 * An allowed value of {@link #PRESENCE}.
2314 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002315 int AVAILABLE = 5;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07002316
2317 /**
2318 * Contact latest status update.
2319 * <p>Type: TEXT</p>
2320 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002321 public static final String STATUS = "status";
2322
2323 /**
2324 * @deprecated use {@link #STATUS}
2325 */
Tom O'Neill244327e22010-01-08 11:11:15 -08002326 @Deprecated
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08002327 public static final String PRESENCE_CUSTOM_STATUS = STATUS;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07002328
2329 /**
2330 * The absolute time in milliseconds when the latest status was inserted/updated.
2331 * <p>Type: NUMBER</p>
2332 */
2333 public static final String STATUS_TIMESTAMP = "status_ts";
2334
2335 /**
2336 * The package containing resources for this status: label and icon.
2337 * <p>Type: NUMBER</p>
2338 */
2339 public static final String STATUS_RES_PACKAGE = "status_res_package";
2340
2341 /**
2342 * The resource ID of the label describing the source of the status update, e.g. "Google
2343 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
2344 * <p>Type: NUMBER</p>
2345 */
2346 public static final String STATUS_LABEL = "status_label";
2347
2348 /**
2349 * The resource ID of the icon for the source of the status update.
2350 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
2351 * <p>Type: NUMBER</p>
2352 */
2353 public static final String STATUS_ICON = "status_icon";
Vasu Nori5b31498ba12010-07-12 15:13:37 -07002354
2355 /**
2356 * Contact's audio/video chat capability level.
2357 * <P>Type: INTEGER (one of the values below)</P>
2358 */
2359 public static final String CHAT_CAPABILITY = "chat_capability";
2360
2361 /**
2362 * An allowed value of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
2363 * display a video feed.
2364 */
2365 public static final int CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY = 1;
2366
2367 /**
2368 * An allowed value of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability.
2369 */
2370 public static final int CAPABILITY_HAS_VOICE = 2;
2371
2372 /**
2373 * An allowed value of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
2374 * camera that can be used for video chat (e.g. a front-facing camera on a phone).
2375 */
2376 public static final int CAPABILITY_HAS_CAMERA = 4;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07002377 }
2378
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002379 /**
2380 * Columns in the Data table.
2381 *
2382 * @see ContactsContract.Data
2383 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07002384 protected interface DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07002385 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002386 * The package name to use when creating {@link Resources} objects for
2387 * this data row. This value is only designed for use when building user
2388 * interfaces, and should not be used to infer the owner.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002389 *
2390 * @hide
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002391 */
2392 public static final String RES_PACKAGE = "res_package";
2393
2394 /**
2395 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -07002396 */
2397 public static final String MIMETYPE = "mimetype";
2398
2399 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002400 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -07002401 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -07002402 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002403 public static final String RAW_CONTACT_ID = "raw_contact_id";
2404
Evan Millarab5742d2009-06-02 16:21:45 -07002405 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08002406 * Whether this is the primary entry of its kind for the raw contact it belongs to.
Evan Millarab5742d2009-06-02 16:21:45 -07002407 * <P>Type: INTEGER (if set, non-0 means true)</P>
2408 */
2409 public static final String IS_PRIMARY = "is_primary";
2410
2411 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002412 * Whether this is the primary entry of its kind for the aggregate
2413 * contact it belongs to. Any data record that is "super primary" must
2414 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -07002415 * <P>Type: INTEGER (if set, non-0 means true)</P>
2416 */
2417 public static final String IS_SUPER_PRIMARY = "is_super_primary";
2418
Jeff Sharkey28b68e52009-06-10 15:26:58 -07002419 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07002420 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
2421 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
2422 * <P>Type: INTEGER</P>
Dmitri Plotnikove270c512010-07-16 10:46:00 -07002423 * @hide
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07002424 */
2425 public static final String IS_READ_ONLY = "is_read_only";
2426
2427 /**
Fred Quintanac933fb62009-06-11 12:14:40 -07002428 * The version of this data record. This is a read-only value. The data column is
2429 * guaranteed to not change without the version going up. This value is monotonically
2430 * increasing.
2431 * <P>Type: INTEGER</P>
2432 */
2433 public static final String DATA_VERSION = "data_version";
2434
Evan Millar088b2912009-05-28 15:24:37 -07002435 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2436 public static final String DATA1 = "data1";
2437 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2438 public static final String DATA2 = "data2";
2439 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2440 public static final String DATA3 = "data3";
2441 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2442 public static final String DATA4 = "data4";
2443 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2444 public static final String DATA5 = "data5";
2445 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2446 public static final String DATA6 = "data6";
2447 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2448 public static final String DATA7 = "data7";
2449 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2450 public static final String DATA8 = "data8";
2451 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2452 public static final String DATA9 = "data9";
2453 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2454 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002455 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2456 public static final String DATA11 = "data11";
2457 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2458 public static final String DATA12 = "data12";
2459 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2460 public static final String DATA13 = "data13";
2461 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
2462 public static final String DATA14 = "data14";
Tom O'Neill244327e22010-01-08 11:11:15 -08002463 /**
2464 * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
2465 * this field is used to store BLOBs (binary data).
2466 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002467 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07002468
Fred Quintana8851e162009-08-05 21:06:45 -07002469 /** Generic column for use by sync adapters. */
2470 public static final String SYNC1 = "data_sync1";
2471 /** Generic column for use by sync adapters. */
2472 public static final String SYNC2 = "data_sync2";
2473 /** Generic column for use by sync adapters. */
2474 public static final String SYNC3 = "data_sync3";
2475 /** Generic column for use by sync adapters. */
2476 public static final String SYNC4 = "data_sync4";
Evan Millar088b2912009-05-28 15:24:37 -07002477 }
2478
2479 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002480 * Combines all columns returned by {@link ContactsContract.Data} table queries.
2481 *
2482 * @see ContactsContract.Data
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07002483 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07002484 protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08002485 RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
2486 ContactStatusColumns {
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07002487 }
2488
2489 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002490 * <p>
2491 * Constants for the data table, which contains data points tied to a raw
Tom O'Neill244327e22010-01-08 11:11:15 -08002492 * contact. Each row of the data table is typically used to store a single
2493 * piece of contact
2494 * information (such as a phone number) and its
2495 * associated metadata (such as whether it is a work or home number).
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002496 * </p>
2497 * <h3>Data kinds</h3>
2498 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08002499 * Data is a generic table that can hold any kind of contact data.
2500 * The kind of data stored in a given row is specified by the row's
2501 * {@link #MIMETYPE} value, which determines the meaning of the
2502 * generic columns {@link #DATA1} through
2503 * {@link #DATA15}.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002504 * For example, if the data kind is
Tom O'Neill244327e22010-01-08 11:11:15 -08002505 * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
2506 * {@link #DATA1} stores the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002507 * phone number, but if the data kind is
Tom O'Neill244327e22010-01-08 11:11:15 -08002508 * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
2509 * stores the email address.
2510 * Sync adapters and applications can introduce their own data kinds.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002511 * </p>
2512 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08002513 * ContactsContract defines a small number of pre-defined data kinds, e.g.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002514 * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
2515 * convenience, these classes define data kind specific aliases for DATA1 etc.
2516 * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
2517 * {@link ContactsContract.Data Data.DATA1}.
2518 * </p>
2519 * <p>
2520 * {@link #DATA1} is an indexed column and should be used for the data element that is
2521 * expected to be most frequently used in query selections. For example, in the
2522 * case of a row representing email addresses {@link #DATA1} should probably
2523 * be used for the email address itself, while {@link #DATA2} etc can be
2524 * used for auxiliary information like type of email address.
2525 * <p>
2526 * <p>
2527 * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
2528 * </p>
2529 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002530 * The sync adapter for a given account type must correctly handle every data type
2531 * used in the corresponding raw contacts. Otherwise it could result in lost or
2532 * corrupted data.
2533 * </p>
2534 * <p>
2535 * Similarly, you should refrain from introducing new kinds of data for an other
Tom O'Neill244327e22010-01-08 11:11:15 -08002536 * party's account types. For example, if you add a data row for
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002537 * "favorite song" to a raw contact owned by a Google account, it will not
2538 * get synced to the server, because the Google sync adapter does not know
2539 * how to handle this data kind. Thus new data kinds are typically
2540 * introduced along with new account types, i.e. new sync adapters.
2541 * </p>
2542 * <h3>Batch operations</h3>
2543 * <p>
2544 * Data rows can be inserted/updated/deleted using the traditional
2545 * {@link ContentResolver#insert}, {@link ContentResolver#update} and
2546 * {@link ContentResolver#delete} methods, however the newer mechanism based
2547 * on a batch of {@link ContentProviderOperation} will prove to be a better
2548 * choice in almost all cases. All operations in a batch are executed in a
2549 * single transaction, which ensures that the phone-side and server-side
2550 * state of a raw contact are always consistent. Also, the batch-based
2551 * approach is far more efficient: not only are the database operations
2552 * faster when executed in a single transaction, but also sending a batch of
2553 * commands to the content provider saves a lot of time on context switching
2554 * between your process and the process in which the content provider runs.
2555 * </p>
2556 * <p>
2557 * The flip side of using batched operations is that a large batch may lock
2558 * up the database for a long time preventing other applications from
2559 * accessing data and potentially causing ANRs ("Application Not Responding"
2560 * dialogs.)
2561 * </p>
2562 * <p>
2563 * To avoid such lockups of the database, make sure to insert "yield points"
2564 * in the batch. A yield point indicates to the content provider that before
2565 * executing the next operation it can commit the changes that have already
2566 * been made, yield to other requests, open another transaction and continue
2567 * processing operations. A yield point will not automatically commit the
2568 * transaction, but only if there is another request waiting on the
2569 * database. Normally a sync adapter should insert a yield point at the
2570 * beginning of each raw contact operation sequence in the batch. See
2571 * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
2572 * </p>
2573 * <h3>Operations</h3>
2574 * <dl>
2575 * <dt><b>Insert</b></dt>
2576 * <dd>
2577 * <p>
2578 * An individual data row can be inserted using the traditional
2579 * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
2580 * should always be inserted as a batch.
2581 * </p>
2582 * <p>
2583 * An example of a traditional insert:
2584 * <pre>
2585 * ContentValues values = new ContentValues();
2586 * values.put(Data.RAW_CONTACT_ID, rawContactId);
2587 * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
2588 * values.put(Phone.NUMBER, "1-800-GOOG-411");
2589 * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
2590 * values.put(Phone.LABEL, "free directory assistance");
2591 * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
2592 * </pre>
2593 * <p>
2594 * The same done using ContentProviderOperations:
2595 * <pre>
2596 * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
2597 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
2598 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
2599 * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
2600 * .withValue(Phone.NUMBER, "1-800-GOOG-411")
2601 * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
2602 * .withValue(Phone.LABEL, "free directory assistance")
2603 * .build());
2604 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2605 * </pre>
2606 * </p>
2607 * <dt><b>Update</b></dt>
2608 * <dd>
2609 * <p>
2610 * Just as with insert, update can be done incrementally or as a batch,
2611 * the batch mode being the preferred method:
2612 * <pre>
2613 * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
2614 * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
2615 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
2616 * .withValue(Email.DATA, "somebody@android.com")
2617 * .build());
2618 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2619 * </pre>
2620 * </p>
2621 * </dd>
2622 * <dt><b>Delete</b></dt>
2623 * <dd>
2624 * <p>
2625 * Just as with insert and update, deletion can be done either using the
2626 * {@link ContentResolver#delete} method or using a ContentProviderOperation:
2627 * <pre>
2628 * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
2629 * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
2630 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
2631 * .build());
2632 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2633 * </pre>
2634 * </p>
2635 * </dd>
2636 * <dt><b>Query</b></dt>
2637 * <dd>
2638 * <p>
2639 * <dl>
2640 * <dt>Finding all Data of a given type for a given contact</dt>
2641 * <dd>
2642 * <pre>
2643 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
2644 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
2645 * Data.CONTACT_ID + &quot;=?&quot; + " AND "
2646 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
2647 * new String[] {String.valueOf(contactId)}, null);
2648 * </pre>
2649 * </p>
2650 * <p>
2651 * </dd>
2652 * <dt>Finding all Data of a given type for a given raw contact</dt>
2653 * <dd>
2654 * <pre>
2655 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
2656 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
2657 * Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
2658 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
2659 * new String[] {String.valueOf(rawContactId)}, null);
2660 * </pre>
2661 * </dd>
2662 * <dt>Finding all Data for a given raw contact</dt>
2663 * <dd>
2664 * Most sync adapters will want to read all data rows for a raw contact
2665 * along with the raw contact itself. For that you should use the
2666 * {@link RawContactsEntity}. See also {@link RawContacts}.
2667 * </dd>
2668 * </dl>
2669 * </p>
2670 * </dd>
2671 * </dl>
2672 * <h2>Columns</h2>
Tom O'Neill244327e22010-01-08 11:11:15 -08002673 * <p>
2674 * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you
2675 * should explicitly specify a projection to only those columns that you need.
2676 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002677 * <table class="jd-sumtable">
2678 * <tr>
2679 * <th colspan='4'>Data</th>
2680 * </tr>
2681 * <tr>
2682 * <td style="width: 7em;">long</td>
2683 * <td style="width: 20em;">{@link #_ID}</td>
2684 * <td style="width: 5em;">read-only</td>
2685 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
Tom O'Neill244327e22010-01-08 11:11:15 -08002686 * it would be a bad idea to delete and reinsert a data row. A sync adapter should
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002687 * always do an update instead.</td>
2688 * </tr>
2689 * <tr>
2690 * <td>String</td>
2691 * <td>{@link #MIMETYPE}</td>
2692 * <td>read/write-once</td>
2693 * <td>
2694 * <p>The MIME type of the item represented by this row. Examples of common
2695 * MIME types are:
2696 * <ul>
2697 * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
2698 * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
2699 * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
2700 * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
2701 * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
2702 * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
2703 * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
2704 * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
2705 * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
2706 * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
2707 * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
2708 * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
2709 * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
2710 * </ul>
2711 * </p>
2712 * </td>
2713 * </tr>
2714 * <tr>
2715 * <td>long</td>
2716 * <td>{@link #RAW_CONTACT_ID}</td>
2717 * <td>read/write-once</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08002718 * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002719 * </tr>
2720 * <tr>
2721 * <td>int</td>
2722 * <td>{@link #IS_PRIMARY}</td>
2723 * <td>read/write</td>
2724 * <td>Whether this is the primary entry of its kind for the raw contact it belongs to.
Tom O'Neill244327e22010-01-08 11:11:15 -08002725 * "1" if true, "0" if false.
2726 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002727 * </tr>
2728 * <tr>
2729 * <td>int</td>
2730 * <td>{@link #IS_SUPER_PRIMARY}</td>
2731 * <td>read/write</td>
2732 * <td>Whether this is the primary entry of its kind for the aggregate
2733 * contact it belongs to. Any data record that is "super primary" must
Tom O'Neill244327e22010-01-08 11:11:15 -08002734 * also be "primary". For example, the super-primary entry may be
2735 * interpreted as the default contact value of its kind (for example,
2736 * the default phone number to use for the contact).</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002737 * </tr>
2738 * <tr>
2739 * <td>int</td>
2740 * <td>{@link #DATA_VERSION}</td>
2741 * <td>read-only</td>
2742 * <td>The version of this data record. Whenever the data row changes
2743 * the version goes up. This value is monotonically increasing.</td>
2744 * </tr>
2745 * <tr>
2746 * <td>Any type</td>
2747 * <td>
2748 * {@link #DATA1}<br>
2749 * {@link #DATA2}<br>
2750 * {@link #DATA3}<br>
2751 * {@link #DATA4}<br>
2752 * {@link #DATA5}<br>
2753 * {@link #DATA6}<br>
2754 * {@link #DATA7}<br>
2755 * {@link #DATA8}<br>
2756 * {@link #DATA9}<br>
2757 * {@link #DATA10}<br>
2758 * {@link #DATA11}<br>
2759 * {@link #DATA12}<br>
2760 * {@link #DATA13}<br>
2761 * {@link #DATA14}<br>
2762 * {@link #DATA15}
2763 * </td>
2764 * <td>read/write</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08002765 * <td>
2766 * <p>
2767 * Generic data columns. The meaning of each column is determined by the
2768 * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing
2769 * BLOBs (binary data).
2770 * </p>
2771 * <p>
2772 * Data columns whose meaning is not explicitly defined for a given MIMETYPE
2773 * should not be used. There is no guarantee that any sync adapter will
2774 * preserve them. Sync adapters themselves should not use such columns either,
2775 * but should instead use {@link #SYNC1}-{@link #SYNC4}.
2776 * </p>
2777 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002778 * </tr>
2779 * <tr>
2780 * <td>Any type</td>
2781 * <td>
2782 * {@link #SYNC1}<br>
2783 * {@link #SYNC2}<br>
2784 * {@link #SYNC3}<br>
2785 * {@link #SYNC4}
2786 * </td>
2787 * <td>read/write</td>
2788 * <td>Generic columns for use by sync adapters. For example, a Photo row
2789 * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
2790 * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
2791 * </tr>
2792 * </table>
2793 *
Tom O'Neill244327e22010-01-08 11:11:15 -08002794 * <p>
2795 * Some columns from the most recent associated status update are also available
2796 * through an implicit join.
2797 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002798 * <table class="jd-sumtable">
2799 * <tr>
2800 * <th colspan='4'>Join with {@link StatusUpdates}</th>
2801 * </tr>
2802 * <tr>
2803 * <td style="width: 7em;">int</td>
2804 * <td style="width: 20em;">{@link #PRESENCE}</td>
2805 * <td style="width: 5em;">read-only</td>
2806 * <td>IM presence status linked to this data row. Compare with
2807 * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
2808 * all IM rows. See {@link StatusUpdates} for individual status definitions.
2809 * The provider may choose not to store this value
2810 * in persistent storage. The expectation is that presence status will be
2811 * updated on a regular basic.
2812 * </td>
2813 * </tr>
2814 * <tr>
2815 * <td>String</td>
2816 * <td>{@link #STATUS}</td>
2817 * <td>read-only</td>
2818 * <td>Latest status update linked with this data row.</td>
2819 * </tr>
2820 * <tr>
2821 * <td>long</td>
2822 * <td>{@link #STATUS_TIMESTAMP}</td>
2823 * <td>read-only</td>
2824 * <td>The absolute time in milliseconds when the latest status was
2825 * inserted/updated for this data row.</td>
2826 * </tr>
2827 * <tr>
2828 * <td>String</td>
2829 * <td>{@link #STATUS_RES_PACKAGE}</td>
2830 * <td>read-only</td>
2831 * <td>The package containing resources for this status: label and icon.</td>
2832 * </tr>
2833 * <tr>
2834 * <td>long</td>
2835 * <td>{@link #STATUS_LABEL}</td>
2836 * <td>read-only</td>
2837 * <td>The resource ID of the label describing the source of status update linked
2838 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
2839 * </tr>
2840 * <tr>
2841 * <td>long</td>
2842 * <td>{@link #STATUS_ICON}</td>
2843 * <td>read-only</td>
2844 * <td>The resource ID of the icon for the source of the status update linked
2845 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
2846 * </tr>
2847 * </table>
2848 *
2849 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08002850 * Some columns from the associated raw contact are also available through an
2851 * implicit join. The other columns are excluded as uninteresting in this
2852 * context.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002853 * </p>
2854 *
2855 * <table class="jd-sumtable">
2856 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08002857 * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002858 * </tr>
2859 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08002860 * <td style="width: 7em;">long</td>
2861 * <td style="width: 20em;">{@link #CONTACT_ID}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002862 * <td style="width: 5em;">read-only</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08002863 * <td>The id of the row in the {@link Contacts} table that this data belongs
2864 * to.</td>
2865 * </tr>
2866 * <tr>
2867 * <td>int</td>
2868 * <td>{@link #AGGREGATION_MODE}</td>
2869 * <td>read-only</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002870 * <td>See {@link RawContacts}.</td>
2871 * </tr>
2872 * <tr>
2873 * <td>int</td>
2874 * <td>{@link #DELETED}</td>
2875 * <td>read-only</td>
2876 * <td>See {@link RawContacts}.</td>
2877 * </tr>
2878 * </table>
2879 *
2880 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08002881 * The ID column for the associated aggregated contact table
2882 * {@link ContactsContract.Contacts} is available
2883 * via the implicit join to the {@link RawContacts} table, see above.
2884 * The remaining columns from this table are also
2885 * available, through an implicit join. This
2886 * facilitates lookup by
2887 * the value of a single data element, such as the email address.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002888 * </p>
2889 *
2890 * <table class="jd-sumtable">
2891 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08002892 * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002893 * </tr>
2894 * <tr>
2895 * <td style="width: 7em;">String</td>
2896 * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
2897 * <td style="width: 5em;">read-only</td>
2898 * <td>See {@link ContactsContract.Contacts}</td>
2899 * </tr>
2900 * <tr>
2901 * <td>String</td>
2902 * <td>{@link #DISPLAY_NAME}</td>
2903 * <td>read-only</td>
2904 * <td>See {@link ContactsContract.Contacts}</td>
2905 * </tr>
2906 * <tr>
2907 * <td>long</td>
2908 * <td>{@link #PHOTO_ID}</td>
2909 * <td>read-only</td>
2910 * <td>See {@link ContactsContract.Contacts}.</td>
2911 * </tr>
2912 * <tr>
2913 * <td>int</td>
2914 * <td>{@link #IN_VISIBLE_GROUP}</td>
2915 * <td>read-only</td>
2916 * <td>See {@link ContactsContract.Contacts}.</td>
2917 * </tr>
2918 * <tr>
2919 * <td>int</td>
2920 * <td>{@link #HAS_PHONE_NUMBER}</td>
2921 * <td>read-only</td>
2922 * <td>See {@link ContactsContract.Contacts}.</td>
2923 * </tr>
2924 * <tr>
2925 * <td>int</td>
2926 * <td>{@link #TIMES_CONTACTED}</td>
2927 * <td>read-only</td>
2928 * <td>See {@link ContactsContract.Contacts}.</td>
2929 * </tr>
2930 * <tr>
2931 * <td>long</td>
2932 * <td>{@link #LAST_TIME_CONTACTED}</td>
2933 * <td>read-only</td>
2934 * <td>See {@link ContactsContract.Contacts}.</td>
2935 * </tr>
2936 * <tr>
2937 * <td>int</td>
2938 * <td>{@link #STARRED}</td>
2939 * <td>read-only</td>
2940 * <td>See {@link ContactsContract.Contacts}.</td>
2941 * </tr>
2942 * <tr>
2943 * <td>String</td>
2944 * <td>{@link #CUSTOM_RINGTONE}</td>
2945 * <td>read-only</td>
2946 * <td>See {@link ContactsContract.Contacts}.</td>
2947 * </tr>
2948 * <tr>
2949 * <td>int</td>
2950 * <td>{@link #SEND_TO_VOICEMAIL}</td>
2951 * <td>read-only</td>
2952 * <td>See {@link ContactsContract.Contacts}.</td>
2953 * </tr>
2954 * <tr>
2955 * <td>int</td>
2956 * <td>{@link #CONTACT_PRESENCE}</td>
2957 * <td>read-only</td>
2958 * <td>See {@link ContactsContract.Contacts}.</td>
2959 * </tr>
2960 * <tr>
2961 * <td>String</td>
2962 * <td>{@link #CONTACT_STATUS}</td>
2963 * <td>read-only</td>
2964 * <td>See {@link ContactsContract.Contacts}.</td>
2965 * </tr>
2966 * <tr>
2967 * <td>long</td>
2968 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
2969 * <td>read-only</td>
2970 * <td>See {@link ContactsContract.Contacts}.</td>
2971 * </tr>
2972 * <tr>
2973 * <td>String</td>
2974 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
2975 * <td>read-only</td>
2976 * <td>See {@link ContactsContract.Contacts}.</td>
2977 * </tr>
2978 * <tr>
2979 * <td>long</td>
2980 * <td>{@link #CONTACT_STATUS_LABEL}</td>
2981 * <td>read-only</td>
2982 * <td>See {@link ContactsContract.Contacts}.</td>
2983 * </tr>
2984 * <tr>
2985 * <td>long</td>
2986 * <td>{@link #CONTACT_STATUS_ICON}</td>
2987 * <td>read-only</td>
2988 * <td>See {@link ContactsContract.Contacts}.</td>
2989 * </tr>
2990 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07002991 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07002992 public final static class Data implements DataColumnsWithJoins {
Evan Millar088b2912009-05-28 15:24:37 -07002993 /**
2994 * This utility class cannot be instantiated
2995 */
2996 private Data() {}
2997
2998 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08002999 * The content:// style URI for this table, which requests a directory
3000 * of data rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07003001 */
3002 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
3003
3004 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08003005 * The MIME type of the results from {@link #CONTENT_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07003006 */
3007 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07003008
3009 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08003010 * <p>
Daisuke Miyakawaf2e0d7b2009-09-28 06:28:26 -07003011 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
3012 * Data.CONTENT_URI contains only exportable data.
Tom O'Neill244327e22010-01-08 11:11:15 -08003013 * </p>
3014 * <p>
Daisuke Miyakawaf2e0d7b2009-09-28 06:28:26 -07003015 * This flag is useful (currently) only for vCard exporter in Contacts app, which
3016 * needs to exclude "un-exportable" data from available data to export, while
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003017 * Contacts app itself has priviledge to access all data including "un-exportable"
Daisuke Miyakawaf2e0d7b2009-09-28 06:28:26 -07003018 * ones and providers return all of them regardless of the callers' intention.
Tom O'Neill244327e22010-01-08 11:11:15 -08003019 * </p>
3020 * <p>
3021 * Type: INTEGER
3022 * </p>
Daisuke Miyakawaf2e0d7b2009-09-28 06:28:26 -07003023 *
3024 * @hide Maybe available only in Eclair and not really ready for public use.
3025 * TODO: remove, or implement this feature completely. As of now (Eclair),
3026 * we only use this flag in queryEntities(), not query().
3027 */
3028 public static final String FOR_EXPORT_ONLY = "for_export_only";
3029
3030 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08003031 * <p>
Jeff Hamiltonf8526982009-09-24 11:34:58 -05003032 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
3033 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003034 * entry of the given {@link ContactsContract.Data} entry.
Tom O'Neill244327e22010-01-08 11:11:15 -08003035 * </p>
3036 * <p>
3037 * Returns the Uri for the contact in the first entry returned by
3038 * {@link ContentResolver#query(Uri, String[], String, String[], String)}
3039 * for the provided {@code dataUri}. If the query returns null or empty
3040 * results, silently returns null.
3041 * </p>
Jeff Sharkey6449eb02009-09-16 21:41:51 -07003042 */
3043 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
3044 final Cursor cursor = resolver.query(dataUri, new String[] {
3045 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
3046 }, null, null, null);
3047
3048 Uri lookupUri = null;
3049 try {
3050 if (cursor != null && cursor.moveToFirst()) {
3051 final long contactId = cursor.getLong(0);
3052 final String lookupKey = cursor.getString(1);
3053 return Contacts.getLookupUri(contactId, lookupKey);
3054 }
3055 } finally {
3056 if (cursor != null) cursor.close();
3057 }
3058 return lookupUri;
3059 }
Evan Millar088b2912009-05-28 15:24:37 -07003060 }
3061
Fred Quintana5bba6322009-10-05 14:21:12 -07003062 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003063 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08003064 * Constants for the raw contacts entities table, which can be thought of as
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003065 * an outer join of the raw_contacts table with the data table. It is a strictly
3066 * read-only table.
3067 * </p>
3068 * <p>
3069 * If a raw contact has data rows, the RawContactsEntity cursor will contain
3070 * a one row for each data row. If the raw contact has no data rows, the
3071 * cursor will still contain one row with the raw contact-level information
3072 * and nulls for data columns.
3073 *
3074 * <pre>
3075 * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
3076 * Cursor c = getContentResolver().query(entityUri,
3077 * new String[]{
3078 * RawContactsEntity.SOURCE_ID,
3079 * RawContactsEntity.DATA_ID,
3080 * RawContactsEntity.MIMETYPE,
3081 * RawContactsEntity.DATA1
3082 * }, null, null, null);
3083 * try {
3084 * while (c.moveToNext()) {
3085 * String sourceId = c.getString(0);
3086 * if (!c.isNull(1)) {
3087 * String mimeType = c.getString(2);
3088 * String data = c.getString(3);
3089 * ...
3090 * }
3091 * }
3092 * } finally {
3093 * c.close();
3094 * }
3095 * </pre>
3096 *
3097 * <h3>Columns</h3>
3098 * RawContactsEntity has a combination of RawContact and Data columns.
3099 *
3100 * <table class="jd-sumtable">
3101 * <tr>
3102 * <th colspan='4'>RawContacts</th>
3103 * </tr>
3104 * <tr>
3105 * <td style="width: 7em;">long</td>
3106 * <td style="width: 20em;">{@link #_ID}</td>
3107 * <td style="width: 5em;">read-only</td>
3108 * <td>Raw contact row ID. See {@link RawContacts}.</td>
3109 * </tr>
3110 * <tr>
3111 * <td>long</td>
3112 * <td>{@link #CONTACT_ID}</td>
3113 * <td>read-only</td>
3114 * <td>See {@link RawContacts}.</td>
3115 * </tr>
3116 * <tr>
3117 * <td>int</td>
3118 * <td>{@link #AGGREGATION_MODE}</td>
3119 * <td>read-only</td>
3120 * <td>See {@link RawContacts}.</td>
3121 * </tr>
3122 * <tr>
3123 * <td>int</td>
3124 * <td>{@link #DELETED}</td>
3125 * <td>read-only</td>
3126 * <td>See {@link RawContacts}.</td>
3127 * </tr>
3128 * </table>
3129 *
3130 * <table class="jd-sumtable">
3131 * <tr>
3132 * <th colspan='4'>Data</th>
3133 * </tr>
3134 * <tr>
3135 * <td style="width: 7em;">long</td>
3136 * <td style="width: 20em;">{@link #DATA_ID}</td>
3137 * <td style="width: 5em;">read-only</td>
3138 * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
3139 * </tr>
3140 * <tr>
3141 * <td>String</td>
3142 * <td>{@link #MIMETYPE}</td>
3143 * <td>read-only</td>
3144 * <td>See {@link ContactsContract.Data}.</td>
3145 * </tr>
3146 * <tr>
3147 * <td>int</td>
3148 * <td>{@link #IS_PRIMARY}</td>
3149 * <td>read-only</td>
3150 * <td>See {@link ContactsContract.Data}.</td>
3151 * </tr>
3152 * <tr>
3153 * <td>int</td>
3154 * <td>{@link #IS_SUPER_PRIMARY}</td>
3155 * <td>read-only</td>
3156 * <td>See {@link ContactsContract.Data}.</td>
3157 * </tr>
3158 * <tr>
3159 * <td>int</td>
3160 * <td>{@link #DATA_VERSION}</td>
3161 * <td>read-only</td>
3162 * <td>See {@link ContactsContract.Data}.</td>
3163 * </tr>
3164 * <tr>
3165 * <td>Any type</td>
3166 * <td>
3167 * {@link #DATA1}<br>
3168 * {@link #DATA2}<br>
3169 * {@link #DATA3}<br>
3170 * {@link #DATA4}<br>
3171 * {@link #DATA5}<br>
3172 * {@link #DATA6}<br>
3173 * {@link #DATA7}<br>
3174 * {@link #DATA8}<br>
3175 * {@link #DATA9}<br>
3176 * {@link #DATA10}<br>
3177 * {@link #DATA11}<br>
3178 * {@link #DATA12}<br>
3179 * {@link #DATA13}<br>
3180 * {@link #DATA14}<br>
3181 * {@link #DATA15}
3182 * </td>
3183 * <td>read-only</td>
3184 * <td>See {@link ContactsContract.Data}.</td>
3185 * </tr>
3186 * <tr>
3187 * <td>Any type</td>
3188 * <td>
3189 * {@link #SYNC1}<br>
3190 * {@link #SYNC2}<br>
3191 * {@link #SYNC3}<br>
3192 * {@link #SYNC4}
3193 * </td>
3194 * <td>read-only</td>
3195 * <td>See {@link ContactsContract.Data}.</td>
3196 * </tr>
3197 * </table>
Fred Quintana5bba6322009-10-05 14:21:12 -07003198 */
3199 public final static class RawContactsEntity
3200 implements BaseColumns, DataColumns, RawContactsColumns {
3201 /**
3202 * This utility class cannot be instantiated
3203 */
3204 private RawContactsEntity() {}
3205
3206 /**
3207 * The content:// style URI for this table
3208 */
3209 public static final Uri CONTENT_URI =
3210 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
3211
3212 /**
3213 * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
3214 */
3215 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
3216
3217 /**
3218 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
3219 * Data.CONTENT_URI contains only exportable data.
3220 *
3221 * This flag is useful (currently) only for vCard exporter in Contacts app, which
3222 * needs to exclude "un-exportable" data from available data to export, while
3223 * Contacts app itself has priviledge to access all data including "un-expotable"
3224 * ones and providers return all of them regardless of the callers' intention.
3225 * <P>Type: INTEGER</p>
3226 *
3227 * @hide Maybe available only in Eclair and not really ready for public use.
3228 * TODO: remove, or implement this feature completely. As of now (Eclair),
3229 * we only use this flag in queryEntities(), not query().
3230 */
3231 public static final String FOR_EXPORT_ONLY = "for_export_only";
3232
3233 /**
3234 * The ID of the data column. The value will be null if this raw contact has no data rows.
3235 * <P>Type: INTEGER</P>
3236 */
3237 public static final String DATA_ID = "data_id";
3238 }
3239
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003240 /**
3241 * @see PhoneLookup
3242 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07003243 protected interface PhoneLookupColumns {
Dmitri Plotnikov93032952009-08-19 11:26:57 -07003244 /**
3245 * The phone number as the user entered it.
3246 * <P>Type: TEXT</P>
3247 */
3248 public static final String NUMBER = "number";
3249
3250 /**
3251 * The type of phone number, for example Home or Work.
3252 * <P>Type: INTEGER</P>
3253 */
3254 public static final String TYPE = "type";
3255
3256 /**
3257 * The user defined label for the phone number.
3258 * <P>Type: TEXT</P>
3259 */
3260 public static final String LABEL = "label";
3261 }
3262
Evan Millar088b2912009-05-28 15:24:37 -07003263 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003264 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -07003265 * example for caller ID. To perform a lookup you must append the number you
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003266 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly
3267 * optimized.
3268 * <pre>
3269 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
3270 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
3271 * </pre>
3272 *
3273 * <h3>Columns</h3>
3274 *
3275 * <table class="jd-sumtable">
3276 * <tr>
3277 * <th colspan='4'>PhoneLookup</th>
3278 * </tr>
3279 * <tr>
3280 * <td>long</td>
3281 * <td>{@link #_ID}</td>
3282 * <td>read-only</td>
3283 * <td>Data row ID.</td>
3284 * </tr>
3285 * <tr>
3286 * <td>String</td>
3287 * <td>{@link #NUMBER}</td>
3288 * <td>read-only</td>
3289 * <td>Phone number.</td>
3290 * </tr>
3291 * <tr>
3292 * <td>String</td>
3293 * <td>{@link #TYPE}</td>
3294 * <td>read-only</td>
3295 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
3296 * </tr>
3297 * <tr>
3298 * <td>String</td>
3299 * <td>{@link #LABEL}</td>
3300 * <td>read-only</td>
3301 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
3302 * </tr>
3303 * </table>
3304 * <p>
3305 * Columns from the Contacts table are also available through a join.
3306 * </p>
3307 * <table class="jd-sumtable">
3308 * <tr>
3309 * <th colspan='4'>Join with {@link Contacts}</th>
3310 * </tr>
3311 * <tr>
3312 * <td>String</td>
3313 * <td>{@link #LOOKUP_KEY}</td>
3314 * <td>read-only</td>
3315 * <td>See {@link ContactsContract.Contacts}</td>
3316 * </tr>
3317 * <tr>
3318 * <td>String</td>
3319 * <td>{@link #DISPLAY_NAME}</td>
3320 * <td>read-only</td>
3321 * <td>See {@link ContactsContract.Contacts}</td>
3322 * </tr>
3323 * <tr>
3324 * <td>long</td>
3325 * <td>{@link #PHOTO_ID}</td>
3326 * <td>read-only</td>
3327 * <td>See {@link ContactsContract.Contacts}.</td>
3328 * </tr>
3329 * <tr>
3330 * <td>int</td>
3331 * <td>{@link #IN_VISIBLE_GROUP}</td>
3332 * <td>read-only</td>
3333 * <td>See {@link ContactsContract.Contacts}.</td>
3334 * </tr>
3335 * <tr>
3336 * <td>int</td>
3337 * <td>{@link #HAS_PHONE_NUMBER}</td>
3338 * <td>read-only</td>
3339 * <td>See {@link ContactsContract.Contacts}.</td>
3340 * </tr>
3341 * <tr>
3342 * <td>int</td>
3343 * <td>{@link #TIMES_CONTACTED}</td>
3344 * <td>read-only</td>
3345 * <td>See {@link ContactsContract.Contacts}.</td>
3346 * </tr>
3347 * <tr>
3348 * <td>long</td>
3349 * <td>{@link #LAST_TIME_CONTACTED}</td>
3350 * <td>read-only</td>
3351 * <td>See {@link ContactsContract.Contacts}.</td>
3352 * </tr>
3353 * <tr>
3354 * <td>int</td>
3355 * <td>{@link #STARRED}</td>
3356 * <td>read-only</td>
3357 * <td>See {@link ContactsContract.Contacts}.</td>
3358 * </tr>
3359 * <tr>
3360 * <td>String</td>
3361 * <td>{@link #CUSTOM_RINGTONE}</td>
3362 * <td>read-only</td>
3363 * <td>See {@link ContactsContract.Contacts}.</td>
3364 * </tr>
3365 * <tr>
3366 * <td>int</td>
3367 * <td>{@link #SEND_TO_VOICEMAIL}</td>
3368 * <td>read-only</td>
3369 * <td>See {@link ContactsContract.Contacts}.</td>
3370 * </tr>
3371 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07003372 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -07003373 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
3374 ContactsColumns, ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -07003375 /**
3376 * This utility class cannot be instantiated
3377 */
3378 private PhoneLookup() {}
3379
3380 /**
3381 * The content:// style URI for this table. Append the phone number you want to lookup
3382 * to this URI and query it to perform a lookup. For example:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003383 * <pre>
3384 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, Uri.encode(phoneNumber));
3385 * </pre>
Evan Millar088b2912009-05-28 15:24:37 -07003386 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003387 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
3388 "phone_lookup");
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08003389
3390 /**
3391 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows.
3392 *
3393 * @hide
3394 */
3395 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003396 }
3397
3398 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003399 * Additional data mixed in with {@link StatusColumns} to link
3400 * back to specific {@link ContactsContract.Data#_ID} entries.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003401 *
3402 * @see StatusUpdates
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003403 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07003404 protected interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -07003405
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003406 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003407 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003408 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003409 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07003410 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003411
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003412 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003413 * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07003414 * <p>Type: NUMBER</p>
3415 */
3416 public static final String PROTOCOL = "protocol";
3417
3418 /**
3419 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
3420 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
3421 * omitted if {@link #PROTOCOL} value is not
3422 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
3423 *
3424 * <p>Type: NUMBER</p>
3425 */
3426 public static final String CUSTOM_PROTOCOL = "custom_protocol";
3427
3428 /**
3429 * The IM handle the presence item is for. The handle is scoped to
3430 * {@link #PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003431 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003432 */
3433 public static final String IM_HANDLE = "im_handle";
3434
3435 /**
3436 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003437 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003438 */
3439 public static final String IM_ACCOUNT = "im_account";
3440 }
3441
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003442 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003443 * <p>
3444 * A status update is linked to a {@link ContactsContract.Data} row and captures
3445 * the user's latest status update via the corresponding source, e.g.
3446 * "Having lunch" via "Google Talk".
3447 * </p>
3448 * <p>
3449 * There are two ways a status update can be inserted: by explicitly linking
3450 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
3451 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
3452 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use
3453 * either.
3454 * </p>
3455 * <p>
3456 * You cannot use {@link ContentResolver#update} to change a status, but
3457 * {@link ContentResolver#insert} will replace the latests status if it already
3458 * exists.
3459 * </p>
3460 * <p>
3461 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
3462 * for multiple contacts at once.
3463 * </p>
3464 *
3465 * <h3>Columns</h3>
3466 * <table class="jd-sumtable">
3467 * <tr>
3468 * <th colspan='4'>StatusUpdates</th>
3469 * </tr>
3470 * <tr>
3471 * <td>long</td>
3472 * <td>{@link #DATA_ID}</td>
3473 * <td>read/write</td>
3474 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
3475 * field is <i>not</i> specified, the provider will attempt to find a data row
3476 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
3477 * {@link #IM_HANDLE} columns.
3478 * </td>
3479 * </tr>
3480 * <tr>
3481 * <td>long</td>
3482 * <td>{@link #PROTOCOL}</td>
3483 * <td>read/write</td>
3484 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
3485 * </tr>
3486 * <tr>
3487 * <td>String</td>
3488 * <td>{@link #CUSTOM_PROTOCOL}</td>
3489 * <td>read/write</td>
3490 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
3491 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
3492 * omitted if {@link #PROTOCOL} value is not
3493 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
3494 * </tr>
3495 * <tr>
3496 * <td>String</td>
3497 * <td>{@link #IM_HANDLE}</td>
3498 * <td>read/write</td>
3499 * <td> The IM handle the presence item is for. The handle is scoped to
3500 * {@link #PROTOCOL}.</td>
3501 * </tr>
3502 * <tr>
3503 * <td>String</td>
3504 * <td>{@link #IM_ACCOUNT}</td>
3505 * <td>read/write</td>
3506 * <td>The IM account for the local user that the presence data came from.</td>
3507 * </tr>
3508 * <tr>
3509 * <td>int</td>
3510 * <td>{@link #PRESENCE}</td>
3511 * <td>read/write</td>
3512 * <td>Contact IM presence status. The allowed values are:
3513 * <p>
3514 * <ul>
3515 * <li>{@link #OFFLINE}</li>
3516 * <li>{@link #INVISIBLE}</li>
3517 * <li>{@link #AWAY}</li>
3518 * <li>{@link #IDLE}</li>
3519 * <li>{@link #DO_NOT_DISTURB}</li>
3520 * <li>{@link #AVAILABLE}</li>
3521 * </ul>
3522 * </p>
3523 * <p>
3524 * Since presence status is inherently volatile, the content provider
3525 * may choose not to store this field in long-term storage.
3526 * </p>
3527 * </td>
3528 * </tr>
3529 * <tr>
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003530 * <td>int</td>
3531 * <td>{@link #CHAT_CAPABILITY}</td>
3532 * <td>read/write</td>
3533 * <td>Contact IM chat compatibility value. The allowed values are:
3534 * <p>
3535 * <ul>
3536 * <li>{@link #CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY}</li>
3537 * <li>{@link #CAPABILITY_HAS_VOICE}</li>
3538 * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
3539 * </ul>
3540 * </p>
3541 * <p>
3542 * Since chat compatibility is inherently volatile as the contact's availability moves from
3543 * one device to another, the content provider may choose not to store this field in long-term
3544 * storage.
3545 * </p>
3546 * </td>
3547 * </tr>
3548 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003549 * <td>String</td>
3550 * <td>{@link #STATUS}</td>
3551 * <td>read/write</td>
3552 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
3553 * </tr>
3554 * <tr>
3555 * <td>long</td>
3556 * <td>{@link #STATUS_TIMESTAMP}</td>
3557 * <td>read/write</td>
3558 * <td>The absolute time in milliseconds when the status was
3559 * entered by the user. If this value is not provided, the provider will follow
3560 * this logic: if there was no prior status update, the value will be left as null.
3561 * If there was a prior status update, the provider will default this field
3562 * to the current time.</td>
3563 * </tr>
3564 * <tr>
3565 * <td>String</td>
3566 * <td>{@link #STATUS_RES_PACKAGE}</td>
3567 * <td>read/write</td>
3568 * <td> The package containing resources for this status: label and icon.</td>
3569 * </tr>
3570 * <tr>
3571 * <td>long</td>
3572 * <td>{@link #STATUS_LABEL}</td>
3573 * <td>read/write</td>
3574 * <td>The resource ID of the label describing the source of contact status,
3575 * e.g. "Google Talk". This resource is scoped by the
3576 * {@link #STATUS_RES_PACKAGE}.</td>
3577 * </tr>
3578 * <tr>
3579 * <td>long</td>
3580 * <td>{@link #STATUS_ICON}</td>
3581 * <td>read/write</td>
3582 * <td>The resource ID of the icon for the source of contact status. This
3583 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
3584 * </tr>
3585 * </table>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003586 */
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003587 public static class StatusUpdates implements StatusColumns, PresenceColumns {
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07003588
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003589 /**
3590 * This utility class cannot be instantiated
3591 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003592 private StatusUpdates() {}
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003593
3594 /**
3595 * The content:// style URI for this table
3596 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003597 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
Jeff Hamilton85abdc52009-09-22 12:41:45 -05003598
3599 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003600 * Gets the resource ID for the proper presence icon.
3601 *
3602 * @param status the status to get the icon for
3603 * @return the resource ID for the proper presence icon
3604 */
3605 public static final int getPresenceIconResourceId(int status) {
3606 switch (status) {
3607 case AVAILABLE:
3608 return android.R.drawable.presence_online;
3609 case IDLE:
3610 case AWAY:
3611 return android.R.drawable.presence_away;
3612 case DO_NOT_DISTURB:
3613 return android.R.drawable.presence_busy;
3614 case INVISIBLE:
3615 return android.R.drawable.presence_invisible;
3616 case OFFLINE:
3617 default:
3618 return android.R.drawable.presence_offline;
3619 }
3620 }
3621
3622 /**
Evan Millarc0437522009-06-23 17:31:05 -07003623 * Returns the precedence of the status code the higher number being the higher precedence.
3624 *
3625 * @param status The status code.
3626 * @return An integer representing the precedence, 0 being the lowest.
3627 */
3628 public static final int getPresencePrecedence(int status) {
3629 // Keep this function here incase we want to enforce a different precedence than the
3630 // natural order of the status constants.
3631 return status;
3632 }
3633
3634 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003635 * The MIME type of {@link #CONTENT_URI} providing a directory of
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003636 * status update details.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003637 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003638 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003639
3640 /**
3641 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003642 * status update detail.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07003643 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003644 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
3645 }
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07003646
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003647 /**
3648 * @deprecated This old name was never meant to be made public. Do not use.
3649 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003650 @Deprecated
3651 public static final class Presence extends StatusUpdates {
3652
Evan Millar088b2912009-05-28 15:24:37 -07003653 }
3654
3655 /**
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08003656 * Additional columns returned by the {@link Contacts#CONTENT_FILTER_URI} providing the
3657 * explanation of why the filter matched the contact. Specifically, they contain the
3658 * data type and element that was used for matching.
3659 * <p>
3660 * This is temporary API, it will need to change when we move to FTS.
3661 *
3662 * @hide
3663 */
3664 public static class SearchSnippetColumns {
3665
3666 /**
3667 * The ID of the data row that was matched by the filter.
3668 *
3669 * @hide
3670 */
3671 public static final String SNIPPET_DATA_ID = "snippet_data_id";
3672
3673 /**
3674 * The type of data that was matched by the filter.
3675 *
3676 * @hide
3677 */
3678 public static final String SNIPPET_MIMETYPE = "snippet_mimetype";
3679
3680 /**
Dmitri Plotnikovda2572a2010-02-25 16:09:21 -08003681 * The {@link Data#DATA1} field of the data row that was matched by the filter.
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08003682 *
3683 * @hide
3684 */
Dmitri Plotnikovda2572a2010-02-25 16:09:21 -08003685 public static final String SNIPPET_DATA1 = "snippet_data1";
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08003686
3687 /**
Dmitri Plotnikovda2572a2010-02-25 16:09:21 -08003688 * The {@link Data#DATA2} field of the data row that was matched by the filter.
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08003689 *
3690 * @hide
3691 */
Dmitri Plotnikovda2572a2010-02-25 16:09:21 -08003692 public static final String SNIPPET_DATA2 = "snippet_data2";
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08003693
3694 /**
Dmitri Plotnikovda2572a2010-02-25 16:09:21 -08003695 * The {@link Data#DATA3} field of the data row that was matched by the filter.
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08003696 *
3697 * @hide
3698 */
Dmitri Plotnikovda2572a2010-02-25 16:09:21 -08003699 public static final String SNIPPET_DATA3 = "snippet_data3";
3700
3701 /**
3702 * The {@link Data#DATA4} field of the data row that was matched by the filter.
3703 *
3704 * @hide
3705 */
3706 public static final String SNIPPET_DATA4 = "snippet_data4";
3707
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08003708 }
3709
3710 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003711 * Container for definitions of common data types stored in the {@link ContactsContract.Data}
3712 * table.
Evan Millar088b2912009-05-28 15:24:37 -07003713 */
3714 public static final class CommonDataKinds {
3715 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05003716 * This utility class cannot be instantiated
3717 */
3718 private CommonDataKinds() {}
3719
3720 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003721 * The {@link Data#RES_PACKAGE} value for common data that should be
3722 * shown using a default style.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05003723 *
3724 * @hide RES_PACKAGE is hidden
Evan Millar088b2912009-05-28 15:24:37 -07003725 */
3726 public static final String PACKAGE_COMMON = "common";
3727
3728 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07003729 * The base types that all "Typed" data kinds support.
3730 */
3731 public interface BaseTypes {
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07003732 /**
3733 * A custom type. The custom label should be supplied by user.
3734 */
3735 public static int TYPE_CUSTOM = 0;
3736 }
3737
3738 /**
Evan Millar088b2912009-05-28 15:24:37 -07003739 * Columns common across the specific types.
3740 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07003741 protected interface CommonColumns extends BaseTypes {
Evan Millar088b2912009-05-28 15:24:37 -07003742 /**
Evan Millar088b2912009-05-28 15:24:37 -07003743 * The data for the contact method.
3744 * <P>Type: TEXT</P>
3745 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07003746 public static final String DATA = DataColumns.DATA1;
3747
3748 /**
3749 * The type of data, for example Home or Work.
3750 * <P>Type: INTEGER</P>
3751 */
3752 public static final String TYPE = DataColumns.DATA2;
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07003753
3754 /**
3755 * The user defined label for the the contact method.
3756 * <P>Type: TEXT</P>
3757 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07003758 public static final String LABEL = DataColumns.DATA3;
Evan Millar088b2912009-05-28 15:24:37 -07003759 }
3760
3761 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003762 * A data kind representing the contact's proper name. You can use all
3763 * columns defined for {@link ContactsContract.Data} as well as the following aliases.
3764 *
3765 * <h2>Column aliases</h2>
3766 * <table class="jd-sumtable">
3767 * <tr>
3768 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
3769 * </tr>
3770 * <tr>
3771 * <td>String</td>
3772 * <td>{@link #DISPLAY_NAME}</td>
3773 * <td>{@link #DATA1}</td>
3774 * <td></td>
3775 * </tr>
3776 * <tr>
3777 * <td>String</td>
3778 * <td>{@link #GIVEN_NAME}</td>
3779 * <td>{@link #DATA2}</td>
3780 * <td></td>
3781 * </tr>
3782 * <tr>
3783 * <td>String</td>
3784 * <td>{@link #FAMILY_NAME}</td>
3785 * <td>{@link #DATA3}</td>
3786 * <td></td>
3787 * </tr>
3788 * <tr>
3789 * <td>String</td>
3790 * <td>{@link #PREFIX}</td>
3791 * <td>{@link #DATA4}</td>
3792 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
3793 * </tr>
3794 * <tr>
3795 * <td>String</td>
3796 * <td>{@link #MIDDLE_NAME}</td>
3797 * <td>{@link #DATA5}</td>
3798 * <td></td>
3799 * </tr>
3800 * <tr>
3801 * <td>String</td>
3802 * <td>{@link #SUFFIX}</td>
3803 * <td>{@link #DATA6}</td>
3804 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
3805 * </tr>
3806 * <tr>
3807 * <td>String</td>
3808 * <td>{@link #PHONETIC_GIVEN_NAME}</td>
3809 * <td>{@link #DATA7}</td>
3810 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
3811 * </tr>
3812 * <tr>
3813 * <td>String</td>
3814 * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
3815 * <td>{@link #DATA8}</td>
3816 * <td></td>
3817 * </tr>
3818 * <tr>
3819 * <td>String</td>
3820 * <td>{@link #PHONETIC_FAMILY_NAME}</td>
3821 * <td>{@link #DATA9}</td>
3822 * <td></td>
3823 * </tr>
3824 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07003825 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07003826 public static final class StructuredName implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05003827 /**
3828 * This utility class cannot be instantiated
3829 */
Evan Millar088b2912009-05-28 15:24:37 -07003830 private StructuredName() {}
3831
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003832 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07003833 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
3834
3835 /**
Evan Millar088b2912009-05-28 15:24:37 -07003836 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -07003837 * <i>Unstructured component of the name should be consistent with
3838 * its structured representation.</i>
3839 * <p>
3840 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -07003841 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07003842 public static final String DISPLAY_NAME = DATA1;
3843
3844 /**
3845 * The given name for the contact.
3846 * <P>Type: TEXT</P>
3847 */
3848 public static final String GIVEN_NAME = DATA2;
3849
3850 /**
3851 * The family name for the contact.
3852 * <P>Type: TEXT</P>
3853 */
3854 public static final String FAMILY_NAME = DATA3;
3855
3856 /**
3857 * The contact's honorific prefix, e.g. "Sir"
3858 * <P>Type: TEXT</P>
3859 */
3860 public static final String PREFIX = DATA4;
3861
3862 /**
3863 * The contact's middle name
3864 * <P>Type: TEXT</P>
3865 */
3866 public static final String MIDDLE_NAME = DATA5;
3867
3868 /**
3869 * The contact's honorific suffix, e.g. "Jr"
3870 */
3871 public static final String SUFFIX = DATA6;
3872
3873 /**
3874 * The phonetic version of the given name for the contact.
3875 * <P>Type: TEXT</P>
3876 */
3877 public static final String PHONETIC_GIVEN_NAME = DATA7;
3878
3879 /**
3880 * The phonetic version of the additional name for the contact.
3881 * <P>Type: TEXT</P>
3882 */
3883 public static final String PHONETIC_MIDDLE_NAME = DATA8;
3884
3885 /**
3886 * The phonetic version of the family name for the contact.
3887 * <P>Type: TEXT</P>
3888 */
3889 public static final String PHONETIC_FAMILY_NAME = DATA9;
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08003890
3891 /**
3892 * The style used for combining given/middle/family name into a full name.
3893 * See {@link ContactsContract.FullNameStyle}.
3894 *
3895 * @hide
3896 */
3897 public static final String FULL_NAME_STYLE = DATA10;
3898
3899 /**
3900 * The alphabet used for capturing the phonetic name.
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08003901 * See ContactsContract.PhoneticNameStyle.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08003902 * @hide
3903 */
3904 public static final String PHONETIC_NAME_STYLE = DATA11;
Evan Millar088b2912009-05-28 15:24:37 -07003905 }
3906
3907 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003908 * <p>A data kind representing the contact's nickname. For example, for
3909 * Bob Parr ("Mr. Incredible"):
3910 * <pre>
3911 * ArrayList&lt;ContentProviderOperation&gt; ops = Lists.newArrayList();
3912 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
3913 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
3914 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
3915 * .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
3916 * .build());
3917 *
3918 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
3919 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
3920 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
3921 * .withValue(Nickname.NAME, "Mr. Incredible")
3922 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
3923 * .withValue(Nickname.LABEL, "Superhero")
3924 * .build());
3925 *
3926 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
3927 * </pre>
3928 * </p>
3929 * <p>
3930 * You can use all columns defined for {@link ContactsContract.Data} as well as the
3931 * following aliases.
3932 * </p>
3933 *
3934 * <h2>Column aliases</h2>
3935 * <table class="jd-sumtable">
3936 * <tr>
3937 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
3938 * </tr>
3939 * <tr>
3940 * <td>String</td>
3941 * <td>{@link #NAME}</td>
3942 * <td>{@link #DATA1}</td>
3943 * <td></td>
3944 * </tr>
3945 * <tr>
3946 * <td>int</td>
3947 * <td>{@link #TYPE}</td>
3948 * <td>{@link #DATA2}</td>
3949 * <td>
3950 * Allowed values are:
3951 * <p>
3952 * <ul>
3953 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
3954 * <li>{@link #TYPE_DEFAULT}</li>
3955 * <li>{@link #TYPE_OTHER_NAME}</li>
3956 * <li>{@link #TYPE_MAINDEN_NAME}</li>
3957 * <li>{@link #TYPE_SHORT_NAME}</li>
3958 * <li>{@link #TYPE_INITIALS}</li>
3959 * </ul>
3960 * </p>
3961 * </td>
3962 * </tr>
3963 * <tr>
3964 * <td>String</td>
3965 * <td>{@link #LABEL}</td>
3966 * <td>{@link #DATA3}</td>
3967 * <td></td>
3968 * </tr>
3969 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07003970 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07003971 public static final class Nickname implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05003972 /**
3973 * This utility class cannot be instantiated
3974 */
Evan Millar088b2912009-05-28 15:24:37 -07003975 private Nickname() {}
3976
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003977 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07003978 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
3979
Evan Millar78e79ad2009-06-08 10:24:44 -07003980 public static final int TYPE_DEFAULT = 1;
3981 public static final int TYPE_OTHER_NAME = 2;
3982 public static final int TYPE_MAINDEN_NAME = 3;
3983 public static final int TYPE_SHORT_NAME = 4;
3984 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -07003985
3986 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07003987 * The name itself
3988 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07003989 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07003990 }
3991
3992 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003993 * <p>
3994 * A data kind representing a telephone number.
3995 * </p>
3996 * <p>
3997 * You can use all columns defined for {@link ContactsContract.Data} as
3998 * well as the following aliases.
3999 * </p>
4000 * <h2>Column aliases</h2>
4001 * <table class="jd-sumtable">
4002 * <tr>
4003 * <th>Type</th>
4004 * <th>Alias</th><th colspan='2'>Data column</th>
4005 * </tr>
4006 * <tr>
4007 * <td>String</td>
4008 * <td>{@link #NUMBER}</td>
4009 * <td>{@link #DATA1}</td>
4010 * <td></td>
4011 * </tr>
4012 * <tr>
4013 * <td>int</td>
4014 * <td>{@link #TYPE}</td>
4015 * <td>{@link #DATA2}</td>
4016 * <td>Allowed values are:
4017 * <p>
4018 * <ul>
4019 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4020 * <li>{@link #TYPE_HOME}</li>
4021 * <li>{@link #TYPE_MOBILE}</li>
4022 * <li>{@link #TYPE_WORK}</li>
4023 * <li>{@link #TYPE_FAX_WORK}</li>
4024 * <li>{@link #TYPE_FAX_HOME}</li>
4025 * <li>{@link #TYPE_PAGER}</li>
4026 * <li>{@link #TYPE_OTHER}</li>
4027 * <li>{@link #TYPE_CALLBACK}</li>
4028 * <li>{@link #TYPE_CAR}</li>
4029 * <li>{@link #TYPE_COMPANY_MAIN}</li>
4030 * <li>{@link #TYPE_ISDN}</li>
4031 * <li>{@link #TYPE_MAIN}</li>
4032 * <li>{@link #TYPE_OTHER_FAX}</li>
4033 * <li>{@link #TYPE_RADIO}</li>
4034 * <li>{@link #TYPE_TELEX}</li>
4035 * <li>{@link #TYPE_TTY_TDD}</li>
4036 * <li>{@link #TYPE_WORK_MOBILE}</li>
4037 * <li>{@link #TYPE_WORK_PAGER}</li>
4038 * <li>{@link #TYPE_ASSISTANT}</li>
4039 * <li>{@link #TYPE_MMS}</li>
4040 * </ul>
4041 * </p>
4042 * </td>
4043 * </tr>
4044 * <tr>
4045 * <td>String</td>
4046 * <td>{@link #LABEL}</td>
4047 * <td>{@link #DATA3}</td>
4048 * <td></td>
4049 * </tr>
4050 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004051 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004052 public static final class Phone implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05004053 /**
4054 * This utility class cannot be instantiated
4055 */
Evan Millar088b2912009-05-28 15:24:37 -07004056 private Phone() {}
4057
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004058 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07004059 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
Evan Millar088b2912009-05-28 15:24:37 -07004060
Evan Millar161dd862009-06-12 16:02:43 -07004061 /**
4062 * The MIME type of {@link #CONTENT_URI} providing a directory of
4063 * phones.
4064 */
Evan Millarb3c49982009-09-01 11:38:04 -07004065 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
Evan Millar161dd862009-06-12 16:02:43 -07004066
4067 /**
4068 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004069 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004070 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -07004071 */
4072 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
4073 "phones");
4074
4075 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07004076 * The content:// style URL for phone lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004077 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07004078 * to display names as well as phone numbers. The filter argument should be passed
4079 * as an additional path segment after this URI.
Evan Millar161dd862009-06-12 16:02:43 -07004080 */
4081 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
4082 "filter");
4083
Evan Millar088b2912009-05-28 15:24:37 -07004084 public static final int TYPE_HOME = 1;
4085 public static final int TYPE_MOBILE = 2;
4086 public static final int TYPE_WORK = 3;
4087 public static final int TYPE_FAX_WORK = 4;
4088 public static final int TYPE_FAX_HOME = 5;
4089 public static final int TYPE_PAGER = 6;
4090 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -07004091 public static final int TYPE_CALLBACK = 8;
4092 public static final int TYPE_CAR = 9;
4093 public static final int TYPE_COMPANY_MAIN = 10;
4094 public static final int TYPE_ISDN = 11;
4095 public static final int TYPE_MAIN = 12;
4096 public static final int TYPE_OTHER_FAX = 13;
4097 public static final int TYPE_RADIO = 14;
4098 public static final int TYPE_TELEX = 15;
4099 public static final int TYPE_TTY_TDD = 16;
4100 public static final int TYPE_WORK_MOBILE = 17;
4101 public static final int TYPE_WORK_PAGER = 18;
4102 public static final int TYPE_ASSISTANT = 19;
Jeff Sharkeyd5abd462009-09-16 19:54:29 -07004103 public static final int TYPE_MMS = 20;
Evan Millar088b2912009-05-28 15:24:37 -07004104
4105 /**
4106 * The phone number as the user entered it.
4107 * <P>Type: TEXT</P>
4108 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07004109 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004110
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004111 /**
4112 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05004113 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004114 */
4115 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004116 public static final CharSequence getDisplayLabel(Context context, int type,
4117 CharSequence label, CharSequence[] labelArray) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004118 return getTypeLabel(context.getResources(), type, label);
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004119 }
4120
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004121 /**
4122 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05004123 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004124 */
4125 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004126 public static final CharSequence getDisplayLabel(Context context, int type,
4127 CharSequence label) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004128 return getTypeLabel(context.getResources(), type, label);
4129 }
4130
4131 /**
4132 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004133 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004134 */
4135 public static final int getTypeLabelResource(int type) {
4136 switch (type) {
4137 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
4138 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
4139 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
4140 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
4141 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
4142 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
4143 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
4144 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
4145 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
4146 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
4147 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
4148 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
4149 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
4150 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
4151 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
4152 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
4153 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
4154 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
4155 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
4156 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
4157 default: return com.android.internal.R.string.phoneTypeCustom;
4158 }
4159 }
4160
4161 /**
4162 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004163 * possibly substituting the given {@link #LABEL} value
4164 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004165 */
4166 public static final CharSequence getTypeLabel(Resources res, int type,
4167 CharSequence label) {
4168 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
4169 return label;
4170 } else {
4171 final int labelRes = getTypeLabelResource(type);
4172 return res.getText(labelRes);
4173 }
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004174 }
Evan Millar088b2912009-05-28 15:24:37 -07004175 }
4176
4177 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004178 * <p>
4179 * A data kind representing an email address.
4180 * </p>
4181 * <p>
4182 * You can use all columns defined for {@link ContactsContract.Data} as
4183 * well as the following aliases.
4184 * </p>
4185 * <h2>Column aliases</h2>
4186 * <table class="jd-sumtable">
4187 * <tr>
4188 * <th>Type</th>
4189 * <th>Alias</th><th colspan='2'>Data column</th>
4190 * </tr>
4191 * <tr>
4192 * <td>String</td>
4193 * <td>{@link #DATA}</td>
4194 * <td>{@link #DATA1}</td>
4195 * <td>Email address itself.</td>
4196 * </tr>
4197 * <tr>
4198 * <td>int</td>
4199 * <td>{@link #TYPE}</td>
4200 * <td>{@link #DATA2}</td>
4201 * <td>Allowed values are:
4202 * <p>
4203 * <ul>
4204 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4205 * <li>{@link #TYPE_HOME}</li>
4206 * <li>{@link #TYPE_WORK}</li>
4207 * <li>{@link #TYPE_OTHER}</li>
4208 * <li>{@link #TYPE_MOBILE}</li>
4209 * </ul>
4210 * </p>
4211 * </td>
4212 * </tr>
4213 * <tr>
4214 * <td>String</td>
4215 * <td>{@link #LABEL}</td>
4216 * <td>{@link #DATA3}</td>
4217 * <td></td>
4218 * </tr>
4219 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004220 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004221 public static final class Email implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05004222 /**
4223 * This utility class cannot be instantiated
4224 */
Evan Millar088b2912009-05-28 15:24:37 -07004225 private Email() {}
4226
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004227 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07004228 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
Evan Millar088b2912009-05-28 15:24:37 -07004229
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07004230 /**
Dmitri Plotnikovabf15c32009-09-18 20:29:11 -07004231 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
4232 */
4233 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
4234
4235 /**
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07004236 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004237 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07004238 * associated raw contact and aggregate contact data.
4239 */
4240 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
4241 "emails");
4242
4243 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004244 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07004245 * The content:// style URL for looking up data rows by email address. The
4246 * lookup argument, an email address, should be passed as an additional path segment
4247 * after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004248 * </p>
4249 * <p>Example:
4250 * <pre>
4251 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
4252 * Cursor c = getContentResolver().query(uri,
4253 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
4254 * null, null, null);
4255 * </pre>
4256 * </p>
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07004257 */
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07004258 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
4259 "lookup");
4260
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07004261 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004262 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07004263 * The content:// style URL for email lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004264 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07004265 * to display names as well as email addresses. The filter argument should be passed
4266 * as an additional path segment after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004267 * </p>
4268 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)"
4269 * as well as "Bob Parr (incredible@android.com)".
4270 * <pre>
4271 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
4272 * Cursor c = getContentResolver().query(uri,
4273 * new String[]{Email.DISPLAY_NAME, Email.DATA},
4274 * null, null, null);
4275 * </pre>
4276 * </p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07004277 */
4278 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07004279 "filter");
4280
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004281 /**
4282 * The email address.
4283 * <P>Type: TEXT</P>
4284 * @hide TODO: Unhide in a separate CL
4285 */
4286 public static final String ADDRESS = DATA1;
4287
Evan Millar088b2912009-05-28 15:24:37 -07004288 public static final int TYPE_HOME = 1;
4289 public static final int TYPE_WORK = 2;
4290 public static final int TYPE_OTHER = 3;
Jeff Sharkey14fb1532009-08-29 15:54:26 -07004291 public static final int TYPE_MOBILE = 4;
Fred Quintana8851e162009-08-05 21:06:45 -07004292
4293 /**
4294 * The display name for the email address
4295 * <P>Type: TEXT</P>
4296 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004297 public static final String DISPLAY_NAME = DATA4;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004298
4299 /**
4300 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004301 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004302 */
4303 public static final int getTypeLabelResource(int type) {
4304 switch (type) {
4305 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
4306 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
4307 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
4308 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
4309 default: return com.android.internal.R.string.emailTypeCustom;
4310 }
4311 }
4312
4313 /**
4314 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004315 * possibly substituting the given {@link #LABEL} value
4316 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004317 */
4318 public static final CharSequence getTypeLabel(Resources res, int type,
4319 CharSequence label) {
4320 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
4321 return label;
4322 } else {
4323 final int labelRes = getTypeLabelResource(type);
4324 return res.getText(labelRes);
4325 }
4326 }
Evan Millar088b2912009-05-28 15:24:37 -07004327 }
4328
4329 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004330 * <p>
4331 * A data kind representing a postal addresses.
4332 * </p>
4333 * <p>
4334 * You can use all columns defined for {@link ContactsContract.Data} as
4335 * well as the following aliases.
4336 * </p>
4337 * <h2>Column aliases</h2>
4338 * <table class="jd-sumtable">
4339 * <tr>
4340 * <th>Type</th>
4341 * <th>Alias</th><th colspan='2'>Data column</th>
4342 * </tr>
4343 * <tr>
4344 * <td>String</td>
4345 * <td>{@link #FORMATTED_ADDRESS}</td>
4346 * <td>{@link #DATA1}</td>
4347 * <td></td>
4348 * </tr>
4349 * <tr>
4350 * <td>int</td>
4351 * <td>{@link #TYPE}</td>
4352 * <td>{@link #DATA2}</td>
4353 * <td>Allowed values are:
4354 * <p>
4355 * <ul>
4356 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4357 * <li>{@link #TYPE_HOME}</li>
4358 * <li>{@link #TYPE_WORK}</li>
4359 * <li>{@link #TYPE_OTHER}</li>
4360 * </ul>
4361 * </p>
4362 * </td>
4363 * </tr>
4364 * <tr>
4365 * <td>String</td>
4366 * <td>{@link #LABEL}</td>
4367 * <td>{@link #DATA3}</td>
4368 * <td></td>
4369 * </tr>
4370 * <tr>
4371 * <td>String</td>
4372 * <td>{@link #STREET}</td>
4373 * <td>{@link #DATA4}</td>
4374 * <td></td>
4375 * </tr>
4376 * <tr>
4377 * <td>String</td>
4378 * <td>{@link #POBOX}</td>
4379 * <td>{@link #DATA5}</td>
4380 * <td>Post Office Box number</td>
4381 * </tr>
4382 * <tr>
4383 * <td>String</td>
4384 * <td>{@link #NEIGHBORHOOD}</td>
4385 * <td>{@link #DATA6}</td>
4386 * <td></td>
4387 * </tr>
4388 * <tr>
4389 * <td>String</td>
4390 * <td>{@link #CITY}</td>
4391 * <td>{@link #DATA7}</td>
4392 * <td></td>
4393 * </tr>
4394 * <tr>
4395 * <td>String</td>
4396 * <td>{@link #REGION}</td>
4397 * <td>{@link #DATA8}</td>
4398 * <td></td>
4399 * </tr>
4400 * <tr>
4401 * <td>String</td>
4402 * <td>{@link #POSTCODE}</td>
4403 * <td>{@link #DATA9}</td>
4404 * <td></td>
4405 * </tr>
4406 * <tr>
4407 * <td>String</td>
4408 * <td>{@link #COUNTRY}</td>
4409 * <td>{@link #DATA10}</td>
4410 * <td></td>
4411 * </tr>
4412 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004413 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004414 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05004415 /**
4416 * This utility class cannot be instantiated
4417 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004418 private StructuredPostal() {
4419 }
Evan Millar088b2912009-05-28 15:24:37 -07004420
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004421 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07004422 public static final String CONTENT_ITEM_TYPE =
4423 "vnd.android.cursor.item/postal-address_v2";
Evan Millar088b2912009-05-28 15:24:37 -07004424
Evan Millar161dd862009-06-12 16:02:43 -07004425 /**
4426 * The MIME type of {@link #CONTENT_URI} providing a directory of
4427 * postal addresses.
4428 */
Evan Millarb3c49982009-09-01 11:38:04 -07004429 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
Evan Millar161dd862009-06-12 16:02:43 -07004430
4431 /**
4432 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004433 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07004434 */
4435 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
4436 "postals");
4437
Evan Millar088b2912009-05-28 15:24:37 -07004438 public static final int TYPE_HOME = 1;
4439 public static final int TYPE_WORK = 2;
4440 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004441
4442 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07004443 * The full, unstructured postal address. <i>This field must be
4444 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004445 * <p>
4446 * Type: TEXT
4447 */
4448 public static final String FORMATTED_ADDRESS = DATA;
4449
4450 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004451 * Can be street, avenue, road, etc. This element also includes the
4452 * house number and room/apartment/flat/floor number.
4453 * <p>
4454 * Type: TEXT
4455 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004456 public static final String STREET = DATA4;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004457
4458 /**
4459 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
4460 * usually but not always mutually exclusive with street.
4461 * <p>
4462 * Type: TEXT
4463 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004464 public static final String POBOX = DATA5;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004465
4466 /**
4467 * This is used to disambiguate a street address when a city
4468 * contains more than one street with the same name, or to specify a
4469 * small place whose mail is routed through a larger postal town. In
4470 * China it could be a county or a minor city.
4471 * <p>
4472 * Type: TEXT
4473 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004474 public static final String NEIGHBORHOOD = DATA6;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004475
4476 /**
4477 * Can be city, village, town, borough, etc. This is the postal town
4478 * and not necessarily the place of residence or place of business.
4479 * <p>
4480 * Type: TEXT
4481 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004482 public static final String CITY = DATA7;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004483
4484 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004485 * A state, province, county (in Ireland), Land (in Germany),
4486 * departement (in France), etc.
4487 * <p>
4488 * Type: TEXT
4489 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004490 public static final String REGION = DATA8;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004491
4492 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07004493 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004494 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
4495 * <p>
4496 * Type: TEXT
4497 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004498 public static final String POSTCODE = DATA9;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004499
4500 /**
4501 * The name or code of the country.
4502 * <p>
4503 * Type: TEXT
4504 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004505 public static final String COUNTRY = DATA10;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004506
4507 /**
4508 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004509 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004510 */
4511 public static final int getTypeLabelResource(int type) {
4512 switch (type) {
4513 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
4514 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
4515 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
4516 default: return com.android.internal.R.string.postalTypeCustom;
4517 }
4518 }
4519
4520 /**
4521 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004522 * possibly substituting the given {@link #LABEL} value
4523 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004524 */
4525 public static final CharSequence getTypeLabel(Resources res, int type,
4526 CharSequence label) {
4527 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
4528 return label;
4529 } else {
4530 final int labelRes = getTypeLabelResource(type);
4531 return res.getText(labelRes);
4532 }
4533 }
Evan Millar088b2912009-05-28 15:24:37 -07004534 }
4535
Fred Quintana8851e162009-08-05 21:06:45 -07004536 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004537 * <p>
4538 * A data kind representing an IM address
4539 * </p>
4540 * <p>
4541 * You can use all columns defined for {@link ContactsContract.Data} as
4542 * well as the following aliases.
4543 * </p>
4544 * <h2>Column aliases</h2>
4545 * <table class="jd-sumtable">
4546 * <tr>
4547 * <th>Type</th>
4548 * <th>Alias</th><th colspan='2'>Data column</th>
4549 * </tr>
4550 * <tr>
4551 * <td>String</td>
4552 * <td>{@link #DATA}</td>
4553 * <td>{@link #DATA1}</td>
4554 * <td></td>
4555 * </tr>
4556 * <tr>
4557 * <td>int</td>
4558 * <td>{@link #TYPE}</td>
4559 * <td>{@link #DATA2}</td>
4560 * <td>Allowed values are:
4561 * <p>
4562 * <ul>
4563 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4564 * <li>{@link #TYPE_HOME}</li>
4565 * <li>{@link #TYPE_WORK}</li>
4566 * <li>{@link #TYPE_OTHER}</li>
4567 * </ul>
4568 * </p>
4569 * </td>
4570 * </tr>
4571 * <tr>
4572 * <td>String</td>
4573 * <td>{@link #LABEL}</td>
4574 * <td>{@link #DATA3}</td>
4575 * <td></td>
4576 * </tr>
4577 * <tr>
4578 * <td>String</td>
4579 * <td>{@link #PROTOCOL}</td>
4580 * <td>{@link #DATA5}</td>
4581 * <td>
4582 * <p>
4583 * Allowed values:
4584 * <ul>
4585 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
4586 * as {@link #CUSTOM_PROTOCOL}.</li>
4587 * <li>{@link #PROTOCOL_AIM}</li>
4588 * <li>{@link #PROTOCOL_MSN}</li>
4589 * <li>{@link #PROTOCOL_YAHOO}</li>
4590 * <li>{@link #PROTOCOL_SKYPE}</li>
4591 * <li>{@link #PROTOCOL_QQ}</li>
4592 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
4593 * <li>{@link #PROTOCOL_ICQ}</li>
4594 * <li>{@link #PROTOCOL_JABBER}</li>
4595 * <li>{@link #PROTOCOL_NETMEETING}</li>
4596 * </ul>
4597 * </p>
4598 * </td>
4599 * </tr>
4600 * <tr>
4601 * <td>String</td>
4602 * <td>{@link #CUSTOM_PROTOCOL}</td>
4603 * <td>{@link #DATA6}</td>
4604 * <td></td>
4605 * </tr>
4606 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07004607 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004608 public static final class Im implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05004609 /**
4610 * This utility class cannot be instantiated
4611 */
Evan Millar088b2912009-05-28 15:24:37 -07004612 private Im() {}
4613
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004614 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07004615 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
4616
Evan Millar088b2912009-05-28 15:24:37 -07004617 public static final int TYPE_HOME = 1;
4618 public static final int TYPE_WORK = 2;
4619 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07004620
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07004621 /**
4622 * This column should be populated with one of the defined
4623 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
4624 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
4625 * should contain the name of the custom protocol.
4626 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004627 public static final String PROTOCOL = DATA5;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07004628
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004629 public static final String CUSTOM_PROTOCOL = DATA6;
Jeff Sharkey732da922009-07-30 09:59:31 -07004630
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07004631 /*
4632 * The predefined IM protocol types.
Evan Millar088b2912009-05-28 15:24:37 -07004633 */
Jeff Sharkey732da922009-07-30 09:59:31 -07004634 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07004635 public static final int PROTOCOL_AIM = 0;
4636 public static final int PROTOCOL_MSN = 1;
4637 public static final int PROTOCOL_YAHOO = 2;
4638 public static final int PROTOCOL_SKYPE = 3;
4639 public static final int PROTOCOL_QQ = 4;
4640 public static final int PROTOCOL_GOOGLE_TALK = 5;
4641 public static final int PROTOCOL_ICQ = 6;
4642 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07004643 public static final int PROTOCOL_NETMEETING = 8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004644
4645 /**
4646 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004647 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004648 */
4649 public static final int getTypeLabelResource(int type) {
4650 switch (type) {
4651 case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
4652 case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
4653 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
4654 default: return com.android.internal.R.string.imTypeCustom;
4655 }
4656 }
4657
4658 /**
4659 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004660 * possibly substituting the given {@link #LABEL} value
4661 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004662 */
4663 public static final CharSequence getTypeLabel(Resources res, int type,
4664 CharSequence label) {
4665 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
4666 return label;
4667 } else {
4668 final int labelRes = getTypeLabelResource(type);
4669 return res.getText(labelRes);
4670 }
4671 }
4672
4673 /**
4674 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004675 * {@link #PROTOCOL}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004676 */
4677 public static final int getProtocolLabelResource(int type) {
4678 switch (type) {
4679 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
4680 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
4681 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
4682 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
4683 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
4684 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
4685 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
4686 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
4687 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
4688 default: return com.android.internal.R.string.imProtocolCustom;
4689 }
4690 }
4691
4692 /**
4693 * Return a {@link CharSequence} that best describes the given
4694 * protocol, possibly substituting the given
4695 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
4696 */
4697 public static final CharSequence getProtocolLabel(Resources res, int type,
4698 CharSequence label) {
4699 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
4700 return label;
4701 } else {
4702 final int labelRes = getProtocolLabelResource(type);
4703 return res.getText(labelRes);
4704 }
4705 }
Evan Millar088b2912009-05-28 15:24:37 -07004706 }
4707
4708 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004709 * <p>
4710 * A data kind representing an organization.
4711 * </p>
4712 * <p>
4713 * You can use all columns defined for {@link ContactsContract.Data} as
4714 * well as the following aliases.
4715 * </p>
4716 * <h2>Column aliases</h2>
4717 * <table class="jd-sumtable">
4718 * <tr>
4719 * <th>Type</th>
4720 * <th>Alias</th><th colspan='2'>Data column</th>
4721 * </tr>
4722 * <tr>
4723 * <td>String</td>
4724 * <td>{@link #COMPANY}</td>
4725 * <td>{@link #DATA1}</td>
4726 * <td></td>
4727 * </tr>
4728 * <tr>
4729 * <td>int</td>
4730 * <td>{@link #TYPE}</td>
4731 * <td>{@link #DATA2}</td>
4732 * <td>Allowed values are:
4733 * <p>
4734 * <ul>
4735 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4736 * <li>{@link #TYPE_WORK}</li>
4737 * <li>{@link #TYPE_OTHER}</li>
4738 * </ul>
4739 * </p>
4740 * </td>
4741 * </tr>
4742 * <tr>
4743 * <td>String</td>
4744 * <td>{@link #LABEL}</td>
4745 * <td>{@link #DATA3}</td>
4746 * <td></td>
4747 * </tr>
4748 * <tr>
4749 * <td>String</td>
4750 * <td>{@link #TITLE}</td>
4751 * <td>{@link #DATA4}</td>
4752 * <td></td>
4753 * </tr>
4754 * <tr>
4755 * <td>String</td>
4756 * <td>{@link #DEPARTMENT}</td>
4757 * <td>{@link #DATA5}</td>
4758 * <td></td>
4759 * </tr>
4760 * <tr>
4761 * <td>String</td>
4762 * <td>{@link #JOB_DESCRIPTION}</td>
4763 * <td>{@link #DATA6}</td>
4764 * <td></td>
4765 * </tr>
4766 * <tr>
4767 * <td>String</td>
4768 * <td>{@link #SYMBOL}</td>
4769 * <td>{@link #DATA7}</td>
4770 * <td></td>
4771 * </tr>
4772 * <tr>
4773 * <td>String</td>
4774 * <td>{@link #PHONETIC_NAME}</td>
4775 * <td>{@link #DATA8}</td>
4776 * <td></td>
4777 * </tr>
4778 * <tr>
4779 * <td>String</td>
4780 * <td>{@link #OFFICE_LOCATION}</td>
4781 * <td>{@link #DATA9}</td>
4782 * <td></td>
4783 * </tr>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08004784 * <tr>
4785 * <td>String</td>
4786 * <td>PHONETIC_NAME_STYLE</td>
4787 * <td>{@link #DATA10}</td>
4788 * <td></td>
4789 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004790 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004791 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004792 public static final class Organization implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05004793 /**
4794 * This utility class cannot be instantiated
4795 */
Evan Millar088b2912009-05-28 15:24:37 -07004796 private Organization() {}
4797
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004798 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07004799 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
4800
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07004801 public static final int TYPE_WORK = 1;
4802 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07004803
4804 /**
4805 * The company as the user entered it.
4806 * <P>Type: TEXT</P>
4807 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07004808 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07004809
4810 /**
4811 * The position title at this company as the user entered it.
4812 * <P>Type: TEXT</P>
4813 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004814 public static final String TITLE = DATA4;
Fred Quintana8851e162009-08-05 21:06:45 -07004815
4816 /**
4817 * The department at this company as the user entered it.
4818 * <P>Type: TEXT</P>
4819 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004820 public static final String DEPARTMENT = DATA5;
Fred Quintana8851e162009-08-05 21:06:45 -07004821
4822 /**
4823 * The job description at this company as the user entered it.
4824 * <P>Type: TEXT</P>
4825 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004826 public static final String JOB_DESCRIPTION = DATA6;
Fred Quintana8851e162009-08-05 21:06:45 -07004827
4828 /**
4829 * The symbol of this company as the user entered it.
4830 * <P>Type: TEXT</P>
4831 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004832 public static final String SYMBOL = DATA7;
Fred Quintana8851e162009-08-05 21:06:45 -07004833
4834 /**
4835 * The phonetic name of this company as the user entered it.
4836 * <P>Type: TEXT</P>
4837 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07004838 public static final String PHONETIC_NAME = DATA8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004839
4840 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07004841 * The office location of this organization.
4842 * <P>Type: TEXT</P>
4843 */
4844 public static final String OFFICE_LOCATION = DATA9;
4845
4846 /**
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08004847 * The alphabet used for capturing the phonetic name.
4848 * See {@link ContactsContract.PhoneticNameStyle}.
4849 * @hide
4850 */
4851 public static final String PHONETIC_NAME_STYLE = DATA10;
4852
4853 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004854 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004855 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004856 */
4857 public static final int getTypeLabelResource(int type) {
4858 switch (type) {
4859 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
4860 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
4861 default: return com.android.internal.R.string.orgTypeCustom;
4862 }
4863 }
4864
4865 /**
4866 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004867 * possibly substituting the given {@link #LABEL} value
4868 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07004869 */
4870 public static final CharSequence getTypeLabel(Resources res, int type,
4871 CharSequence label) {
4872 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
4873 return label;
4874 } else {
4875 final int labelRes = getTypeLabelResource(type);
4876 return res.getText(labelRes);
4877 }
4878 }
Fred Quintana8851e162009-08-05 21:06:45 -07004879 }
4880
4881 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004882 * <p>
4883 * A data kind representing a relation.
4884 * </p>
4885 * <p>
4886 * You can use all columns defined for {@link ContactsContract.Data} as
4887 * well as the following aliases.
4888 * </p>
4889 * <h2>Column aliases</h2>
4890 * <table class="jd-sumtable">
4891 * <tr>
4892 * <th>Type</th>
4893 * <th>Alias</th><th colspan='2'>Data column</th>
4894 * </tr>
4895 * <tr>
4896 * <td>String</td>
4897 * <td>{@link #NAME}</td>
4898 * <td>{@link #DATA1}</td>
4899 * <td></td>
4900 * </tr>
4901 * <tr>
4902 * <td>int</td>
4903 * <td>{@link #TYPE}</td>
4904 * <td>{@link #DATA2}</td>
4905 * <td>Allowed values are:
4906 * <p>
4907 * <ul>
4908 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4909 * <li>{@link #TYPE_ASSISTANT}</li>
4910 * <li>{@link #TYPE_BROTHER}</li>
4911 * <li>{@link #TYPE_CHILD}</li>
4912 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
4913 * <li>{@link #TYPE_FATHER}</li>
4914 * <li>{@link #TYPE_FRIEND}</li>
4915 * <li>{@link #TYPE_MANAGER}</li>
4916 * <li>{@link #TYPE_MOTHER}</li>
4917 * <li>{@link #TYPE_PARENT}</li>
4918 * <li>{@link #TYPE_PARTNER}</li>
4919 * <li>{@link #TYPE_REFERRED_BY}</li>
4920 * <li>{@link #TYPE_RELATIVE}</li>
4921 * <li>{@link #TYPE_SISTER}</li>
4922 * <li>{@link #TYPE_SPOUSE}</li>
4923 * </ul>
4924 * </p>
4925 * </td>
4926 * </tr>
4927 * <tr>
4928 * <td>String</td>
4929 * <td>{@link #LABEL}</td>
4930 * <td>{@link #DATA3}</td>
4931 * <td></td>
4932 * </tr>
4933 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07004934 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004935 public static final class Relation implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05004936 /**
4937 * This utility class cannot be instantiated
4938 */
Fred Quintana8851e162009-08-05 21:06:45 -07004939 private Relation() {}
4940
4941 /** MIME type used when storing this in data table. */
4942 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
4943
4944 public static final int TYPE_ASSISTANT = 1;
4945 public static final int TYPE_BROTHER = 2;
4946 public static final int TYPE_CHILD = 3;
4947 public static final int TYPE_DOMESTIC_PARTNER = 4;
4948 public static final int TYPE_FATHER = 5;
4949 public static final int TYPE_FRIEND = 6;
4950 public static final int TYPE_MANAGER = 7;
4951 public static final int TYPE_MOTHER = 8;
4952 public static final int TYPE_PARENT = 9;
4953 public static final int TYPE_PARTNER = 10;
4954 public static final int TYPE_REFERRED_BY = 11;
4955 public static final int TYPE_RELATIVE = 12;
4956 public static final int TYPE_SISTER = 13;
4957 public static final int TYPE_SPOUSE = 14;
4958
4959 /**
4960 * The name of the relative as the user entered it.
4961 * <P>Type: TEXT</P>
4962 */
4963 public static final String NAME = DATA;
4964 }
4965
4966 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004967 * <p>
4968 * A data kind representing an event.
4969 * </p>
4970 * <p>
4971 * You can use all columns defined for {@link ContactsContract.Data} as
4972 * well as the following aliases.
4973 * </p>
4974 * <h2>Column aliases</h2>
4975 * <table class="jd-sumtable">
4976 * <tr>
4977 * <th>Type</th>
4978 * <th>Alias</th><th colspan='2'>Data column</th>
4979 * </tr>
4980 * <tr>
4981 * <td>String</td>
4982 * <td>{@link #START_DATE}</td>
4983 * <td>{@link #DATA1}</td>
4984 * <td></td>
4985 * </tr>
4986 * <tr>
4987 * <td>int</td>
4988 * <td>{@link #TYPE}</td>
4989 * <td>{@link #DATA2}</td>
4990 * <td>Allowed values are:
4991 * <p>
4992 * <ul>
4993 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
4994 * <li>{@link #TYPE_ANNIVERSARY}</li>
4995 * <li>{@link #TYPE_OTHER}</li>
4996 * <li>{@link #TYPE_BIRTHDAY}</li>
4997 * </ul>
4998 * </p>
4999 * </td>
5000 * </tr>
5001 * <tr>
5002 * <td>String</td>
5003 * <td>{@link #LABEL}</td>
5004 * <td>{@link #DATA3}</td>
5005 * <td></td>
5006 * </tr>
5007 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07005008 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07005009 public static final class Event implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005010 /**
5011 * This utility class cannot be instantiated
5012 */
Fred Quintana8851e162009-08-05 21:06:45 -07005013 private Event() {}
5014
5015 /** MIME type used when storing this in data table. */
Fred Quintanac868acf2009-09-30 18:17:47 -07005016 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
Fred Quintana8851e162009-08-05 21:06:45 -07005017
5018 public static final int TYPE_ANNIVERSARY = 1;
5019 public static final int TYPE_OTHER = 2;
Fred Quintanac868acf2009-09-30 18:17:47 -07005020 public static final int TYPE_BIRTHDAY = 3;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005021
Fred Quintana8851e162009-08-05 21:06:45 -07005022 /**
5023 * The event start date as the user entered it.
5024 * <P>Type: TEXT</P>
5025 */
5026 public static final String START_DATE = DATA;
Fred Quintanac868acf2009-09-30 18:17:47 -07005027
5028 /**
5029 * Return the string resource that best describes the given
5030 * {@link #TYPE}. Will always return a valid resource.
5031 */
5032 public static int getTypeResource(Integer type) {
5033 if (type == null) {
5034 return com.android.internal.R.string.eventTypeOther;
5035 }
5036 switch (type) {
5037 case TYPE_ANNIVERSARY:
5038 return com.android.internal.R.string.eventTypeAnniversary;
5039 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
5040 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
5041 default: return com.android.internal.R.string.eventTypeOther;
5042 }
5043 }
Evan Millar088b2912009-05-28 15:24:37 -07005044 }
5045
5046 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005047 * <p>
5048 * A data kind representing an photo for the contact.
5049 * </p>
5050 * <p>
5051 * Some sync adapters will choose to download photos in a separate
5052 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
5053 * through {@link ContactsContract.Data#SYNC4} to store temporary
5054 * data, e.g. the image URL or ID, state of download, server-side version
5055 * of the image. It is allowed for the {@link #PHOTO} to be null.
5056 * </p>
5057 * <p>
5058 * You can use all columns defined for {@link ContactsContract.Data} as
5059 * well as the following aliases.
5060 * </p>
5061 * <h2>Column aliases</h2>
5062 * <table class="jd-sumtable">
5063 * <tr>
5064 * <th>Type</th>
5065 * <th>Alias</th><th colspan='2'>Data column</th>
5066 * </tr>
5067 * <tr>
5068 * <td>BLOB</td>
5069 * <td>{@link #PHOTO}</td>
5070 * <td>{@link #DATA15}</td>
5071 * <td>By convention, binary data is stored in DATA15.</td>
5072 * </tr>
5073 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005074 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07005075 public static final class Photo implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005076 /**
5077 * This utility class cannot be instantiated
5078 */
Evan Millar088b2912009-05-28 15:24:37 -07005079 private Photo() {}
5080
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005081 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005082 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
5083
5084 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07005085 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005086 * that could be inflated using {@link android.graphics.BitmapFactory}.
Evan Millar088b2912009-05-28 15:24:37 -07005087 * <p>
5088 * Type: BLOB
5089 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005090 public static final String PHOTO = DATA15;
Evan Millar088b2912009-05-28 15:24:37 -07005091 }
5092
5093 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005094 * <p>
Evan Millar088b2912009-05-28 15:24:37 -07005095 * Notes about the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005096 * </p>
5097 * <p>
5098 * You can use all columns defined for {@link ContactsContract.Data} as
5099 * well as the following aliases.
5100 * </p>
5101 * <h2>Column aliases</h2>
5102 * <table class="jd-sumtable">
5103 * <tr>
5104 * <th>Type</th>
5105 * <th>Alias</th><th colspan='2'>Data column</th>
5106 * </tr>
5107 * <tr>
5108 * <td>String</td>
5109 * <td>{@link #NOTE}</td>
5110 * <td>{@link #DATA1}</td>
5111 * <td></td>
5112 * </tr>
5113 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005114 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07005115 public static final class Note implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005116 /**
5117 * This utility class cannot be instantiated
5118 */
Evan Millar088b2912009-05-28 15:24:37 -07005119 private Note() {}
5120
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005121 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005122 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
5123
5124 /**
5125 * The note text.
5126 * <P>Type: TEXT</P>
5127 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005128 public static final String NOTE = DATA1;
Evan Millar088b2912009-05-28 15:24:37 -07005129 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07005130
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005131 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005132 * <p>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07005133 * Group Membership.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005134 * </p>
5135 * <p>
5136 * You can use all columns defined for {@link ContactsContract.Data} as
5137 * well as the following aliases.
5138 * </p>
5139 * <h2>Column aliases</h2>
5140 * <table class="jd-sumtable">
5141 * <tr>
5142 * <th>Type</th>
5143 * <th>Alias</th><th colspan='2'>Data column</th>
5144 * </tr>
5145 * <tr>
5146 * <td>long</td>
5147 * <td>{@link #GROUP_ROW_ID}</td>
5148 * <td>{@link #DATA1}</td>
5149 * <td></td>
5150 * </tr>
5151 * <tr>
5152 * <td>String</td>
5153 * <td>{@link #GROUP_SOURCE_ID}</td>
5154 * <td>none</td>
5155 * <td>
5156 * <p>
5157 * The sourceid of the group that this group membership refers to.
5158 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
5159 * inserting a row.
5160 * </p>
5161 * <p>
5162 * If this field is specified, the provider will first try to
5163 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group
5164 * is found, it will use the corresponding row id. If the group is not
5165 * found, it will create one.
5166 * </td>
5167 * </tr>
5168 * </table>
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07005169 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07005170 public static final class GroupMembership implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005171 /**
5172 * This utility class cannot be instantiated
5173 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07005174 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07005175
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005176 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07005177 public static final String CONTENT_ITEM_TYPE =
5178 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07005179
Fred Quintanad8dfeb52009-06-04 10:28:49 -07005180 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07005181 * The row id of the group that this group membership refers to. Exactly one of
5182 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07005183 * <P>Type: INTEGER</P>
5184 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005185 public static final String GROUP_ROW_ID = DATA1;
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07005186
Fred Quintanad8dfeb52009-06-04 10:28:49 -07005187 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07005188 * The sourceid of the group that this group membership refers to. Exactly one of
5189 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005190 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07005191 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07005192 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07005193 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005194
5195 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005196 * <p>
5197 * A data kind representing a website related to the contact.
5198 * </p>
5199 * <p>
5200 * You can use all columns defined for {@link ContactsContract.Data} as
5201 * well as the following aliases.
5202 * </p>
5203 * <h2>Column aliases</h2>
5204 * <table class="jd-sumtable">
5205 * <tr>
5206 * <th>Type</th>
5207 * <th>Alias</th><th colspan='2'>Data column</th>
5208 * </tr>
5209 * <tr>
5210 * <td>String</td>
5211 * <td>{@link #URL}</td>
5212 * <td>{@link #DATA1}</td>
5213 * <td></td>
5214 * </tr>
5215 * <tr>
5216 * <td>int</td>
5217 * <td>{@link #TYPE}</td>
5218 * <td>{@link #DATA2}</td>
5219 * <td>Allowed values are:
5220 * <p>
5221 * <ul>
5222 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5223 * <li>{@link #TYPE_HOMEPAGE}</li>
5224 * <li>{@link #TYPE_BLOG}</li>
5225 * <li>{@link #TYPE_PROFILE}</li>
5226 * <li>{@link #TYPE_HOME}</li>
5227 * <li>{@link #TYPE_WORK}</li>
5228 * <li>{@link #TYPE_FTP}</li>
5229 * <li>{@link #TYPE_OTHER}</li>
5230 * </ul>
5231 * </p>
5232 * </td>
5233 * </tr>
5234 * <tr>
5235 * <td>String</td>
5236 * <td>{@link #LABEL}</td>
5237 * <td>{@link #DATA3}</td>
5238 * <td></td>
5239 * </tr>
5240 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005241 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07005242 public static final class Website implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005243 /**
5244 * This utility class cannot be instantiated
5245 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005246 private Website() {}
5247
5248 /** MIME type used when storing this in data table. */
5249 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
5250
Fred Quintana8851e162009-08-05 21:06:45 -07005251 public static final int TYPE_HOMEPAGE = 1;
5252 public static final int TYPE_BLOG = 2;
5253 public static final int TYPE_PROFILE = 3;
5254 public static final int TYPE_HOME = 4;
5255 public static final int TYPE_WORK = 5;
5256 public static final int TYPE_FTP = 6;
5257 public static final int TYPE_OTHER = 7;
5258
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005259 /**
5260 * The website URL string.
5261 * <P>Type: TEXT</P>
5262 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005263 public static final String URL = DATA;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005264 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07005265 }
Fred Quintana435e4272009-06-04 17:30:28 -07005266
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005267 /**
5268 * @see Groups
5269 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005270 protected interface GroupsColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005271 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005272 * The display title of this group.
5273 * <p>
5274 * Type: TEXT
5275 */
5276 public static final String TITLE = "title";
5277
5278 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005279 * The package name to use when creating {@link Resources} objects for
5280 * this group. This value is only designed for use when building user
5281 * interfaces, and should not be used to infer the owner.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005282 *
5283 * @hide
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005284 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005285 public static final String RES_PACKAGE = "res_package";
5286
5287 /**
5288 * The display title of this group to load as a resource from
5289 * {@link #RES_PACKAGE}, which may be localized.
5290 * <P>Type: TEXT</P>
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005291 *
5292 * @hide
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005293 */
5294 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005295
5296 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07005297 * Notes about the group.
5298 * <p>
5299 * Type: TEXT
5300 */
5301 public static final String NOTES = "notes";
5302
5303 /**
5304 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
5305 * to the sync adapter, null otherwise.
5306 * <P>Type: TEXT</P>
5307 */
5308 public static final String SYSTEM_ID = "system_id";
5309
5310 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07005311 * The total number of {@link Contacts} that have
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07005312 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005313 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
5314 * <p>
5315 * Type: INTEGER
5316 */
5317 public static final String SUMMARY_COUNT = "summ_count";
5318
5319 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07005320 * The total number of {@link Contacts} that have both
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07005321 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005322 * Read-only value that is only present when querying
5323 * {@link Groups#CONTENT_SUMMARY_URI}.
5324 * <p>
5325 * Type: INTEGER
5326 */
5327 public static final String SUMMARY_WITH_PHONES = "summ_phones";
5328
5329 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005330 * Flag indicating if the contacts belonging to this group should be
5331 * visible in any user interface.
5332 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07005333 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005334 */
5335 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07005336
5337 /**
5338 * The "deleted" flag: "0" by default, "1" if the row has been marked
5339 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005340 * called on a group, it is marked for deletion. The sync adaptor
5341 * deletes the group on the server and then calls ContactResolver.delete
5342 * once more, this time setting the the
5343 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
5344 * finalize the data removal.
Fred Quintana00c89f62009-08-10 14:43:24 -07005345 * <P>Type: INTEGER</P>
5346 */
5347 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07005348
5349 /**
5350 * Whether this group should be synced if the SYNC_EVERYTHING settings
5351 * is false for this group's account.
5352 * <p>
5353 * Type: INTEGER (boolean)
5354 */
5355 public static final String SHOULD_SYNC = "should_sync";
Fred Quintanaa31a9452010-04-13 14:52:20 -07005356
5357 /**
5358 * Any newly created contacts will automatically be added to groups that have this
5359 * flag set to true.
5360 * <p>
5361 * Type: INTEGER (boolean)
5362 */
5363 public static final String AUTO_ADD = "auto_add";
5364
5365 /**
5366 * When a contacts is marked as a favorites it will be automatically added
5367 * to the groups that have this flag set, and when it is removed from favorites
5368 * it will be removed from these groups.
5369 * <p>
5370 * Type: INTEGER (boolean)
5371 */
5372 public static final String FAVORITES = "favorites";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005373 }
5374
5375 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005376 * Constants for the groups table. Only per-account groups are supported.
5377 * <h2>Columns</h2>
5378 * <table class="jd-sumtable">
5379 * <tr>
5380 * <th colspan='4'>Groups</th>
5381 * </tr>
5382 * <tr>
5383 * <td>long</td>
5384 * <td>{@link #_ID}</td>
5385 * <td>read-only</td>
5386 * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
5387 * In other words, it would be a really bad idea to delete and reinsert a
5388 * group. A sync adapter should always do an update instead.</td>
5389 * </tr>
5390 * <tr>
5391 * <td>String</td>
5392 * <td>{@link #TITLE}</td>
5393 * <td>read/write</td>
5394 * <td>The display title of this group.</td>
5395 * </tr>
5396 * <tr>
5397 * <td>String</td>
5398 * <td>{@link #NOTES}</td>
5399 * <td>read/write</td>
5400 * <td>Notes about the group.</td>
5401 * </tr>
5402 * <tr>
5403 * <td>String</td>
5404 * <td>{@link #SYSTEM_ID}</td>
5405 * <td>read/write</td>
5406 * <td>The ID of this group if it is a System Group, i.e. a group that has a
5407 * special meaning to the sync adapter, null otherwise.</td>
5408 * </tr>
5409 * <tr>
5410 * <td>int</td>
5411 * <td>{@link #SUMMARY_COUNT}</td>
5412 * <td>read-only</td>
5413 * <td>The total number of {@link Contacts} that have
5414 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
5415 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
5416 * </tr>
5417 * <tr>
5418 * <td>int</td>
5419 * <td>{@link #SUMMARY_WITH_PHONES}</td>
5420 * <td>read-only</td>
5421 * <td>The total number of {@link Contacts} that have both
5422 * {@link CommonDataKinds.GroupMembership} in this group, and also have
5423 * phone numbers. Read-only value that is only present when querying
5424 * {@link Groups#CONTENT_SUMMARY_URI}.</td>
5425 * </tr>
5426 * <tr>
5427 * <td>int</td>
5428 * <td>{@link #GROUP_VISIBLE}</td>
5429 * <td>read-only</td>
5430 * <td>Flag indicating if the contacts belonging to this group should be
5431 * visible in any user interface. Allowed values: 0 and 1.</td>
5432 * </tr>
5433 * <tr>
5434 * <td>int</td>
5435 * <td>{@link #DELETED}</td>
5436 * <td>read/write</td>
5437 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
5438 * for deletion. When {@link android.content.ContentResolver#delete} is
5439 * called on a group, it is marked for deletion. The sync adaptor deletes
5440 * the group on the server and then calls ContactResolver.delete once more,
5441 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
5442 * query parameter to finalize the data removal.</td>
5443 * </tr>
5444 * <tr>
5445 * <td>int</td>
5446 * <td>{@link #SHOULD_SYNC}</td>
5447 * <td>read/write</td>
5448 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
5449 * is false for this group's account.</td>
5450 * </tr>
5451 * </table>
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005452 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005453 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005454 /**
5455 * This utility class cannot be instantiated
5456 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005457 private Groups() {
5458 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005459
5460 /**
5461 * The content:// style URI for this table
5462 */
5463 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
5464
5465 /**
5466 * The content:// style URI for this table joined with details data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005467 * {@link ContactsContract.Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005468 */
5469 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
5470 "groups_summary");
5471
5472 /**
5473 * The MIME type of a directory of groups.
5474 */
5475 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
5476
5477 /**
5478 * The MIME type of a single group.
5479 */
5480 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
Fred Quintana328c0e72009-12-07 14:52:28 -08005481
5482 public static EntityIterator newEntityIterator(Cursor cursor) {
5483 return new EntityIteratorImpl(cursor);
5484 }
5485
5486 private static class EntityIteratorImpl extends CursorEntityIterator {
5487 public EntityIteratorImpl(Cursor cursor) {
5488 super(cursor);
5489 }
5490
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08005491 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08005492 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
5493 // we expect the cursor is already at the row we need to read from
5494 final ContentValues values = new ContentValues();
5495 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
5496 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
5497 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
5498 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
5499 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
5500 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
5501 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
5502 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
5503 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
5504 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
5505 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
5506 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
5507 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
5508 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
5509 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
5510 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
5511 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
5512 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
Fred Quintanaa31a9452010-04-13 14:52:20 -07005513 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES);
5514 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD);
Fred Quintana328c0e72009-12-07 14:52:28 -08005515 cursor.moveToNext();
5516 return new Entity(values);
5517 }
5518 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07005519 }
5520
Fred Quintana435e4272009-06-04 17:30:28 -07005521 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005522 * <p>
Fred Quintana435e4272009-06-04 17:30:28 -07005523 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005524 * aggregation rules overriding those used by automatic aggregation. This
5525 * type only supports query and update. Neither insert nor delete are
5526 * supported.
5527 * </p>
5528 * <h2>Columns</h2>
5529 * <table class="jd-sumtable">
5530 * <tr>
5531 * <th colspan='4'>AggregationExceptions</th>
5532 * </tr>
5533 * <tr>
5534 * <td>int</td>
5535 * <td>{@link #TYPE}</td>
5536 * <td>read/write</td>
5537 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
5538 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
5539 * </tr>
5540 * <tr>
5541 * <td>long</td>
5542 * <td>{@link #RAW_CONTACT_ID1}</td>
5543 * <td>read/write</td>
5544 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
5545 * the rule applies to.</td>
5546 * </tr>
5547 * <tr>
5548 * <td>long</td>
5549 * <td>{@link #RAW_CONTACT_ID2}</td>
5550 * <td>read/write</td>
5551 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
5552 * that the rule applies to.</td>
5553 * </tr>
5554 * </table>
Fred Quintana435e4272009-06-04 17:30:28 -07005555 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07005556 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07005557 /**
5558 * This utility class cannot be instantiated
5559 */
5560 private AggregationExceptions() {}
5561
5562 /**
5563 * The content:// style URI for this table
5564 */
5565 public static final Uri CONTENT_URI =
5566 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
5567
5568 /**
5569 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
5570 */
5571 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
5572
5573 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07005574 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
5575 */
5576 public static final String CONTENT_ITEM_TYPE =
5577 "vnd.android.cursor.item/aggregation_exception";
5578
5579 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07005580 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07005581 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07005582 *
5583 * <P>Type: INTEGER</P>
5584 */
5585 public static final String TYPE = "type";
5586
Fred Quintana435e4272009-06-04 17:30:28 -07005587 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07005588 * Allows the provider to automatically decide whether the specified raw contacts should
5589 * be included in the same aggregate contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07005590 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07005591 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07005592
5593 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07005594 * Makes sure that the specified raw contacts are included in the same
5595 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07005596 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07005597 public static final int TYPE_KEEP_TOGETHER = 1;
5598
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07005599 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07005600 * Makes sure that the specified raw contacts are NOT included in the same
5601 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07005602 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07005603 public static final int TYPE_KEEP_SEPARATE = 2;
5604
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07005605 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07005606 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07005607 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07005608 public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
5609
5610 /**
5611 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
5612 * applies to.
5613 */
5614 public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
Fred Quintana435e4272009-06-04 17:30:28 -07005615 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07005616
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005617 /**
5618 * @see Settings
5619 */
Dmitri Plotnikovfe4c8712009-10-14 00:28:48 -07005620 protected interface SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07005621 /**
5622 * The name of the account instance to which this row belongs.
5623 * <P>Type: TEXT</P>
5624 */
5625 public static final String ACCOUNT_NAME = "account_name";
5626
5627 /**
5628 * The type of account to which this row belongs, which when paired with
5629 * {@link #ACCOUNT_NAME} identifies a specific account.
5630 * <P>Type: TEXT</P>
5631 */
5632 public static final String ACCOUNT_TYPE = "account_type";
5633
5634 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07005635 * Depending on the mode defined by the sync-adapter, this flag controls
5636 * the top-level sync behavior for this data source.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07005637 * <p>
5638 * Type: INTEGER (boolean)
5639 */
5640 public static final String SHOULD_SYNC = "should_sync";
5641
5642 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07005643 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
Jeff Sharkeya6597442009-08-19 09:23:33 -07005644 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07005645 * <p>
5646 * Type: INTEGER (boolean)
5647 */
5648 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
Jeff Sharkey06a03232009-08-21 17:37:56 -07005649
5650 /**
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07005651 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
5652 * {@link Groups#SHOULD_SYNC} under this account have been marked as
5653 * unsynced.
5654 */
5655 public static final String ANY_UNSYNCED = "any_unsynced";
5656
5657 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07005658 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07005659 * no {@link CommonDataKinds.GroupMembership} entries.
Jeff Sharkey06a03232009-08-21 17:37:56 -07005660 * <p>
5661 * Type: INTEGER
5662 */
5663 public static final String UNGROUPED_COUNT = "summ_count";
5664
5665 /**
5666 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07005667 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
Jeff Sharkey06a03232009-08-21 17:37:56 -07005668 * <p>
5669 * Type: INTEGER
5670 */
5671 public static final String UNGROUPED_WITH_PHONES = "summ_phones";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07005672 }
5673
5674 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005675 * <p>
5676 * Contacts-specific settings for various {@link Account}'s.
5677 * </p>
5678 * <h2>Columns</h2>
5679 * <table class="jd-sumtable">
5680 * <tr>
5681 * <th colspan='4'>Settings</th>
5682 * </tr>
5683 * <tr>
5684 * <td>String</td>
5685 * <td>{@link #ACCOUNT_NAME}</td>
5686 * <td>read/write-once</td>
5687 * <td>The name of the account instance to which this row belongs.</td>
5688 * </tr>
5689 * <tr>
5690 * <td>String</td>
5691 * <td>{@link #ACCOUNT_TYPE}</td>
5692 * <td>read/write-once</td>
5693 * <td>The type of account to which this row belongs, which when paired with
5694 * {@link #ACCOUNT_NAME} identifies a specific account.</td>
5695 * </tr>
5696 * <tr>
5697 * <td>int</td>
5698 * <td>{@link #SHOULD_SYNC}</td>
5699 * <td>read/write</td>
5700 * <td>Depending on the mode defined by the sync-adapter, this flag controls
5701 * the top-level sync behavior for this data source.</td>
5702 * </tr>
5703 * <tr>
5704 * <td>int</td>
5705 * <td>{@link #UNGROUPED_VISIBLE}</td>
5706 * <td>read/write</td>
5707 * <td>Flag indicating if contacts without any
5708 * {@link CommonDataKinds.GroupMembership} entries should be visible in any
5709 * user interface.</td>
5710 * </tr>
5711 * <tr>
5712 * <td>int</td>
5713 * <td>{@link #ANY_UNSYNCED}</td>
5714 * <td>read-only</td>
5715 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
5716 * {@link Groups#SHOULD_SYNC} under this account have been marked as
5717 * unsynced.</td>
5718 * </tr>
5719 * <tr>
5720 * <td>int</td>
5721 * <td>{@link #UNGROUPED_COUNT}</td>
5722 * <td>read-only</td>
5723 * <td>Read-only count of {@link Contacts} from a specific source that have
5724 * no {@link CommonDataKinds.GroupMembership} entries.</td>
5725 * </tr>
5726 * <tr>
5727 * <td>int</td>
5728 * <td>{@link #UNGROUPED_WITH_PHONES}</td>
5729 * <td>read-only</td>
5730 * <td>Read-only count of {@link Contacts} from a specific source that have
5731 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
5732 * numbers.</td>
5733 * </tr>
5734 * </table>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07005735 */
Jeff Sharkey06a03232009-08-21 17:37:56 -07005736 public static final class Settings implements SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07005737 /**
5738 * This utility class cannot be instantiated
5739 */
5740 private Settings() {
5741 }
5742
5743 /**
5744 * The content:// style URI for this table
5745 */
5746 public static final Uri CONTENT_URI =
5747 Uri.withAppendedPath(AUTHORITY_URI, "settings");
5748
5749 /**
5750 * The MIME-type of {@link #CONTENT_URI} providing a directory of
5751 * settings.
5752 */
5753 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
5754
5755 /**
5756 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
5757 */
5758 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07005759 }
5760
Evan Millardc2da5f2009-06-18 16:07:13 -07005761 /**
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08005762 * Private API for inquiring about the general status of the provider.
5763 *
5764 * @hide
5765 */
5766 public static final class ProviderStatus {
5767
5768 /**
5769 * Not instantiable.
5770 */
5771 private ProviderStatus() {
5772 }
5773
5774 /**
5775 * The content:// style URI for this table. Requests to this URI can be
5776 * performed on the UI thread because they are always unblocking.
5777 *
5778 * @hide
5779 */
5780 public static final Uri CONTENT_URI =
5781 Uri.withAppendedPath(AUTHORITY_URI, "provider_status");
5782
5783 /**
5784 * The MIME-type of {@link #CONTENT_URI} providing a directory of
5785 * settings.
5786 *
5787 * @hide
5788 */
5789 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status";
5790
5791 /**
5792 * An integer representing the current status of the provider.
5793 *
5794 * @hide
5795 */
5796 public static final String STATUS = "status";
5797
5798 /**
5799 * Default status of the provider.
5800 *
5801 * @hide
5802 */
5803 public static final int STATUS_NORMAL = 0;
5804
5805 /**
5806 * The status used when the provider is in the process of upgrading. Contacts
5807 * are temporarily unaccessible.
5808 *
5809 * @hide
5810 */
5811 public static final int STATUS_UPGRADING = 1;
5812
5813 /**
5814 * The status used if the provider was in the process of upgrading but ran
5815 * out of storage. The DATA1 column will contain the estimated amount of
5816 * storage required (in bytes). Update status to STATUS_NORMAL to force
5817 * the provider to retry the upgrade.
5818 *
5819 * @hide
5820 */
5821 public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2;
5822
5823 /**
5824 * The status used during a locale change.
5825 *
5826 * @hide
5827 */
5828 public static final int STATUS_CHANGING_LOCALE = 3;
5829
5830 /**
5831 * Additional data associated with the status.
5832 *
5833 * @hide
5834 */
5835 public static final String DATA1 = "data1";
5836 }
5837
5838 /**
Evan Millare3ec9972009-09-30 19:37:36 -07005839 * Helper methods to display QuickContact dialogs that allow users to pivot on
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005840 * a specific {@link Contacts} entry.
5841 */
Evan Millare3ec9972009-09-30 19:37:36 -07005842 public static final class QuickContact {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005843 /**
5844 * Action used to trigger person pivot dialog.
5845 * @hide
5846 */
Evan Millar5042f7e2009-09-30 21:28:33 -07005847 public static final String ACTION_QUICK_CONTACT =
5848 "com.android.contacts.action.QUICK_CONTACT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005849
5850 /**
5851 * Extra used to specify pivot dialog location in screen coordinates.
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08005852 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005853 * @hide
5854 */
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08005855 @Deprecated
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005856 public static final String EXTRA_TARGET_RECT = "target_rect";
5857
5858 /**
5859 * Extra used to specify size of pivot dialog.
5860 * @hide
5861 */
5862 public static final String EXTRA_MODE = "mode";
5863
5864 /**
5865 * Extra used to indicate a list of specific MIME-types to exclude and
5866 * not display. Stored as a {@link String} array.
5867 * @hide
5868 */
5869 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
5870
5871 /**
Evan Millare3ec9972009-09-30 19:37:36 -07005872 * Small QuickContact mode, usually presented with minimal actions.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005873 */
5874 public static final int MODE_SMALL = 1;
5875
5876 /**
Evan Millare3ec9972009-09-30 19:37:36 -07005877 * Medium QuickContact mode, includes actions and light summary describing
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005878 * the {@link Contacts} entry being shown. This may include social
5879 * status and presence details.
5880 */
5881 public static final int MODE_MEDIUM = 2;
5882
5883 /**
Evan Millare3ec9972009-09-30 19:37:36 -07005884 * Large QuickContact mode, includes actions and larger, card-like summary
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005885 * of the {@link Contacts} entry being shown. This may include detailed
5886 * information, such as a photo.
5887 */
5888 public static final int MODE_LARGE = 3;
5889
5890 /**
5891 * Trigger a dialog that lists the various methods of interacting with
5892 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005893 * {@link ContactsContract.Data} rows under that contact, and may also
5894 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005895 *
5896 * @param context The parent {@link Context} that may be used as the
5897 * parent for this dialog.
5898 * @param target Specific {@link View} from your layout that this dialog
5899 * should be centered around. In particular, if the dialog
5900 * has a "callout" arrow, it will be pointed and centered
5901 * around this {@link View}.
Evan Millar772722e2009-09-30 22:24:07 -07005902 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005903 * {@link Uri} that describes a specific contact to feature
5904 * in this dialog.
5905 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
5906 * {@link #MODE_LARGE}, indicating the desired dialog size,
5907 * when supported.
5908 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
5909 * to exclude when showing this dialog. For example, when
5910 * already viewing the contact details card, this can be used
5911 * to omit the details entry from the dialog.
5912 */
Evan Millare3ec9972009-09-30 19:37:36 -07005913 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005914 String[] excludeMimes) {
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08005915 // Find location and bounds of target view, adjusting based on the
5916 // assumed local density.
5917 final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
5918 final int[] pos = new int[2];
5919 target.getLocationOnScreen(pos);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005920
5921 final Rect rect = new Rect();
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08005922 rect.left = (int) (pos[0] * appScale + 0.5f);
5923 rect.top = (int) (pos[1] * appScale + 0.5f);
5924 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
5925 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005926
5927 // Trigger with obtained rectangle
Evan Millare3ec9972009-09-30 19:37:36 -07005928 showQuickContact(context, rect, lookupUri, mode, excludeMimes);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005929 }
5930
5931 /**
5932 * Trigger a dialog that lists the various methods of interacting with
5933 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005934 * {@link ContactsContract.Data} rows under that contact, and may also
5935 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005936 *
5937 * @param context The parent {@link Context} that may be used as the
5938 * parent for this dialog.
5939 * @param target Specific {@link Rect} that this dialog should be
5940 * centered around, in screen coordinates. In particular, if
5941 * the dialog has a "callout" arrow, it will be pointed and
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08005942 * centered around this {@link Rect}. If you are running at a
5943 * non-native density, you need to manually adjust using
5944 * {@link DisplayMetrics#density} before calling.
Jeff Sharkey223bd7a2009-12-21 14:51:19 -08005945 * @param lookupUri A
5946 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005947 * {@link Uri} that describes a specific contact to feature
5948 * in this dialog.
5949 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
5950 * {@link #MODE_LARGE}, indicating the desired dialog size,
5951 * when supported.
5952 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
5953 * to exclude when showing this dialog. For example, when
5954 * already viewing the contact details card, this can be used
5955 * to omit the details entry from the dialog.
5956 */
Evan Millare3ec9972009-09-30 19:37:36 -07005957 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005958 String[] excludeMimes) {
5959 // Launch pivot dialog through intent for now
Evan Millar5042f7e2009-09-30 21:28:33 -07005960 final Intent intent = new Intent(ACTION_QUICK_CONTACT);
Jeff Sharkeyc00099e2009-09-30 22:27:15 -07005961 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
5962 | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5963
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005964 intent.setData(lookupUri);
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08005965 intent.setSourceBounds(target);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07005966 intent.putExtra(EXTRA_MODE, mode);
5967 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
5968 context.startActivity(intent);
5969 }
5970 }
5971
5972 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07005973 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
5974 * that involve contacts.
5975 */
5976 public static final class Intents {
5977 /**
5978 * This is the intent that is fired when a search suggestion is clicked on.
5979 */
5980 public static final String SEARCH_SUGGESTION_CLICKED =
5981 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
5982
5983 /**
5984 * This is the intent that is fired when a search suggestion for dialing a number
5985 * is clicked on.
5986 */
5987 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
5988 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
5989
5990 /**
5991 * This is the intent that is fired when a search suggestion for creating a contact
5992 * is clicked on.
5993 */
5994 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
5995 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
5996
5997 /**
5998 * Starts an Activity that lets the user pick a contact to attach an image to.
5999 * After picking the contact it launches the image cropper in face detection mode.
6000 */
6001 public static final String ATTACH_IMAGE =
6002 "com.android.contacts.action.ATTACH_IMAGE";
6003
6004 /**
6005 * Takes as input a data URI with a mailto: or tel: scheme. If a single
6006 * contact exists with the given data it will be shown. If no contact
6007 * exists, a dialog will ask the user if they want to create a new
6008 * contact with the provided details filled in. If multiple contacts
6009 * share the data the user will be prompted to pick which contact they
6010 * want to view.
6011 * <p>
6012 * For <code>mailto:</code> URIs, the scheme specific portion must be a
6013 * raw email address, such as one built using
6014 * {@link Uri#fromParts(String, String, String)}.
6015 * <p>
6016 * For <code>tel:</code> URIs, the scheme specific portion is compared
6017 * to existing numbers using the standard caller ID lookup algorithm.
6018 * The number must be properly encoded, for example using
6019 * {@link Uri#fromParts(String, String, String)}.
6020 * <p>
6021 * Any extras from the {@link Insert} class will be passed along to the
6022 * create activity if there are no contacts to show.
6023 * <p>
6024 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
6025 * prompting the user when the contact doesn't exist.
6026 */
6027 public static final String SHOW_OR_CREATE_CONTACT =
6028 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
6029
6030 /**
Bai Taofc7838b2010-01-22 03:34:56 +08006031 * Starts an Activity that lets the user select the multiple phones from a
6032 * list of phone numbers which come from the contacts or
6033 * {@link #EXTRA_PHONE_URIS}.
6034 * <p>
6035 * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS}
6036 * could belong to the contacts or not, and will be selected by default.
6037 * <p>
6038 * The user's selection will be returned from
6039 * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
Fred Quintanaa31a9452010-04-13 14:52:20 -07006040 * if the resultCode is
Bai Taofc7838b2010-01-22 03:34:56 +08006041 * {@link android.app.Activity#RESULT_OK}, the array of picked phone
6042 * numbers are in the Intent's
6043 * {@link #EXTRA_PHONE_URIS}; otherwise, the
6044 * {@link android.app.Activity#RESULT_CANCELED} is returned if the user
6045 * left the Activity without changing the selection.
6046 *
6047 * @hide
6048 */
6049 public static final String ACTION_GET_MULTIPLE_PHONES =
6050 "com.android.contacts.action.GET_MULTIPLE_PHONES";
6051
6052 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07006053 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
6054 * contact if no matching contact found. Otherwise, default behavior is
6055 * to prompt user with dialog before creating.
6056 * <p>
6057 * Type: BOOLEAN
6058 */
6059 public static final String EXTRA_FORCE_CREATE =
6060 "com.android.contacts.action.FORCE_CREATE";
6061
6062 /**
6063 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
6064 * description to be shown when prompting user about creating a new
6065 * contact.
6066 * <p>
6067 * Type: STRING
6068 */
6069 public static final String EXTRA_CREATE_DESCRIPTION =
6070 "com.android.contacts.action.CREATE_DESCRIPTION";
6071
6072 /**
Bai Taofc7838b2010-01-22 03:34:56 +08006073 * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value.
6074 * <p>
6075 * The phone numbers want to be picked by default should be passed in as
6076 * input value. These phone numbers could belong to the contacts or not.
6077 * <p>
6078 * The phone numbers which were picked by the user are returned as output
6079 * value.
6080 * <p>
6081 * Type: array of URIs, the tel URI is used for the phone numbers which don't
6082 * belong to any contact, the content URI is used for phone id in contacts.
Fred Quintanaa31a9452010-04-13 14:52:20 -07006083 *
Bai Taofc7838b2010-01-22 03:34:56 +08006084 * @hide
6085 */
6086 public static final String EXTRA_PHONE_URIS =
6087 "com.android.contacts.extra.PHONE_URIS";
6088
6089 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07006090 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
6091 * dialog location using screen coordinates. When not specified, the
6092 * dialog will be centered.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006093 *
6094 * @hide
Jeff Sharkey11322002009-06-04 17:25:51 -07006095 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07006096 @Deprecated
Jeff Sharkey11322002009-06-04 17:25:51 -07006097 public static final String EXTRA_TARGET_RECT = "target_rect";
6098
6099 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006100 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
6101 * desired dialog style, usually a variation on size. One of
6102 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006103 *
6104 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006105 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07006106 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006107 public static final String EXTRA_MODE = "mode";
6108
6109 /**
6110 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006111 *
6112 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006113 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07006114 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006115 public static final int MODE_SMALL = 1;
6116
6117 /**
6118 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006119 *
6120 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006121 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07006122 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006123 public static final int MODE_MEDIUM = 2;
6124
6125 /**
6126 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006127 *
6128 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006129 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07006130 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07006131 public static final int MODE_LARGE = 3;
6132
6133 /**
Jeff Sharkey84235ee2009-08-23 14:07:02 -07006134 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
6135 * a list of specific MIME-types to exclude and not display. Stored as a
6136 * {@link String} array.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006137 *
6138 * @hide
Jeff Sharkey84235ee2009-08-23 14:07:02 -07006139 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07006140 @Deprecated
Jeff Sharkey84235ee2009-08-23 14:07:02 -07006141 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
6142
6143 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07006144 * Intents related to the Contacts app UI.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006145 *
6146 * @hide
Evan Millardc2da5f2009-06-18 16:07:13 -07006147 */
6148 public static final class UI {
6149 /**
6150 * The action for the default contacts list tab.
6151 */
6152 public static final String LIST_DEFAULT =
6153 "com.android.contacts.action.LIST_DEFAULT";
6154
6155 /**
6156 * The action for the contacts list tab.
6157 */
6158 public static final String LIST_GROUP_ACTION =
6159 "com.android.contacts.action.LIST_GROUP";
6160
6161 /**
6162 * When in LIST_GROUP_ACTION mode, this is the group to display.
6163 */
6164 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
6165
6166 /**
6167 * The action for the all contacts list tab.
6168 */
6169 public static final String LIST_ALL_CONTACTS_ACTION =
6170 "com.android.contacts.action.LIST_ALL_CONTACTS";
6171
6172 /**
6173 * The action for the contacts with phone numbers list tab.
6174 */
6175 public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
6176 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
6177
6178 /**
6179 * The action for the starred contacts list tab.
6180 */
6181 public static final String LIST_STARRED_ACTION =
6182 "com.android.contacts.action.LIST_STARRED";
6183
6184 /**
6185 * The action for the frequent contacts list tab.
6186 */
6187 public static final String LIST_FREQUENT_ACTION =
6188 "com.android.contacts.action.LIST_FREQUENT";
6189
6190 /**
6191 * The action for the "strequent" contacts list tab. It first lists the starred
6192 * contacts in alphabetical order and then the frequent contacts in descending
6193 * order of the number of times they have been contacted.
6194 */
6195 public static final String LIST_STREQUENT_ACTION =
6196 "com.android.contacts.action.LIST_STREQUENT";
6197
6198 /**
6199 * A key for to be used as an intent extra to set the activity
6200 * title to a custom String value.
6201 */
6202 public static final String TITLE_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006203 "com.android.contacts.extra.TITLE_EXTRA";
Evan Millardc2da5f2009-06-18 16:07:13 -07006204
6205 /**
6206 * Activity Action: Display a filtered list of contacts
6207 * <p>
6208 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
6209 * filtering
6210 * <p>
6211 * Output: Nothing.
6212 */
6213 public static final String FILTER_CONTACTS_ACTION =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006214 "com.android.contacts.action.FILTER_CONTACTS";
Evan Millardc2da5f2009-06-18 16:07:13 -07006215
6216 /**
6217 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
6218 * intents to supply the text on which to filter.
6219 */
6220 public static final String FILTER_TEXT_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006221 "com.android.contacts.extra.FILTER_TEXT";
Evan Millardc2da5f2009-06-18 16:07:13 -07006222 }
6223
6224 /**
6225 * Convenience class that contains string constants used
6226 * to create contact {@link android.content.Intent Intents}.
6227 */
6228 public static final class Insert {
6229 /** The action code to use when adding a contact */
6230 public static final String ACTION = Intent.ACTION_INSERT;
6231
6232 /**
6233 * If present, forces a bypass of quick insert mode.
6234 */
6235 public static final String FULL_MODE = "full_mode";
6236
6237 /**
6238 * The extra field for the contact name.
6239 * <P>Type: String</P>
6240 */
6241 public static final String NAME = "name";
6242
6243 // TODO add structured name values here.
6244
6245 /**
6246 * The extra field for the contact phonetic name.
6247 * <P>Type: String</P>
6248 */
6249 public static final String PHONETIC_NAME = "phonetic_name";
6250
6251 /**
6252 * The extra field for the contact company.
6253 * <P>Type: String</P>
6254 */
6255 public static final String COMPANY = "company";
6256
6257 /**
6258 * The extra field for the contact job title.
6259 * <P>Type: String</P>
6260 */
6261 public static final String JOB_TITLE = "job_title";
6262
6263 /**
6264 * The extra field for the contact notes.
6265 * <P>Type: String</P>
6266 */
6267 public static final String NOTES = "notes";
6268
6269 /**
6270 * The extra field for the contact phone number.
6271 * <P>Type: String</P>
6272 */
6273 public static final String PHONE = "phone";
6274
6275 /**
6276 * The extra field for the contact phone number type.
6277 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006278 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07006279 * or a string specifying a custom label.</P>
6280 */
6281 public static final String PHONE_TYPE = "phone_type";
6282
6283 /**
6284 * The extra field for the phone isprimary flag.
6285 * <P>Type: boolean</P>
6286 */
6287 public static final String PHONE_ISPRIMARY = "phone_isprimary";
6288
6289 /**
6290 * The extra field for an optional second contact phone number.
6291 * <P>Type: String</P>
6292 */
6293 public static final String SECONDARY_PHONE = "secondary_phone";
6294
6295 /**
6296 * The extra field for an optional second contact phone number type.
6297 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006298 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07006299 * or a string specifying a custom label.</P>
6300 */
6301 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
6302
6303 /**
6304 * The extra field for an optional third contact phone number.
6305 * <P>Type: String</P>
6306 */
6307 public static final String TERTIARY_PHONE = "tertiary_phone";
6308
6309 /**
6310 * The extra field for an optional third contact phone number type.
6311 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006312 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07006313 * or a string specifying a custom label.</P>
6314 */
6315 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
6316
6317 /**
6318 * The extra field for the contact email address.
6319 * <P>Type: String</P>
6320 */
6321 public static final String EMAIL = "email";
6322
6323 /**
6324 * The extra field for the contact email type.
6325 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006326 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07006327 * or a string specifying a custom label.</P>
6328 */
6329 public static final String EMAIL_TYPE = "email_type";
6330
6331 /**
6332 * The extra field for the email isprimary flag.
6333 * <P>Type: boolean</P>
6334 */
6335 public static final String EMAIL_ISPRIMARY = "email_isprimary";
6336
6337 /**
6338 * The extra field for an optional second contact email address.
6339 * <P>Type: String</P>
6340 */
6341 public static final String SECONDARY_EMAIL = "secondary_email";
6342
6343 /**
6344 * The extra field for an optional second contact email type.
6345 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006346 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07006347 * or a string specifying a custom label.</P>
6348 */
6349 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
6350
6351 /**
6352 * The extra field for an optional third contact email address.
6353 * <P>Type: String</P>
6354 */
6355 public static final String TERTIARY_EMAIL = "tertiary_email";
6356
6357 /**
6358 * The extra field for an optional third contact email type.
6359 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006360 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07006361 * or a string specifying a custom label.</P>
6362 */
6363 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
6364
6365 /**
6366 * The extra field for the contact postal address.
6367 * <P>Type: String</P>
6368 */
6369 public static final String POSTAL = "postal";
6370
6371 /**
6372 * The extra field for the contact postal address type.
6373 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006374 * {@link CommonDataKinds.StructuredPostal}
Evan Millardc2da5f2009-06-18 16:07:13 -07006375 * or a string specifying a custom label.</P>
6376 */
6377 public static final String POSTAL_TYPE = "postal_type";
6378
6379 /**
6380 * The extra field for the postal isprimary flag.
6381 * <P>Type: boolean</P>
6382 */
6383 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
6384
6385 /**
6386 * The extra field for an IM handle.
6387 * <P>Type: String</P>
6388 */
6389 public static final String IM_HANDLE = "im_handle";
6390
6391 /**
6392 * The extra field for the IM protocol
Evan Millardc2da5f2009-06-18 16:07:13 -07006393 */
6394 public static final String IM_PROTOCOL = "im_protocol";
6395
6396 /**
6397 * The extra field for the IM isprimary flag.
6398 * <P>Type: boolean</P>
6399 */
6400 public static final String IM_ISPRIMARY = "im_isprimary";
6401 }
6402 }
Evan Millar088b2912009-05-28 15:24:37 -07006403}