blob: 27473e393b06930beaeb5e7e10065e80b9e6f630 [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;
Daniel Lehmanne6d3d282011-07-13 15:35:05 -070020import android.app.Activity;
Yorke Lee4fc601a2013-12-06 16:35:29 -080021import android.content.ActivityNotFoundException;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070022import android.content.ContentProviderClient;
23import android.content.ContentProviderOperation;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070024import android.content.ContentResolver;
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -070025import android.content.ContentUris;
Jeff Hamilton85abdc52009-09-22 12:41:45 -050026import android.content.ContentValues;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070027import android.content.Context;
Makoto Onukibba33cd2012-05-25 17:09:05 -070028import android.content.ContextWrapper;
Fred Quintana328c0e72009-12-07 14:52:28 -080029import android.content.CursorEntityIterator;
Fred Quintana328c0e72009-12-07 14:52:28 -080030import android.content.Entity;
Tom O'Neill244327e2010-01-08 11:11:15 -080031import android.content.EntityIterator;
32import android.content.Intent;
Daniel Lehmannf5d46522011-07-14 22:16:21 -070033import android.content.res.AssetFileDescriptor;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -070034import android.content.res.Resources;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070035import android.database.Cursor;
Fred Quintana328c0e72009-12-07 14:52:28 -080036import android.database.DatabaseUtils;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070037import android.graphics.Rect;
Evan Millar088b2912009-05-28 15:24:37 -070038import android.net.Uri;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070039import android.os.RemoteException;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070040import android.text.TextUtils;
Jeff Sharkeya503f6f2009-12-08 21:50:14 -080041import android.util.DisplayMetrics;
Fred Quintanac4516a72009-09-03 12:14:06 -070042import android.util.Pair;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070043import android.view.View;
Yorke Lee4fc601a2013-12-06 16:35:29 -080044import android.widget.Toast;
Evan Millar088b2912009-05-28 15:24:37 -070045
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070046import java.io.ByteArrayInputStream;
Daniel Lehmannf5d46522011-07-14 22:16:21 -070047import java.io.IOException;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070048import java.io.InputStream;
Dmitri Plotnikov44730c22010-08-12 10:09:58 -070049import java.util.ArrayList;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070050
Evan Millar088b2912009-05-28 15:24:37 -070051/**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080052 * <p>
53 * The contract between the contacts provider and applications. Contains
54 * definitions for the supported URIs and columns. These APIs supersede
55 * {@link Contacts}.
56 * </p>
57 * <h3>Overview</h3>
58 * <p>
59 * ContactsContract defines an extensible database of contact-related
60 * information. Contact information is stored in a three-tier data model:
61 * </p>
Dirk Dougherty4e7db252010-01-05 17:03:39 -080062 * <ul>
63 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080064 * A row in the {@link Data} table can store any kind of personal data, such
65 * as a phone number or email addresses. The set of data kinds that can be
66 * stored in this table is open-ended. There is a predefined set of common
67 * kinds, but any application can add its own data kinds.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080068 * </li>
69 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080070 * A row in the {@link RawContacts} table represents a set of data describing a
71 * person and associated with a single account (for example, one of the user's
72 * Gmail accounts).
Dirk Dougherty4e7db252010-01-05 17:03:39 -080073 * </li>
74 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080075 * A row in the {@link Contacts} table represents an aggregate of one or more
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080076 * RawContacts presumably describing the same person. When data in or associated with
77 * the RawContacts table is changed, the affected aggregate contacts are updated as
78 * necessary.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080079 * </li>
80 * </ul>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080081 * <p>
82 * Other tables include:
83 * </p>
Dirk Dougherty4e7db252010-01-05 17:03:39 -080084 * <ul>
85 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080086 * {@link Groups}, which contains information about raw contact groups
87 * such as Gmail contact groups. The
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080088 * current API does not support the notion of groups spanning multiple accounts.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080089 * </li>
90 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080091 * {@link StatusUpdates}, which contains social status updates including IM
92 * availability.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080093 * </li>
94 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080095 * {@link AggregationExceptions}, which is used for manual aggregation and
96 * disaggregation of raw contacts
Dirk Dougherty4e7db252010-01-05 17:03:39 -080097 * </li>
98 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080099 * {@link Settings}, which contains visibility and sync settings for accounts
100 * and groups.
Dirk Dougherty4e7db252010-01-05 17:03:39 -0800101 * </li>
102 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800103 * {@link SyncState}, which contains free-form data maintained on behalf of sync
104 * adapters
Dirk Dougherty4e7db252010-01-05 17:03:39 -0800105 * </li>
106 * <li>
107 * {@link PhoneLookup}, which is used for quick caller-ID lookup</li>
108 * </ul>
Evan Millar088b2912009-05-28 15:24:37 -0700109 */
Jeff Hamilton0c232122009-09-24 00:26:50 -0500110@SuppressWarnings("unused")
Evan Millar088b2912009-05-28 15:24:37 -0700111public final class ContactsContract {
112 /** The authority for the contacts provider */
113 public static final String AUTHORITY = "com.android.contacts";
114 /** A content:// style uri to the authority for the contacts provider */
115 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
116
Fred Quintana33f889a2009-09-14 17:31:26 -0700117 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800118 * An optional URI parameter for insert, update, or delete queries
119 * that allows the caller
Fred Quintana33f889a2009-09-14 17:31:26 -0700120 * to specify that it is a sync adapter. The default value is false. If true
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800121 * {@link RawContacts#DIRTY} is not automatically set and the
122 * "syncToNetwork" parameter is set to false when calling
123 * {@link
124 * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
125 * This prevents an unnecessary extra synchronization, see the discussion of
126 * the delete operation in {@link RawContacts}.
Fred Quintana33f889a2009-09-14 17:31:26 -0700127 */
128 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
129
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500130 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700131 * Query parameter that should be used by the client to access a specific
132 * {@link Directory}. The parameter value should be the _ID of the corresponding
133 * directory, e.g.
134 * {@code content://com.android.contacts/data/emails/filter/acme?directory=3}
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700135 */
136 public static final String DIRECTORY_PARAM_KEY = "directory";
137
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700138 /**
Dmitri Plotnikov5a998dd2010-08-31 17:32:16 -0700139 * A query parameter that limits the number of results returned. The
140 * parameter value should be an integer.
141 */
142 public static final String LIMIT_PARAM_KEY = "limit";
143
144 /**
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700145 * A query parameter specifing a primary account. This parameter should be used with
146 * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on
147 * this information to optimize its query results.
148 *
149 * For example, in an email composition screen, its implementation can specify an account when
150 * obtaining possible recipients, letting the provider know which account is selected during
151 * the composition. The provider may use the "primary account" information to optimize
152 * the search result.
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700153 */
154 public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account";
155
156 /**
157 * A query parameter specifing a primary account. This parameter should be used with
158 * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}.
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700159 */
160 public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account";
161
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700162 /**
163 * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and
164 * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to
165 * return only phone-related results. For example, frequently contacted person list should
166 * include persons contacted via phone (not email, sms, etc.)
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700167 */
168 public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only";
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700169
170 /**
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700171 * A key to a boolean in the "extras" bundle of the cursor.
172 * The boolean indicates that the provider did not create a snippet and that the client asking
173 * for the snippet should do it (true means the snippeting was deferred to the client).
Yorke Leeeaf09492014-07-01 10:28:56 -0700174 *
175 * @see SearchSnippets
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700176 */
177 public static final String DEFERRED_SNIPPETING = "deferred_snippeting";
178
179 /**
Yorke Leeeaf09492014-07-01 10:28:56 -0700180 * Key to retrieve the original deferred snippeting from the cursor on the client side.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700181 *
Yorke Leeeaf09492014-07-01 10:28:56 -0700182 * @see SearchSnippets
183 * @see #DEFERRED_SNIPPETING
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700184 */
185 public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query";
186
187 /**
Yorke Lee1ca440b2014-06-04 18:01:46 -0700188 * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI},
189 * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and
190 * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}.
Daisuke Miyakawa19352e02011-11-14 13:16:07 -0800191 * This enables a content provider to remove duplicate entries in results.
Daisuke Miyakawa19352e02011-11-14 13:16:07 -0800192 */
193 public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries";
194
195 /**
Dave Santoroe43185e2011-10-10 18:11:00 -0700196 * <p>
197 * API for obtaining a pre-authorized version of a URI that normally requires special
198 * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI
199 * must already have the necessary permissions to access the URI; otherwise a
200 * {@link SecurityException} will be thrown.
201 * </p>
202 * <p>
203 * The authorized URI returned in the bundle contains an expiring token that allows the
204 * caller to execute the query without having the special permissions that would normally
205 * be required.
206 * </p>
207 * <p>
208 * This API does not access disk, and should be safe to invoke from the UI thread.
209 * </p>
210 * <p>
211 * Example usage:
212 * <pre>
213 * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI;
214 * Bundle uriBundle = new Bundle();
215 * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri);
216 * Bundle authResponse = getContext().getContentResolver().call(
217 * ContactsContract.AUTHORITY_URI,
218 * ContactsContract.Authorization.AUTHORIZATION_METHOD,
219 * null, // String arg, not used.
220 * uriBundle);
221 * if (authResponse != null) {
222 * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable(
223 * ContactsContract.Authorization.KEY_AUTHORIZED_URI);
224 * // This pre-authorized URI can be queried by a caller without READ_PROFILE
225 * // permission.
226 * }
227 * </pre>
228 * </p>
229 * @hide
230 */
231 public static final class Authorization {
232 /**
233 * The method to invoke to create a pre-authorized URI out of the input argument.
234 */
235 public static final String AUTHORIZATION_METHOD = "authorize";
236
237 /**
238 * The key to set in the outbound Bundle with the URI that should be authorized.
239 */
240 public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize";
241
242 /**
243 * The key to retrieve from the returned Bundle to obtain the pre-authorized URI.
244 */
245 public static final String KEY_AUTHORIZED_URI = "authorized_uri";
246 }
247
Yorke Lee6355c8f2014-07-08 11:48:42 -0700248 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700249 * A Directory represents a contacts corpus, e.g. Local contacts,
250 * Google Apps Global Address List or Corporate Global Address List.
251 * <p>
252 * A Directory is implemented as a content provider with its unique authority and
253 * the same API as the main Contacts Provider. However, there is no expectation that
254 * every directory provider will implement this Contract in its entirety. If a
255 * directory provider does not have an implementation for a specific request, it
256 * should throw an UnsupportedOperationException.
257 * </p>
258 * <p>
259 * The most important use case for Directories is search. A Directory provider is
Dmitri Plotnikov13e03572010-08-19 16:31:29 -0700260 * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI
261 * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700262 * in email and phone lookup functionalities, it should also implement
263 * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI}
264 * and
265 * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}.
266 * </p>
267 * <p>
268 * A directory provider should return NULL for every projection field it does not
269 * recognize, rather than throwing an exception. This way it will not be broken
270 * if ContactsContract is extended with new fields in the future.
271 * </p>
272 * <p>
273 * The client interacts with a directory via Contacts Provider by supplying an
274 * optional {@code directory=} query parameter.
275 * <p>
276 * <p>
277 * When the Contacts Provider receives the request, it transforms the URI and forwards
278 * the request to the corresponding directory content provider.
279 * The URI is transformed in the following fashion:
280 * <ul>
281 * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li>
282 * <li>The {@code accountName=} and {@code accountType=} parameters are added or
283 * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700284 * </ul>
285 * </p>
286 * <p>
287 * Clients should send directory requests to Contacts Provider and let it
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700288 * forward them to the respective providers rather than constructing
289 * directory provider URIs by themselves. This level of indirection allows
290 * Contacts Provider to implement additional system-level features and
291 * optimizations. Access to Contacts Provider is protected by the
Subir Jhanb603af612012-08-06 17:19:22 -0700292 * READ_CONTACTS permission, but access to the directory provider is protected by
293 * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous
294 * platform versions the provider should perform the following check to make sure the call
295 * is coming from the ContactsProvider:
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700296 * <pre>
297 * private boolean isCallerAllowed() {
298 * PackageManager pm = getContext().getPackageManager();
299 * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) {
300 * if (packageName.equals("com.android.providers.contacts")) {
301 * return true;
302 * }
303 * }
304 * return false;
305 * }
306 * </pre>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700307 * </p>
308 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700309 * The Directory table is read-only and is maintained by the Contacts Provider
310 * automatically.
311 * </p>
312 * <p>It always has at least these two rows:
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700313 * <ul>
314 * <li>
315 * The local directory. It has {@link Directory#_ID Directory._ID} =
316 * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally
317 * stored contacts. The same can be achieved by omitting the {@code directory=}
318 * parameter altogether.
319 * </li>
320 * <li>
321 * The local invisible contacts. The corresponding directory ID is
322 * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}.
323 * </li>
324 * </ul>
325 * </p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700326 * <p>Custom Directories are discovered by the Contacts Provider following this procedure:
327 * <ul>
328 * <li>It finds all installed content providers with meta data identifying them
329 * as directory providers in AndroidManifest.xml:
330 * <code>
331 * &lt;meta-data android:name="android.content.ContactDirectory"
332 * android:value="true" /&gt;
333 * </code>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700334 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700335 * This tag should be placed inside the corresponding content provider declaration.
336 * </p>
337 * </li>
338 * <li>
339 * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI}
340 * query to each of the directory authorities. A directory provider must implement
341 * this query and return a list of directories. Each directory returned by
342 * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and
343 * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned
344 * automatically, the _ID field will not be part of the query projection.
345 * </li>
346 * <li>Contacts Provider compiles directory lists received from all directory
347 * providers into one, assigns each individual directory a globally unique ID and
348 * stores all directory records in the Directory table.
349 * </li>
350 * </ul>
351 * </p>
352 * <p>Contacts Provider automatically interrogates newly installed or replaced packages.
353 * Thus simply installing a package containing a directory provider is sufficient
354 * to have that provider registered. A package supplying a directory provider does
355 * not have to contain launchable activities.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700356 * </p>
357 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700358 * Every row in the Directory table is automatically associated with the corresponding package
359 * (apk). If the package is later uninstalled, all corresponding directory rows
360 * are automatically removed from the Contacts Provider.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700361 * </p>
362 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700363 * When the list of directories handled by a directory provider changes
364 * (for instance when the user adds a new Directory account), the directory provider
365 * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change.
366 * In response, the Contacts Provider will requery the directory provider to obtain the
367 * new list of directories.
368 * </p>
369 * <p>
370 * A directory row can be optionally associated with an existing account
371 * (see {@link android.accounts.AccountManager}). If the account is later removed,
Dmitri Plotnikove50ed082010-08-18 10:56:09 -0700372 * the corresponding directory rows are automatically removed from the Contacts Provider.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700373 * </p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700374 */
375 public static final class Directory implements BaseColumns {
376
377 /**
378 * Not instantiable.
379 */
380 private Directory() {
381 }
382
383 /**
384 * The content:// style URI for this table. Requests to this URI can be
385 * performed on the UI thread because they are always unblocking.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700386 */
387 public static final Uri CONTENT_URI =
388 Uri.withAppendedPath(AUTHORITY_URI, "directories");
389
390 /**
391 * The MIME-type of {@link #CONTENT_URI} providing a directory of
392 * contact directories.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700393 */
394 public static final String CONTENT_TYPE =
395 "vnd.android.cursor.dir/contact_directories";
396
397 /**
398 * The MIME type of a {@link #CONTENT_URI} item.
399 */
400 public static final String CONTENT_ITEM_TYPE =
401 "vnd.android.cursor.item/contact_directory";
402
403 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700404 * _ID of the default directory, which represents locally stored contacts.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700405 */
406 public static final long DEFAULT = 0;
407
408 /**
409 * _ID of the directory that represents locally stored invisible contacts.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700410 */
411 public static final long LOCAL_INVISIBLE = 1;
412
413 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700414 * The name of the package that owns this directory. Contacts Provider
415 * fill it in with the name of the package containing the directory provider.
416 * If the package is later uninstalled, the directories it owns are
417 * automatically removed from this table.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700418 *
419 * <p>TYPE: TEXT</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700420 */
421 public static final String PACKAGE_NAME = "packageName";
422
423 /**
424 * The type of directory captured as a resource ID in the context of the
425 * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory"
426 *
427 * <p>TYPE: INTEGER</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700428 */
429 public static final String TYPE_RESOURCE_ID = "typeResourceId";
430
431 /**
432 * An optional name that can be used in the UI to represent this directory,
433 * e.g. "Acme Corp"
434 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700435 */
436 public static final String DISPLAY_NAME = "displayName";
437
438 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700439 * <p>
440 * The authority of the Directory Provider. Contacts Provider will
441 * use this authority to forward requests to the directory provider.
442 * A directory provider can leave this column empty - Contacts Provider will fill it in.
443 * </p>
444 * <p>
445 * Clients of this API should not send requests directly to this authority.
446 * All directory requests must be routed through Contacts Provider.
447 * </p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700448 *
449 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700450 */
451 public static final String DIRECTORY_AUTHORITY = "authority";
452
453 /**
454 * The account type which this directory is associated.
455 *
456 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700457 */
458 public static final String ACCOUNT_TYPE = "accountType";
459
460 /**
461 * The account with which this directory is associated. If the account is later
462 * removed, the directories it owns are automatically removed from this table.
463 *
464 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700465 */
466 public static final String ACCOUNT_NAME = "accountName";
467
468 /**
469 * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT},
470 * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the
471 * directory has for data exported from it. Clients must obey this setting.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700472 */
473 public static final String EXPORT_SUPPORT = "exportSupport";
474
475 /**
476 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
477 * does not allow any data to be copied out of it.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700478 */
479 public static final int EXPORT_SUPPORT_NONE = 0;
480
481 /**
482 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
483 * allow its data copied only to the account specified by
484 * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700485 */
486 public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1;
487
488 /**
489 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
490 * allow its data copied to any contacts account.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700491 */
492 public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2;
493
494 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700495 * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY},
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700496 * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700497 * has for shortcuts created for its elements. Clients must obey this setting.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700498 */
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700499 public static final String SHORTCUT_SUPPORT = "shortcutSupport";
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700500
501 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700502 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
503 * does not allow any shortcuts created for its contacts.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700504 */
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700505 public static final int SHORTCUT_SUPPORT_NONE = 0;
506
507 /**
508 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
509 * allow creation of shortcuts for data items like email, phone or postal address,
510 * but not the entire contact.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700511 */
512 public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1;
513
514 /**
515 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
516 * allow creation of shortcuts for contact as well as their constituent elements.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700517 */
518 public static final int SHORTCUT_SUPPORT_FULL = 2;
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700519
520 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700521 * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY},
522 * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent
523 * to which the directory supports contact photos.
524 */
525 public static final String PHOTO_SUPPORT = "photoSupport";
526
527 /**
528 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
529 * does not provide any photos.
530 */
531 public static final int PHOTO_SUPPORT_NONE = 0;
532
533 /**
534 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
535 * can only produce small size thumbnails of contact photos.
536 */
537 public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1;
538
539 /**
540 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
541 * has full-size contact photos, but cannot provide scaled thumbnails.
542 */
543 public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2;
544
545 /**
546 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
547 * can produce thumbnails as well as full-size contact photos.
548 */
549 public static final int PHOTO_SUPPORT_FULL = 3;
550
551 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700552 * Notifies the system of a change in the list of directories handled by
553 * a particular directory provider. The Contacts provider will turn around
554 * and send a query to the directory provider for the full list of directories,
555 * which will replace the previous list.
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700556 */
557 public static void notifyDirectoryChange(ContentResolver resolver) {
558 // This is done to trigger a query by Contacts Provider back to the directory provider.
559 // No data needs to be sent back, because the provider can infer the calling
560 // package from binder.
561 ContentValues contentValues = new ContentValues();
562 resolver.update(Directory.CONTENT_URI, contentValues, null, null);
563 }
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700564 }
565
566 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500567 * @hide should be removed when users are updated to refer to SyncState
568 * @deprecated use SyncState instead
569 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700570 @Deprecated
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700571 public interface SyncStateColumns extends SyncStateContract.Columns {
572 }
573
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500574 /**
Dave Santoro063084e2011-08-23 15:42:49 -0700575 * A table provided for sync adapters to use for storing private sync state data for contacts.
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500576 *
577 * @see SyncStateContract
578 */
579 public static final class SyncState implements SyncStateContract.Columns {
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700580 /**
581 * This utility class cannot be instantiated
582 */
583 private SyncState() {}
584
585 public static final String CONTENT_DIRECTORY =
586 SyncStateContract.Constants.CONTENT_DIRECTORY;
587
588 /**
589 * The content:// style URI for this table
590 */
591 public static final Uri CONTENT_URI =
592 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
593
594 /**
595 * @see android.provider.SyncStateContract.Helpers#get
596 */
597 public static byte[] get(ContentProviderClient provider, Account account)
598 throws RemoteException {
599 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
600 }
601
602 /**
Fred Quintanac4516a72009-09-03 12:14:06 -0700603 * @see android.provider.SyncStateContract.Helpers#get
604 */
605 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
606 throws RemoteException {
607 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
608 }
609
610 /**
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700611 * @see android.provider.SyncStateContract.Helpers#set
612 */
613 public static void set(ContentProviderClient provider, Account account, byte[] data)
614 throws RemoteException {
615 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
616 }
617
618 /**
619 * @see android.provider.SyncStateContract.Helpers#newSetOperation
620 */
621 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
622 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
623 }
624 }
625
Dave Santoro063084e2011-08-23 15:42:49 -0700626
627 /**
628 * A table provided for sync adapters to use for storing private sync state data for the
629 * user's personal profile.
630 *
631 * @see SyncStateContract
632 */
633 public static final class ProfileSyncState implements SyncStateContract.Columns {
634 /**
635 * This utility class cannot be instantiated
636 */
637 private ProfileSyncState() {}
638
639 public static final String CONTENT_DIRECTORY =
640 SyncStateContract.Constants.CONTENT_DIRECTORY;
641
642 /**
643 * The content:// style URI for this table
644 */
645 public static final Uri CONTENT_URI =
646 Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY);
647
648 /**
649 * @see android.provider.SyncStateContract.Helpers#get
650 */
651 public static byte[] get(ContentProviderClient provider, Account account)
652 throws RemoteException {
653 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
654 }
655
656 /**
657 * @see android.provider.SyncStateContract.Helpers#get
658 */
659 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
660 throws RemoteException {
661 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
662 }
663
664 /**
665 * @see android.provider.SyncStateContract.Helpers#set
666 */
667 public static void set(ContentProviderClient provider, Account account, byte[] data)
668 throws RemoteException {
669 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
670 }
671
672 /**
673 * @see android.provider.SyncStateContract.Helpers#newSetOperation
674 */
675 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
676 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
677 }
678 }
679
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700680 /**
681 * Generic columns for use by sync adapters. The specific functions of
682 * these columns are private to the sync adapter. Other clients of the API
683 * should not attempt to either read or write this column.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800684 *
685 * @see RawContacts
686 * @see Groups
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700687 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700688 protected interface BaseSyncColumns {
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700689
690 /** Generic column for use by sync adapters. */
691 public static final String SYNC1 = "sync1";
692 /** Generic column for use by sync adapters. */
693 public static final String SYNC2 = "sync2";
694 /** Generic column for use by sync adapters. */
695 public static final String SYNC3 = "sync3";
696 /** Generic column for use by sync adapters. */
697 public static final String SYNC4 = "sync4";
698 }
699
700 /**
701 * Columns that appear when each row of a table belongs to a specific
702 * account, including sync information that an account may need.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800703 *
704 * @see RawContacts
705 * @see Groups
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700706 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700707 protected interface SyncColumns extends BaseSyncColumns {
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700708 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500709 * The name of the account instance to which this row belongs, which when paired with
710 * {@link #ACCOUNT_TYPE} identifies a specific account.
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700711 * <P>Type: TEXT</P>
712 */
713 public static final String ACCOUNT_NAME = "account_name";
714
715 /**
716 * The type of account to which this row belongs, which when paired with
717 * {@link #ACCOUNT_NAME} identifies a specific account.
718 * <P>Type: TEXT</P>
719 */
720 public static final String ACCOUNT_TYPE = "account_type";
721
722 /**
723 * String that uniquely identifies this row to its source account.
724 * <P>Type: TEXT</P>
725 */
726 public static final String SOURCE_ID = "sourceid";
727
728 /**
729 * Version number that is updated whenever this row or its related data
730 * changes.
731 * <P>Type: INTEGER</P>
732 */
733 public static final String VERSION = "version";
734
735 /**
736 * Flag indicating that {@link #VERSION} has changed, and this row needs
737 * to be synchronized by its owning account.
738 * <P>Type: INTEGER (boolean)</P>
739 */
740 public static final String DIRTY = "dirty";
741 }
742
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800743 /**
Tom O'Neill244327e2010-01-08 11:11:15 -0800744 * Columns of {@link ContactsContract.Contacts} that track the user's
745 * preferences for, or interactions with, the contact.
746 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800747 * @see Contacts
748 * @see RawContacts
749 * @see ContactsContract.Data
750 * @see PhoneLookup
751 * @see ContactsContract.Contacts.AggregationSuggestions
752 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700753 protected interface ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700754 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500755 * The number of times a contact has been contacted
Evan Millar088b2912009-05-28 15:24:37 -0700756 * <P>Type: INTEGER</P>
757 */
758 public static final String TIMES_CONTACTED = "times_contacted";
759
760 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500761 * The last time a contact was contacted.
Evan Millar088b2912009-05-28 15:24:37 -0700762 * <P>Type: INTEGER</P>
763 */
764 public static final String LAST_TIME_CONTACTED = "last_time_contacted";
765
766 /**
767 * Is the contact starred?
768 * <P>Type: INTEGER (boolean)</P>
769 */
770 public static final String STARRED = "starred";
771
772 /**
Yorke Lee217d8a72013-11-27 10:14:04 -0800773 * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED},
Yorke Lee6acfa5d2013-07-17 09:55:26 -0700774 * the contact is not pinned. Also see {@link PinnedPositions}.
775 * <P>Type: INTEGER </P>
Yorke Lee6acfa5d2013-07-17 09:55:26 -0700776 */
777 public static final String PINNED = "pinned";
778
779 /**
Tom O'Neill244327e2010-01-08 11:11:15 -0800780 * URI for a custom ringtone associated with the contact. If null or missing,
781 * the default ringtone is used.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700782 * <P>Type: TEXT (URI to the ringtone)</P>
783 */
784 public static final String CUSTOM_RINGTONE = "custom_ringtone";
785
786 /**
Tom O'Neill244327e2010-01-08 11:11:15 -0800787 * Whether the contact should always be sent to voicemail. If missing,
788 * defaults to false.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700789 * <P>Type: INTEGER (0 for false, 1 for true)</P>
790 */
791 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700792 }
793
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800794 /**
Tom O'Neill244327e2010-01-08 11:11:15 -0800795 * Columns of {@link ContactsContract.Contacts} that refer to intrinsic
796 * properties of the contact, as opposed to the user-specified options
797 * found in {@link ContactOptionsColumns}.
798 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800799 * @see Contacts
800 * @see ContactsContract.Data
801 * @see PhoneLookup
802 * @see ContactsContract.Contacts.AggregationSuggestions
803 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700804 protected interface ContactsColumns {
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700805 /**
806 * The display name for the contact.
807 * <P>Type: TEXT</P>
808 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -0800809 public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY;
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700810
811 /**
Dmitri Plotnikov96186082009-12-01 14:35:04 -0800812 * Reference to the row in the RawContacts table holding the contact name.
813 * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P>
Dmitri Plotnikov96186082009-12-01 14:35:04 -0800814 */
815 public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
816
817 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700818 * Reference to the row in the data table holding the photo. A photo can
819 * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI}
820 * and {@link #PHOTO_URI}).
821 * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI},
822 * which is a more generic mechanism for referencing the contact photo, especially for
823 * contacts returned by non-local directories (see {@link Directory}).
824 *
Evan Millar088b2912009-05-28 15:24:37 -0700825 * <P>Type: INTEGER REFERENCES data(_id)</P>
826 */
827 public static final String PHOTO_ID = "photo_id";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700828
829 /**
Dave Santoroa5282372011-06-29 00:25:16 -0700830 * Photo file ID of the full-size photo. If present, this will be used to populate
831 * {@link #PHOTO_URI}. The ID can also be used with
832 * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo.
833 * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated.
834 *
835 * <P>Type: INTEGER</P>
836 */
837 public static final String PHOTO_FILE_ID = "photo_file_id";
838
839 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700840 * A URI that can be used to retrieve the contact's full-size photo.
Dave Santoroa5282372011-06-29 00:25:16 -0700841 * If PHOTO_FILE_ID is not null, this will be populated with a URI based off
842 * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will
843 * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700844 * A photo can be referred to either by a URI (this field) or by ID
Dave Santoroa5282372011-06-29 00:25:16 -0700845 * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null,
846 * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily
847 * vice versa). Thus using PHOTO_URI is a more robust method of retrieving
848 * contact photos.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700849 *
850 * <P>Type: TEXT</P>
851 */
852 public static final String PHOTO_URI = "photo_uri";
853
854 /**
855 * A URI that can be used to retrieve a thumbnail of the contact's photo.
856 * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI})
857 * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and
858 * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa).
859 * If the content provider does not differentiate between full-size photos
860 * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain
Dave Santoroa5282372011-06-29 00:25:16 -0700861 * the same value, but either both shall be null or both not null.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700862 *
863 * <P>Type: TEXT</P>
864 */
865 public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri";
866
867 /**
Brian Attwell2fa85d32014-03-04 17:41:13 -0800868 * Flag that reflects whether the contact exists inside the default directory.
869 * Ie, whether the contact is designed to only be visible outside search.
Brian Attwell2fa85d32014-03-04 17:41:13 -0800870 */
871 public static final String IN_DEFAULT_DIRECTORY = "in_default_directory";
872
873 /**
Dave Santoro43251332011-05-11 11:39:54 -0700874 * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any
875 * {@link CommonDataKinds.GroupMembership} for this contact.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700876 */
877 public static final String IN_VISIBLE_GROUP = "in_visible_group";
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700878
879 /**
Dave Santoro43251332011-05-11 11:39:54 -0700880 * Flag that reflects whether this contact represents the user's
881 * personal profile entry.
882 */
883 public static final String IS_USER_PROFILE = "is_user_profile";
884
885 /**
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700886 * An indicator of whether this contact has at least one phone number. "1" if there is
887 * at least one phone number, "0" otherwise.
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700888 * <P>Type: INTEGER</P>
889 */
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700890 public static final String HAS_PHONE_NUMBER = "has_phone_number";
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700891
892 /**
893 * An opaque value that contains hints on how to find the contact if
894 * its row id changed as a result of a sync or aggregation.
895 */
896 public static final String LOOKUP_KEY = "lookup";
Chiao Cheng2355d132013-03-20 16:54:06 -0700897
898 /**
899 * Timestamp (milliseconds since epoch) of when this contact was last updated. This
900 * includes updates to all data associated with this contact including raw contacts. Any
901 * modification (including deletes and inserts) of underlying contact data are also
902 * reflected in this timestamp.
903 */
904 public static final String CONTACT_LAST_UPDATED_TIMESTAMP =
905 "contact_last_updated_timestamp";
Evan Millar088b2912009-05-28 15:24:37 -0700906 }
907
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800908 /**
909 * @see Contacts
910 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700911 protected interface ContactStatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700912 /**
913 * Contact presence status. See {@link StatusUpdates} for individual status
914 * definitions.
915 * <p>Type: NUMBER</p>
916 */
917 public static final String CONTACT_PRESENCE = "contact_presence";
918
919 /**
Vasu Norifb5bccf2010-07-19 14:11:54 -0700920 * Contact Chat Capabilities. See {@link StatusUpdates} for individual
Vasu Nori5b314982010-07-12 15:13:37 -0700921 * definitions.
922 * <p>Type: NUMBER</p>
923 */
924 public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability";
925
926 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700927 * Contact's latest status update.
928 * <p>Type: TEXT</p>
929 */
930 public static final String CONTACT_STATUS = "contact_status";
931
932 /**
933 * The absolute time in milliseconds when the latest status was
934 * inserted/updated.
935 * <p>Type: NUMBER</p>
936 */
937 public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
938
939 /**
940 * The package containing resources for this status: label and icon.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800941 * <p>Type: TEXT</p>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700942 */
943 public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
944
945 /**
946 * The resource ID of the label describing the source of contact
947 * status, e.g. "Google Talk". This resource is scoped by the
948 * {@link #CONTACT_STATUS_RES_PACKAGE}.
949 * <p>Type: NUMBER</p>
950 */
951 public static final String CONTACT_STATUS_LABEL = "contact_status_label";
952
953 /**
954 * The resource ID of the icon for the source of contact status. This
955 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
956 * <p>Type: NUMBER</p>
957 */
958 public static final String CONTACT_STATUS_ICON = "contact_status_icon";
959 }
960
Evan Millar088b2912009-05-28 15:24:37 -0700961 /**
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800962 * Constants for various styles of combining given name, family name etc into
963 * a full name. For example, the western tradition follows the pattern
964 * 'given name' 'middle name' 'family name' with the alternative pattern being
965 * 'family name', 'given name' 'middle name'. The CJK tradition is
966 * 'family name' 'middle name' 'given name', with Japanese favoring a space between
967 * the names and Chinese omitting the space.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800968 */
969 public interface FullNameStyle {
970 public static final int UNDEFINED = 0;
971 public static final int WESTERN = 1;
972
973 /**
974 * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
975 * which specific language it belongs to: Chinese, Japanese or Korean.
976 */
977 public static final int CJK = 2;
978
979 public static final int CHINESE = 3;
980 public static final int JAPANESE = 4;
981 public static final int KOREAN = 5;
982 }
983
984 /**
985 * Constants for various styles of capturing the pronunciation of a person's name.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800986 */
987 public interface PhoneticNameStyle {
988 public static final int UNDEFINED = 0;
989
990 /**
991 * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
992 * shown in UIs, but used for searches and sorting.
993 */
994 public static final int PINYIN = 3;
995
996 /**
997 * Hiragana and Katakana are two common styles of writing out the pronunciation
998 * of a Japanese names.
999 */
1000 public static final int JAPANESE = 4;
1001
1002 /**
1003 * Hangul is the Korean phonetic alphabet.
1004 */
1005 public static final int KOREAN = 5;
1006 }
1007
1008 /**
Dmitri Plotnikovdbcdbf22011-02-23 15:49:58 -08001009 * Types of data used to produce the display name for a contact. In the order
1010 * of increasing priority: {@link #EMAIL}, {@link #PHONE},
1011 * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_NAME}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001012 */
1013 public interface DisplayNameSources {
1014 public static final int UNDEFINED = 0;
1015 public static final int EMAIL = 10;
1016 public static final int PHONE = 20;
1017 public static final int ORGANIZATION = 30;
1018 public static final int NICKNAME = 35;
1019 public static final int STRUCTURED_NAME = 40;
1020 }
1021
1022 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08001023 * Contact name and contact name metadata columns in the RawContacts table.
1024 *
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001025 * @see Contacts
1026 * @see RawContacts
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001027 */
1028 protected interface ContactNameColumns {
1029
1030 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001031 * The kind of data that is used as the display name for the contact, such as
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001032 * structured name or email address. See {@link DisplayNameSources}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001033 */
1034 public static final String DISPLAY_NAME_SOURCE = "display_name_source";
1035
1036 /**
Tom O'Neill093a8702010-01-15 16:20:34 -08001037 * <p>
1038 * The standard text shown as the contact's display name, based on the best
1039 * available information for the contact (for example, it might be the email address
1040 * if the name is not available).
1041 * The information actually used to compute the name is stored in
1042 * {@link #DISPLAY_NAME_SOURCE}.
1043 * </p>
1044 * <p>
1045 * A contacts provider is free to choose whatever representation makes most
1046 * sense for its target market.
1047 * For example in the default Android Open Source Project implementation,
1048 * if the display name is
1049 * based on the structured name and the structured name follows
1050 * the Western full-name style, then this field contains the "given name first"
1051 * version of the full name.
1052 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001053 *
1054 * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001055 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001056 public static final String DISPLAY_NAME_PRIMARY = "display_name";
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001057
1058 /**
Tom O'Neill093a8702010-01-15 16:20:34 -08001059 * <p>
1060 * An alternative representation of the display name, such as "family name first"
1061 * instead of "given name first" for Western names. If an alternative is not
1062 * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}.
1063 * </p>
1064 * <p>
1065 * A contacts provider is free to provide alternatives as necessary for
1066 * its target market.
1067 * For example the default Android Open Source Project contacts provider
1068 * currently provides an
1069 * alternative in a single case: if the display name is
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001070 * based on the structured name and the structured name follows
Tom O'Neill093a8702010-01-15 16:20:34 -08001071 * the Western full name style, then the field contains the "family name first"
1072 * version of the full name.
1073 * Other cases may be added later.
1074 * </p>
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001075 */
1076 public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
1077
1078 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001079 * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001080 * {@link PhoneticNameStyle}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001081 */
1082 public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
1083
1084 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001085 * <p>
1086 * Pronunciation of the full name in the phonetic alphabet specified by
1087 * {@link #PHONETIC_NAME_STYLE}.
1088 * </p>
1089 * <p>
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001090 * The value may be set manually by the user. This capability is of
1091 * interest only in countries with commonly used phonetic alphabets,
1092 * such as Japan and Korea. See {@link PhoneticNameStyle}.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001093 * </p>
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001094 */
1095 public static final String PHONETIC_NAME = "phonetic_name";
1096
1097 /**
1098 * Sort key that takes into account locale-based traditions for sorting
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001099 * names in address books. The default
1100 * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names
1101 * the sort key is the name's Pinyin spelling, and for Japanese names
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001102 * it is the Hiragana version of the phonetic name.
1103 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001104 public static final String SORT_KEY_PRIMARY = "sort_key";
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001105
1106 /**
1107 * Sort key based on the alternative representation of the full name,
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001108 * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names,
Dmitri Plotnikov2a650dd2010-01-26 17:28:52 -08001109 * it is the one using the "family name first" format.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001110 */
1111 public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
1112 }
1113
Yorke Lee94c87612014-07-18 18:57:17 -07001114 interface ContactCounts {
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001115
1116 /**
Yorke Lee94c87612014-07-18 18:57:17 -07001117 * Add this query parameter to a URI to get back row counts grouped by the address book
1118 * index as cursor extras. For most languages it is the first letter of the sort key. This
1119 * parameter does not affect the main content of the cursor.
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001120 *
Yorke Leef4b28452014-05-27 19:41:35 -07001121 * <p>
1122 * <pre>
1123 * Example:
Yorke Lee94c87612014-07-18 18:57:17 -07001124 *
1125 * import android.provider.ContactsContract.Contacts;
1126 *
Yorke Leef4b28452014-05-27 19:41:35 -07001127 * Uri uri = Contacts.CONTENT_URI.buildUpon()
Yorke Leea4aa9dc2014-08-04 13:47:50 -07001128 * .appendQueryParameter(Contacts.ADDRESS_BOOK_INDEX_EXTRAS, "true")
Yorke Leef4b28452014-05-27 19:41:35 -07001129 * .build();
1130 * Cursor cursor = getContentResolver().query(uri,
1131 * new String[] {Contacts.DISPLAY_NAME},
1132 * null, null, null);
1133 * Bundle bundle = cursor.getExtras();
Yorke Leea4aa9dc2014-08-04 13:47:50 -07001134 * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) &&
1135 * bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) {
Yorke Leef4b28452014-05-27 19:41:35 -07001136 * String sections[] =
Yorke Leea4aa9dc2014-08-04 13:47:50 -07001137 * bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
1138 * int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
Yorke Leef4b28452014-05-27 19:41:35 -07001139 * }
1140 * </pre>
1141 * </p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001142 */
1143 public static final String ADDRESS_BOOK_INDEX_EXTRAS = "address_book_index_extras";
1144
1145 /**
1146 * The array of address book index titles, which are returned in the
1147 * same order as the data in the cursor.
1148 * <p>TYPE: String[]</p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001149 */
1150 public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "address_book_index_titles";
1151
1152 /**
1153 * The array of group counts for the corresponding group. Contains the same number
1154 * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
1155 * <p>TYPE: int[]</p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001156 */
1157 public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "address_book_index_counts";
1158 }
1159
1160 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001161 * Constants for the contacts table, which contains a record per aggregate
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001162 * of raw contacts representing the same person.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001163 * <h3>Operations</h3>
1164 * <dl>
1165 * <dt><b>Insert</b></dt>
1166 * <dd>A Contact cannot be created explicitly. When a raw contact is
1167 * inserted, the provider will first try to find a Contact representing the
1168 * same person. If one is found, the raw contact's
1169 * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
1170 * Contact. If no match is found, the provider automatically inserts a new
1171 * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
1172 * of the newly inserted raw contact.</dd>
1173 * <dt><b>Update</b></dt>
1174 * <dd>Only certain columns of Contact are modifiable:
1175 * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
1176 * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
1177 * these columns on the Contact also changes them on all constituent raw
1178 * contacts.</dd>
1179 * <dt><b>Delete</b></dt>
1180 * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
1181 * deletes all constituent raw contacts. The corresponding sync adapters
1182 * will notice the deletions of their respective raw contacts and remove
1183 * them from their back end storage.</dd>
1184 * <dt><b>Query</b></dt>
1185 * <dd>
1186 * <ul>
1187 * <li>If you need to read an individual contact, consider using
1188 * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
1189 * <li>If you need to look up a contact by the phone number, use
1190 * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
1191 * which is optimized for this purpose.</li>
1192 * <li>If you need to look up a contact by partial name, e.g. to produce
1193 * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
1194 * <li>If you need to look up a contact by some data element like email
1195 * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
1196 * The result will contain contact ID, name etc.
1197 * </ul>
1198 * </dd>
1199 * </dl>
1200 * <h2>Columns</h2>
1201 * <table class="jd-sumtable">
1202 * <tr>
1203 * <th colspan='4'>Contacts</th>
1204 * </tr>
1205 * <tr>
1206 * <td>long</td>
1207 * <td>{@link #_ID}</td>
1208 * <td>read-only</td>
1209 * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
1210 * </tr>
1211 * <tr>
1212 * <td>String</td>
1213 * <td>{@link #LOOKUP_KEY}</td>
1214 * <td>read-only</td>
1215 * <td>An opaque value that contains hints on how to find the contact if its
1216 * row id changed as a result of a sync or aggregation.</td>
1217 * </tr>
1218 * <tr>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001219 * <td>long</td>
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001220 * <td>NAME_RAW_CONTACT_ID</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001221 * <td>read-only</td>
1222 * <td>The ID of the raw contact that contributes the display name
1223 * to the aggregate contact. During aggregation one of the constituent
1224 * raw contacts is chosen using a heuristic: a longer name or a name
1225 * with more diacritic marks or more upper case characters is chosen.</td>
1226 * </tr>
1227 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001228 * <td>String</td>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001229 * <td>DISPLAY_NAME_PRIMARY</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001230 * <td>read-only</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001231 * <td>The display name for the contact. It is the display name
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001232 * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001233 * column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001234 * </tr>
1235 * <tr>
1236 * <td>long</td>
1237 * <td>{@link #PHOTO_ID}</td>
1238 * <td>read-only</td>
1239 * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
1240 * That row has the mime type
1241 * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
1242 * is computed automatically based on the
1243 * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
1244 * that mime type.</td>
1245 * </tr>
1246 * <tr>
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -07001247 * <td>long</td>
1248 * <td>{@link #PHOTO_URI}</td>
1249 * <td>read-only</td>
1250 * <td>A URI that can be used to retrieve the contact's full-size photo. This
1251 * column is the preferred method of retrieving the contact photo.</td>
1252 * </tr>
1253 * <tr>
1254 * <td>long</td>
1255 * <td>{@link #PHOTO_THUMBNAIL_URI}</td>
1256 * <td>read-only</td>
1257 * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This
1258 * column is the preferred method of retrieving the contact photo.</td>
1259 * </tr>
1260 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001261 * <td>int</td>
1262 * <td>{@link #IN_VISIBLE_GROUP}</td>
1263 * <td>read-only</td>
1264 * <td>An indicator of whether this contact is supposed to be visible in the
1265 * UI. "1" if the contact has at least one raw contact that belongs to a
1266 * visible group; "0" otherwise.</td>
1267 * </tr>
1268 * <tr>
1269 * <td>int</td>
1270 * <td>{@link #HAS_PHONE_NUMBER}</td>
1271 * <td>read-only</td>
1272 * <td>An indicator of whether this contact has at least one phone number.
1273 * "1" if there is at least one phone number, "0" otherwise.</td>
1274 * </tr>
1275 * <tr>
1276 * <td>int</td>
1277 * <td>{@link #TIMES_CONTACTED}</td>
1278 * <td>read/write</td>
1279 * <td>The number of times the contact has been contacted. See
1280 * {@link #markAsContacted}. When raw contacts are aggregated, this field is
1281 * computed automatically as the maximum number of times contacted among all
1282 * constituent raw contacts. Setting this field automatically changes the
1283 * corresponding field on all constituent raw contacts.</td>
1284 * </tr>
1285 * <tr>
1286 * <td>long</td>
1287 * <td>{@link #LAST_TIME_CONTACTED}</td>
1288 * <td>read/write</td>
1289 * <td>The timestamp of the last time the contact was contacted. See
1290 * {@link #markAsContacted}. Setting this field also automatically
1291 * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
1292 * this field is computed automatically as the latest time contacted of all
1293 * constituent raw contacts. Setting this field automatically changes the
1294 * corresponding field on all constituent raw contacts.</td>
1295 * </tr>
1296 * <tr>
1297 * <td>int</td>
1298 * <td>{@link #STARRED}</td>
1299 * <td>read/write</td>
1300 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
1301 * When raw contacts are aggregated, this field is automatically computed:
1302 * if any constituent raw contacts are starred, then this field is set to
1303 * '1'. Setting this field automatically changes the corresponding field on
1304 * all constituent raw contacts.</td>
1305 * </tr>
1306 * <tr>
1307 * <td>String</td>
1308 * <td>{@link #CUSTOM_RINGTONE}</td>
1309 * <td>read/write</td>
1310 * <td>A custom ringtone associated with a contact. Typically this is the
1311 * URI returned by an activity launched with the
1312 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
1313 * </tr>
1314 * <tr>
1315 * <td>int</td>
1316 * <td>{@link #SEND_TO_VOICEMAIL}</td>
1317 * <td>read/write</td>
1318 * <td>An indicator of whether calls from this contact should be forwarded
1319 * directly to voice mail ('1') or not ('0'). When raw contacts are
1320 * aggregated, this field is automatically computed: if <i>all</i>
1321 * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
1322 * to '1'. Setting this field automatically changes the corresponding field
1323 * on all constituent raw contacts.</td>
1324 * </tr>
1325 * <tr>
1326 * <td>int</td>
1327 * <td>{@link #CONTACT_PRESENCE}</td>
1328 * <td>read-only</td>
1329 * <td>Contact IM presence status. See {@link StatusUpdates} for individual
1330 * status definitions. Automatically computed as the highest presence of all
1331 * constituent raw contacts. The provider may choose not to store this value
1332 * in persistent storage. The expectation is that presence status will be
kmccormick50e27c82013-03-28 16:33:11 -07001333 * updated on a regular basis.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001334 * </tr>
1335 * <tr>
1336 * <td>String</td>
1337 * <td>{@link #CONTACT_STATUS}</td>
1338 * <td>read-only</td>
1339 * <td>Contact's latest status update. Automatically computed as the latest
1340 * of all constituent raw contacts' status updates.</td>
1341 * </tr>
1342 * <tr>
1343 * <td>long</td>
1344 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
1345 * <td>read-only</td>
1346 * <td>The absolute time in milliseconds when the latest status was
1347 * inserted/updated.</td>
1348 * </tr>
1349 * <tr>
1350 * <td>String</td>
1351 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
1352 * <td>read-only</td>
1353 * <td> The package containing resources for this status: label and icon.</td>
1354 * </tr>
1355 * <tr>
1356 * <td>long</td>
1357 * <td>{@link #CONTACT_STATUS_LABEL}</td>
1358 * <td>read-only</td>
1359 * <td>The resource ID of the label describing the source of contact status,
1360 * e.g. "Google Talk". This resource is scoped by the
1361 * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1362 * </tr>
1363 * <tr>
1364 * <td>long</td>
1365 * <td>{@link #CONTACT_STATUS_ICON}</td>
1366 * <td>read-only</td>
1367 * <td>The resource ID of the icon for the source of contact status. This
1368 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1369 * </tr>
1370 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07001371 */
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07001372 public static class Contacts implements BaseColumns, ContactsColumns,
Yorke Lee94c87612014-07-18 18:57:17 -07001373 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts {
Evan Millar088b2912009-05-28 15:24:37 -07001374 /**
1375 * This utility class cannot be instantiated
1376 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001377 private Contacts() {}
Evan Millar088b2912009-05-28 15:24:37 -07001378
1379 /**
1380 * The content:// style URI for this table
1381 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001382 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
Evan Millar088b2912009-05-28 15:24:37 -07001383
1384 /**
Makoto Onuki31cd6f72014-07-08 15:20:39 -07001385 * Special contacts URI to refer to contacts on the corp profile from the personal
1386 * profile.
1387 *
1388 * It's supported only by a few specific places for referring to contact pictures that
1389 * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from
1390 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI.
1391 *
1392 * @hide
1393 */
1394 public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
1395 "contacts_corp");
1396
1397 /**
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001398 * A content:// style URI for this table that should be used to create
1399 * shortcuts or otherwise create long-term links to contacts. This URI
1400 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
1401 * It can optionally also have a "/" and last known contact ID appended after
1402 * that. This "complete" format is an important optimization and is highly recommended.
1403 * <p>
1404 * As long as the contact's row ID remains the same, this URI is
1405 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
1406 * as a result of a sync or aggregation, this URI will look up the
1407 * contact using indirect information (sync IDs or constituent raw
1408 * contacts).
1409 * <p>
1410 * Lookup key should be appended unencoded - it is stored in the encoded
1411 * form, ready for use in a URI.
1412 */
1413 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1414 "lookup");
1415
1416 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001417 * Base {@link Uri} for referencing a single {@link Contacts} entry,
Jeff Sharkey8f767342009-09-28 18:22:46 -07001418 * created by appending {@link #LOOKUP_KEY} using
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001419 * {@link Uri#withAppendedPath(Uri, String)}. Provides
1420 * {@link OpenableColumns} columns when queried, or returns the
1421 * referenced contact formatted as a vCard when opened through
1422 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1423 */
1424 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1425 "as_vcard");
1426
Martijn Coenen037d3ff2011-06-15 16:01:45 +02001427 /**
1428 * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI}
1429 * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned
1430 * vcard should not contain a photo.
1431 *
1432 * @hide
1433 */
1434 public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "nophoto";
1435
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001436 /**
Daniel Lehmann63e91402010-03-12 13:44:31 -08001437 * Base {@link Uri} for referencing multiple {@link Contacts} entry,
1438 * created by appending {@link #LOOKUP_KEY} using
1439 * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
Yorke Lee217d8a72013-11-27 10:14:04 -08001440 * joined with the colon (":") separator, and the resulting string encoded.
1441 *
1442 * Provides {@link OpenableColumns} columns when queried, or returns the
Daniel Lehmann63e91402010-03-12 13:44:31 -08001443 * referenced contact formatted as a vCard when opened through
1444 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1445 *
Yorke Lee217d8a72013-11-27 10:14:04 -08001446 * <p>
1447 * Usage example:
1448 * <dl>
1449 * <dt>The following code snippet creates a multi-vcard URI that references all the
1450 * contacts in a user's database.</dt>
1451 * <dd>
Daniel Lehmann63e91402010-03-12 13:44:31 -08001452 *
Yorke Lee217d8a72013-11-27 10:14:04 -08001453 * <pre>
1454 * public Uri getAllContactsVcardUri() {
1455 * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI,
1456 * new String[] {Contacts.LOOKUP_KEY}, null, null, null);
1457 * if (cursor == null) {
1458 * return null;
1459 * }
1460 * try {
1461 * StringBuilder uriListBuilder = new StringBuilder();
1462 * int index = 0;
1463 * while (cursor.moveToNext()) {
1464 * if (index != 0) uriListBuilder.append(':');
1465 * uriListBuilder.append(cursor.getString(0));
1466 * index++;
1467 * }
1468 * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI,
1469 * Uri.encode(uriListBuilder.toString()));
1470 * } finally {
1471 * cursor.close();
1472 * }
1473 * }
1474 * </pre>
1475 *
1476 * </p>
Daniel Lehmann63e91402010-03-12 13:44:31 -08001477 */
1478 public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1479 "as_multi_vcard");
1480
1481 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001482 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
1483 * requested {@link Contacts} entry.
1484 *
1485 * @param contactUri A {@link #CONTENT_URI} row, or an existing
1486 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001487 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001488 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
1489 final Cursor c = resolver.query(contactUri, new String[] {
1490 Contacts.LOOKUP_KEY, Contacts._ID
1491 }, null, null, null);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001492 if (c == null) {
1493 return null;
1494 }
1495
1496 try {
1497 if (c.moveToFirst()) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001498 final String lookupKey = c.getString(0);
1499 final long contactId = c.getLong(1);
1500 return getLookupUri(contactId, lookupKey);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001501 }
1502 } finally {
1503 c.close();
1504 }
1505 return null;
1506 }
1507
1508 /**
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001509 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001510 * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001511 */
1512 public static Uri getLookupUri(long contactId, String lookupKey) {
1513 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
1514 lookupKey), contactId);
1515 }
1516
1517 /**
Dmitri Plotnikovb5759b52009-09-01 15:58:40 -07001518 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
1519 * <p>
1520 * Returns null if the contact cannot be found.
1521 */
1522 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
1523 if (lookupUri == null) {
1524 return null;
1525 }
1526
1527 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
1528 if (c == null) {
1529 return null;
1530 }
1531
1532 try {
1533 if (c.moveToFirst()) {
1534 long contactId = c.getLong(0);
1535 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1536 }
1537 } finally {
1538 c.close();
1539 }
1540 return null;
1541 }
1542
1543 /**
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001544 * Mark a contact as having been contacted. Updates two fields:
1545 * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The
1546 * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED
1547 * field is populated with the current system time.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001548 *
1549 * @param resolver the ContentResolver to use
1550 * @param contactId the person who was contacted
Daniel Lehmanna1620dc2012-04-13 13:29:49 -07001551 *
1552 * @deprecated The class DataUsageStatUpdater of the Android support library should
1553 * be used instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001554 */
Daniel Lehmanna1620dc2012-04-13 13:29:49 -07001555 @Deprecated
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001556 public static void markAsContacted(ContentResolver resolver, long contactId) {
1557 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
1558 ContentValues values = new ContentValues();
1559 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
1560 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
1561 resolver.update(uri, values, null, null);
1562 }
1563
1564 /**
Evan Millar161dd862009-06-12 16:02:43 -07001565 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001566 * {@link #CONTENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001567 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -07001568 * as an additional path segment after this URI.
1569 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001570 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
1571 CONTENT_URI, "filter");
1572
Evan Millardc2da5f2009-06-18 16:07:13 -07001573 /**
1574 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001575 * {@link ContactsContract.Data}, filtered to include only starred contacts
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001576 * and the most frequently contacted contacts.
Evan Millardc2da5f2009-06-18 16:07:13 -07001577 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001578 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
1579 CONTENT_URI, "strequent");
1580
Evan Millardc2da5f2009-06-18 16:07:13 -07001581 /**
Yorke Lee8d370092014-06-26 10:32:17 -07001582 * The content:// style URI for showing a list of frequently contacted people.
Daisuke Miyakawa3604bc52011-07-21 10:14:32 -07001583 */
1584 public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath(
1585 CONTENT_URI, "frequent");
1586
1587 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07001588 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001589 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001590 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -07001591 * as an additional path segment after this URI.
1592 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001593 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
1594 CONTENT_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001595
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001596 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
1597 CONTENT_URI, "group");
1598
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001599 /**
Evan Millar088b2912009-05-28 15:24:37 -07001600 * The MIME type of {@link #CONTENT_URI} providing a directory of
1601 * people.
1602 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001603 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001604
1605 /**
1606 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1607 * person.
1608 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001609 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001610
1611 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001612 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1613 * person.
1614 */
1615 public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
1616
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001617
1618 /**
1619 * Mimimal ID for corp contacts returned from
1620 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
1621 *
1622 * @hide
1623 */
Makoto Onuki0e917332014-08-26 14:06:30 -07001624 public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001625
1626 /**
Makoto Onuki0e917332014-08-26 14:06:30 -07001627 * Return TRUE if a contact ID is from the contacts provider on the enterprise profile.
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001628 *
1629 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact.
1630 */
Makoto Onuki0e917332014-08-26 14:06:30 -07001631 public static boolean isEnterpriseContactId(long contactId) {
1632 return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001633 }
1634
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001635 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001636 * A sub-directory of a single contact that contains all of the constituent raw contact
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001637 * {@link ContactsContract.Data} rows. This directory can be used either
1638 * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07001639 */
Fred Quintana8851e162009-08-05 21:06:45 -07001640 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07001641 /**
1642 * no public constructor since this is a utility class
1643 */
1644 private Data() {}
1645
1646 /**
1647 * The directory twig for this sub-table
1648 */
1649 public static final String CONTENT_DIRECTORY = "data";
1650 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001651
1652 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001653 * <p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001654 * A sub-directory of a contact that contains all of its
1655 * {@link ContactsContract.RawContacts} as well as
1656 * {@link ContactsContract.Data} rows. To access this directory append
1657 * {@link #CONTENT_DIRECTORY} to the contact URI.
1658 * </p>
1659 * <p>
1660 * Entity has three ID fields: {@link #CONTACT_ID} for the contact,
1661 * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for
1662 * the data rows. Entity always contains at least one row per
1663 * constituent raw contact, even if there are no actual data rows. In
1664 * this case the {@link #DATA_ID} field will be null.
1665 * </p>
1666 * <p>
1667 * Entity reads all data for the entire contact in one transaction, to
1668 * guarantee consistency. There is significant data duplication
1669 * in the Entity (each row repeats all Contact columns and all RawContact
1670 * columns), so the benefits of transactional consistency should be weighed
1671 * against the cost of transferring large amounts of denormalized data
1672 * from the Provider.
1673 * </p>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07001674 * <p>
1675 * To reduce the amount of data duplication the contacts provider and directory
1676 * providers implementing this protocol are allowed to provide common Contacts
1677 * and RawContacts fields in the first row returned for each raw contact only and
1678 * leave them as null in subsequent rows.
1679 * </p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001680 */
1681 public static final class Entity implements BaseColumns, ContactsColumns,
1682 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns,
Paul Soulos42cdda82014-06-19 16:13:38 -07001683 StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns {
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001684 /**
1685 * no public constructor since this is a utility class
1686 */
1687 private Entity() {
1688 }
1689
1690 /**
1691 * The directory twig for this sub-table
1692 */
1693 public static final String CONTENT_DIRECTORY = "entities";
1694
1695 /**
1696 * The ID of the raw contact row.
1697 * <P>Type: INTEGER</P>
1698 */
1699 public static final String RAW_CONTACT_ID = "raw_contact_id";
1700
1701 /**
1702 * The ID of the data row. The value will be null if this raw contact has no
1703 * data rows.
1704 * <P>Type: INTEGER</P>
1705 */
1706 public static final String DATA_ID = "data_id";
1707 }
1708
1709 /**
Dave Santoro0b61f592011-10-03 18:25:26 -07001710 * <p>
Dave Santorod414f102011-06-20 14:35:06 -07001711 * A sub-directory of a single contact that contains all of the constituent raw contact
1712 * {@link ContactsContract.StreamItems} rows. This directory can be used either
1713 * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
Dave Santoro0b61f592011-10-03 18:25:26 -07001714 * </p>
1715 * <p>
1716 * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM
1717 * permission.
1718 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07001719 *
1720 * @deprecated - Do not use. This will not be supported in the future. In the future,
1721 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001722 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001723 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001724 public static final class StreamItems implements StreamItemsColumns {
1725 /**
1726 * no public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07001727 *
1728 * @deprecated - Do not use. This will not be supported in the future. In the future,
1729 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001730 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001731 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001732 private StreamItems() {}
1733
1734 /**
1735 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07001736 *
1737 * @deprecated - Do not use. This will not be supported in the future. In the future,
1738 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001739 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001740 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001741 public static final String CONTENT_DIRECTORY = "stream_items";
1742 }
1743
1744 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001745 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001746 * A <i>read-only</i> sub-directory of a single contact aggregate that
1747 * contains all aggregation suggestions (other contacts). The
1748 * aggregation suggestions are computed based on approximate data
1749 * matches with this contact.
1750 * </p>
1751 * <p>
1752 * <i>Note: this query may be expensive! If you need to use it in bulk,
1753 * make sure the user experience is acceptable when the query runs for a
1754 * long time.</i>
1755 * <p>
1756 * Usage example:
1757 *
1758 * <pre>
1759 * Uri uri = Contacts.CONTENT_URI.buildUpon()
1760 * .appendEncodedPath(String.valueOf(contactId))
1761 * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
1762 * .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
1763 * .build()
1764 * Cursor cursor = getContentResolver().query(suggestionsUri,
1765 * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
1766 * null, null, null);
1767 * </pre>
1768 *
1769 * </p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001770 * <p>
1771 * This directory can be used either with a {@link #CONTENT_URI} or
1772 * {@link #CONTENT_LOOKUP_URI}.
1773 * </p>
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001774 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001775 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns,
1776 ContactOptionsColumns, ContactStatusColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001777 /**
1778 * No public constructor since this is a utility class
1779 */
1780 private AggregationSuggestions() {}
1781
1782 /**
Dmitri Plotnikov0fc02442009-09-21 13:26:28 -07001783 * The directory twig for this sub-table. The URI can be followed by an optional
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001784 * type-to-filter, similar to
1785 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001786 */
1787 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001788
1789 /**
1790 * Used with {@link Builder#addParameter} to specify what kind of data is
1791 * supplied for the suggestion query.
1792 *
1793 * @hide
1794 */
1795 public static final String PARAMETER_MATCH_NAME = "name";
1796
1797 /**
1798 * Used with {@link Builder#addParameter} to specify what kind of data is
1799 * supplied for the suggestion query.
1800 *
1801 * @hide
1802 */
1803 public static final String PARAMETER_MATCH_EMAIL = "email";
1804
1805 /**
1806 * Used with {@link Builder#addParameter} to specify what kind of data is
1807 * supplied for the suggestion query.
1808 *
1809 * @hide
1810 */
1811 public static final String PARAMETER_MATCH_PHONE = "phone";
1812
1813 /**
1814 * Used with {@link Builder#addParameter} to specify what kind of data is
1815 * supplied for the suggestion query.
1816 *
1817 * @hide
1818 */
1819 public static final String PARAMETER_MATCH_NICKNAME = "nickname";
1820
1821 /**
1822 * A convenience builder for aggregation suggestion content URIs.
1823 *
1824 * TODO: change documentation for this class to use the builder.
1825 * @hide
1826 */
1827 public static final class Builder {
1828 private long mContactId;
1829 private ArrayList<String> mKinds = new ArrayList<String>();
1830 private ArrayList<String> mValues = new ArrayList<String>();
1831 private int mLimit;
1832
1833 /**
1834 * Optional existing contact ID. If it is not provided, the search
1835 * will be based exclusively on the values supplied with {@link #addParameter}.
1836 */
1837 public Builder setContactId(long contactId) {
1838 this.mContactId = contactId;
1839 return this;
1840 }
1841
1842 /**
1843 * A value that can be used when searching for an aggregation
1844 * suggestion.
1845 *
1846 * @param kind can be one of
1847 * {@link AggregationSuggestions#PARAMETER_MATCH_NAME},
1848 * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL},
1849 * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME},
1850 * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE}
1851 */
1852 public Builder addParameter(String kind, String value) {
1853 if (!TextUtils.isEmpty(value)) {
1854 mKinds.add(kind);
1855 mValues.add(value);
1856 }
1857 return this;
1858 }
1859
1860 public Builder setLimit(int limit) {
1861 mLimit = limit;
1862 return this;
1863 }
1864
1865 public Uri build() {
1866 android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon();
1867 builder.appendEncodedPath(String.valueOf(mContactId));
1868 builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY);
1869 if (mLimit != 0) {
1870 builder.appendQueryParameter("limit", String.valueOf(mLimit));
1871 }
1872
1873 int count = mKinds.size();
1874 for (int i = 0; i < count; i++) {
1875 builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i));
1876 }
1877
1878 return builder.build();
1879 }
1880 }
1881
1882 /**
1883 * @hide
1884 */
1885 public static final Builder builder() {
1886 return new Builder();
1887 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001888 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001889
1890 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001891 * A <i>read-only</i> sub-directory of a single contact that contains
Dave Santoroa5282372011-06-29 00:25:16 -07001892 * the contact's primary photo. The photo may be stored in up to two ways -
1893 * the default "photo" is a thumbnail-sized image stored directly in the data
1894 * row, while the "display photo", if present, is a larger version stored as
1895 * a file.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001896 * <p>
1897 * Usage example:
Dave Santoroa5282372011-06-29 00:25:16 -07001898 * <dl>
1899 * <dt>Retrieving the thumbnail-sized photo</dt>
1900 * <dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001901 * <pre>
1902 * public InputStream openPhoto(long contactId) {
1903 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1904 * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
1905 * Cursor cursor = getContentResolver().query(photoUri,
1906 * new String[] {Contacts.Photo.PHOTO}, null, null, null);
1907 * if (cursor == null) {
1908 * return null;
1909 * }
1910 * try {
1911 * if (cursor.moveToFirst()) {
1912 * byte[] data = cursor.getBlob(0);
1913 * if (data != null) {
1914 * return new ByteArrayInputStream(data);
1915 * }
1916 * }
1917 * } finally {
1918 * cursor.close();
1919 * }
1920 * return null;
1921 * }
1922 * </pre>
Dave Santoroa5282372011-06-29 00:25:16 -07001923 * </dd>
1924 * <dt>Retrieving the larger photo version</dt>
1925 * <dd>
1926 * <pre>
1927 * public InputStream openDisplayPhoto(long contactId) {
1928 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1929 * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
1930 * try {
1931 * AssetFileDescriptor fd =
Dave Santoro040e6b32011-07-15 15:14:08 -07001932 * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
Dave Santoroa5282372011-06-29 00:25:16 -07001933 * return fd.createInputStream();
Dave Santoro040e6b32011-07-15 15:14:08 -07001934 * } catch (IOException e) {
Dave Santoroa5282372011-06-29 00:25:16 -07001935 * return null;
1936 * }
1937 * }
1938 * </pre>
1939 * </dd>
1940 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001941 *
1942 * </p>
Dave Santoroa5282372011-06-29 00:25:16 -07001943 * <p>You may also consider using the convenience method
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001944 * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)}
1945 * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001946 * </p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001947 * <p>
1948 * This directory can be used either with a {@link #CONTENT_URI} or
1949 * {@link #CONTENT_LOOKUP_URI}.
1950 * </p>
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001951 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001952 public static final class Photo implements BaseColumns, DataColumnsWithJoins {
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001953 /**
1954 * no public constructor since this is a utility class
1955 */
1956 private Photo() {}
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07001957
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001958 /**
1959 * The directory twig for this sub-table
1960 */
1961 public static final String CONTENT_DIRECTORY = "photo";
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001962
1963 /**
Dave Santoroa5282372011-06-29 00:25:16 -07001964 * The directory twig for retrieving the full-size display photo.
1965 */
1966 public static final String DISPLAY_PHOTO = "display_photo";
1967
1968 /**
1969 * Full-size photo file ID of the raw contact.
1970 * See {@link ContactsContract.DisplayPhoto}.
1971 * <p>
1972 * Type: NUMBER
1973 */
1974 public static final String PHOTO_FILE_ID = DATA14;
1975
1976 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001977 * Thumbnail photo of the raw contact. This is the raw bytes of an image
1978 * that could be inflated using {@link android.graphics.BitmapFactory}.
1979 * <p>
1980 * Type: BLOB
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001981 */
1982 public static final String PHOTO = DATA15;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001983 }
1984
1985 /**
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001986 * Opens an InputStream for the contacts's photo and returns the
1987 * photo as a byte stream.
1988 * @param cr The content resolver to use for querying
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001989 * @param contactUri the contact whose photo should be used. This can be used with
1990 * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001991 * @param preferHighres If this is true and the contact has a higher resolution photo
1992 * available, it is returned. If false, this function always tries to get the thumbnail
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001993 * @return an InputStream of the photo, or null if no photo is present
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001994 */
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001995 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri,
1996 boolean preferHighres) {
1997 if (preferHighres) {
1998 final Uri displayPhotoUri = Uri.withAppendedPath(contactUri,
1999 Contacts.Photo.DISPLAY_PHOTO);
2000 InputStream inputStream;
2001 try {
2002 AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r");
2003 return fd.createInputStream();
2004 } catch (IOException e) {
2005 // fallback to the thumbnail code
2006 }
2007 }
2008
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07002009 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07002010 if (photoUri == null) {
2011 return null;
2012 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002013 Cursor cursor = cr.query(photoUri,
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002014 new String[] {
2015 ContactsContract.CommonDataKinds.Photo.PHOTO
2016 }, null, null, null);
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002017 try {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07002018 if (cursor == null || !cursor.moveToNext()) {
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002019 return null;
2020 }
2021 byte[] data = cursor.getBlob(0);
2022 if (data == null) {
2023 return null;
2024 }
2025 return new ByteArrayInputStream(data);
2026 } finally {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07002027 if (cursor != null) {
2028 cursor.close();
2029 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002030 }
2031 }
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002032
2033 /**
2034 * Opens an InputStream for the contacts's thumbnail photo and returns the
2035 * photo as a byte stream.
2036 * @param cr The content resolver to use for querying
2037 * @param contactUri the contact whose photo should be used. This can be used with
2038 * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
2039 * @return an InputStream of the photo, or null if no photo is present
2040 * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead
2041 * of the thumbnail the high-res picture is preferred
2042 */
2043 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
2044 return openContactPhotoInputStream(cr, contactUri, false);
2045 }
Evan Millar088b2912009-05-28 15:24:37 -07002046 }
2047
Dave Santoro43251332011-05-11 11:39:54 -07002048 /**
2049 * <p>
2050 * Constants for the user's profile data, which is represented as a single contact on
2051 * the device that represents the user. The profile contact is not aggregated
2052 * together automatically in the same way that normal contacts are; instead, each
Dave Santoro063084e2011-08-23 15:42:49 -07002053 * account (including data set, if applicable) on the device may contribute a single
2054 * raw contact representing the user's personal profile data from that source.
Dave Santoro43251332011-05-11 11:39:54 -07002055 * </p>
2056 * <p>
2057 * Access to the profile entry through these URIs (or incidental access to parts of
2058 * the profile if retrieved directly via ID) requires additional permissions beyond
2059 * the read/write contact permissions required by the provider. Querying for profile
2060 * data requires android.permission.READ_PROFILE permission, and inserting or
2061 * updating profile data requires android.permission.WRITE_PROFILE permission.
2062 * </p>
2063 * <h3>Operations</h3>
2064 * <dl>
2065 * <dt><b>Insert</b></dt>
2066 * <dd>The user's profile entry cannot be created explicitly (attempting to do so
2067 * will throw an exception). When a raw contact is inserted into the profile, the
2068 * provider will check for the existence of a profile on the device. If one is
2069 * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of
2070 * the profile Contact. If no match is found, the profile Contact is created and
2071 * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly
2072 * inserted raw contact.</dd>
2073 * <dt><b>Update</b></dt>
2074 * <dd>The profile Contact has the same update restrictions as Contacts in general,
2075 * but requires the android.permission.WRITE_PROFILE permission.</dd>
2076 * <dt><b>Delete</b></dt>
2077 * <dd>The profile Contact cannot be explicitly deleted. It will be removed
2078 * automatically if all of its constituent raw contact entries are deleted.</dd>
2079 * <dt><b>Query</b></dt>
2080 * <dd>
2081 * <ul>
2082 * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as
2083 * retrieving a contact by ID, except that it will only ever return the user's
2084 * profile contact.
2085 * </li>
2086 * <li>
2087 * The profile contact supports all of the same sub-paths as an individual contact
2088 * does - the content of the profile contact can be retrieved as entities or
2089 * data rows. Similarly, specific raw contact entries can be retrieved by appending
2090 * the desired raw contact ID within the profile.
2091 * </li>
2092 * </ul>
2093 * </dd>
2094 * </dl>
2095 */
2096 public static final class Profile implements BaseColumns, ContactsColumns,
2097 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
2098 /**
2099 * This utility class cannot be instantiated
2100 */
2101 private Profile() {
2102 }
2103
2104 /**
2105 * The content:// style URI for this table, which requests the contact entry
2106 * representing the user's personal profile data.
2107 */
2108 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile");
2109
2110 /**
2111 * {@link Uri} for referencing the user's profile {@link Contacts} entry,
2112 * Provides {@link OpenableColumns} columns when queried, or returns the
2113 * user's profile contact formatted as a vCard when opened through
2114 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
2115 */
2116 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
2117 "as_vcard");
2118
2119 /**
2120 * {@link Uri} for referencing the raw contacts that make up the user's profile
2121 * {@link Contacts} entry. An individual raw contact entry within the profile
2122 * can be addressed by appending the raw contact ID. The entities or data within
2123 * that specific raw contact can be requested by appending the entity or data
2124 * path as well.
2125 */
2126 public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI,
2127 "raw_contacts");
Dave Santoro063084e2011-08-23 15:42:49 -07002128
2129 /**
2130 * The minimum ID for any entity that belongs to the profile. This essentially
2131 * defines an ID-space in which profile data is stored, and is used by the provider
2132 * to determine whether a request via a non-profile-specific URI should be directed
2133 * to the profile data rather than general contacts data, along with all the special
2134 * permission checks that entails.
2135 *
2136 * Callers may use {@link #isProfileId} to check whether a specific ID falls into
2137 * the set of data intended for the profile.
2138 */
2139 public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE;
2140 }
2141
2142 /**
2143 * This method can be used to identify whether the given ID is associated with profile
2144 * data. It does not necessarily indicate that the ID is tied to valid data, merely
2145 * that accessing data using this ID will result in profile access checks and will only
2146 * return data from the profile.
2147 *
2148 * @param id The ID to check.
2149 * @return Whether the ID is associated with profile data.
2150 */
2151 public static boolean isProfileId(long id) {
2152 return id >= Profile.MIN_ID;
Dave Santoro43251332011-05-11 11:39:54 -07002153 }
2154
Chiao Cheng2355d132013-03-20 16:54:06 -07002155 protected interface DeletedContactsColumns {
2156
2157 /**
2158 * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted.
2159 * <P>Type: INTEGER</P>
2160 */
2161 public static final String CONTACT_ID = "contact_id";
2162
2163 /**
2164 * Time (milliseconds since epoch) that the contact was deleted.
2165 */
2166 public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp";
2167 }
2168
2169 /**
2170 * Constants for the deleted contact table. This table holds a log of deleted contacts.
2171 * <p>
2172 * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted.
2173 */
2174 public static final class DeletedContacts implements DeletedContactsColumns {
2175
2176 /**
2177 * This utility class cannot be instantiated
2178 */
2179 private DeletedContacts() {
2180 }
2181
2182 /**
2183 * The content:// style URI for this table, which requests a directory of raw contact rows
2184 * matching the selection criteria.
2185 */
2186 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
2187 "deleted_contacts");
2188
2189 /**
2190 * Number of days that the delete log will be kept. After this time, delete records may be
2191 * deleted.
2192 *
2193 * @hide
2194 */
2195 private static final int DAYS_KEPT = 30;
2196
2197 /**
2198 * Milliseconds that the delete log will be kept. After this time, delete records may be
2199 * deleted.
2200 */
2201 public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT;
2202 }
2203
2204
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07002205 protected interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002206 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002207 * A reference to the {@link ContactsContract.Contacts#_ID} that this
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002208 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002209 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -07002210 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002211 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -07002212
2213 /**
Dave Santorod7bdc182011-06-24 15:39:39 -07002214 * The data set within the account that this row belongs to. This allows
2215 * multiple sync adapters for the same account type to distinguish between
2216 * each others' data.
2217 *
2218 * This is empty by default, and is completely optional. It only needs to
2219 * be populated if multiple sync adapters are entering distinct data for
2220 * the same account type and account name.
2221 * <P>Type: TEXT</P>
2222 */
2223 public static final String DATA_SET = "data_set";
2224
2225 /**
Dave Santoro1d55c332011-07-25 16:44:45 -07002226 * A concatenation of the account type and data set (delimited by a forward
2227 * slash) - if the data set is empty, this will be the same as the account
2228 * type. For applications that need to be aware of the data set, this can
2229 * be used instead of account type to distinguish sets of data. This is
2230 * never intended to be used for specifying accounts.
Makoto Onuki0e917332014-08-26 14:06:30 -07002231 * <p>
2232 * This column does *not* escape forward slashes in the account type or the data set.
2233 * If this is an issue, consider using
2234 * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and
2235 * {@link ContactsContract.RawContacts#DATA_SET} directly.
Dave Santoro1d55c332011-07-25 16:44:45 -07002236 */
2237 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
2238
2239 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002240 * The aggregation mode for this contact.
2241 * <P>Type: INTEGER</P>
2242 */
2243 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002244
2245 /**
2246 * The "deleted" flag: "0" by default, "1" if the row has been marked
2247 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002248 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002249 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002250 * then calls ContactResolver.delete once more, this time passing the
Fred Quintana33f889a2009-09-14 17:31:26 -07002251 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2252 * the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002253 * <P>Type: INTEGER</P>
2254 */
2255 public static final String DELETED = "deleted";
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002256
2257 /**
2258 * The "name_verified" flag: "1" means that the name fields on this raw
2259 * contact can be trusted and therefore should be used for the entire
2260 * aggregated contact.
2261 * <p>
2262 * If an aggregated contact contains more than one raw contact with a
2263 * verified name, one of those verified names is chosen at random.
2264 * If an aggregated contact contains no verified names, the
2265 * name is chosen randomly from the constituent raw contacts.
2266 * </p>
2267 * <p>
2268 * Updating this flag from "0" to "1" automatically resets it to "0" on
2269 * all other raw contacts in the same aggregated contact.
2270 * </p>
2271 * <p>
2272 * Sync adapters should only specify a value for this column when
2273 * inserting a raw contact and leave it out when doing an update.
2274 * </p>
2275 * <p>
2276 * The default value is "0"
2277 * </p>
2278 * <p>Type: INTEGER</p>
Yorke Leeb31c8ab2014-08-26 17:13:02 -07002279 *
2280 * @hide
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002281 */
2282 public static final String NAME_VERIFIED = "name_verified";
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07002283
2284 /**
2285 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
2286 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
2287 * <P>Type: INTEGER</P>
2288 */
Dmitri Plotnikov86fe8392010-07-16 11:19:46 -07002289 public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
Dave Santoro43251332011-05-11 11:39:54 -07002290
2291 /**
2292 * Flag that reflects whether this raw contact belongs to the user's
2293 * personal profile entry.
2294 */
2295 public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002296 }
2297
2298 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002299 * Constants for the raw contacts table, which contains one row of contact
2300 * information for each person in each synced account. Sync adapters and
2301 * contact management apps
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002302 * are the primary consumers of this API.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002303 *
2304 * <h3>Aggregation</h3>
2305 * <p>
2306 * As soon as a raw contact is inserted or whenever its constituent data
2307 * changes, the provider will check if the raw contact matches other
2308 * existing raw contacts and if so will aggregate it with those. The
2309 * aggregation is reflected in the {@link RawContacts} table by the change of the
2310 * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
2311 * </p>
2312 * <p>
2313 * Changes to the structured name, organization, phone number, email address,
2314 * or nickname trigger a re-aggregation.
2315 * </p>
2316 * <p>
2317 * See also {@link AggregationExceptions} for a mechanism to control
2318 * aggregation programmatically.
2319 * </p>
2320 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002321 * <h3>Operations</h3>
2322 * <dl>
2323 * <dt><b>Insert</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002324 * <dd>
2325 * <p>
2326 * Raw contacts can be inserted incrementally or in a batch.
2327 * The incremental method is more traditional but less efficient.
2328 * It should be used
2329 * only if no {@link Data} values are available at the time the raw contact is created:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002330 * <pre>
2331 * ContentValues values = new ContentValues();
2332 * values.put(RawContacts.ACCOUNT_TYPE, accountType);
2333 * values.put(RawContacts.ACCOUNT_NAME, accountName);
2334 * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
2335 * long rawContactId = ContentUris.parseId(rawContactUri);
2336 * </pre>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002337 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002338 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002339 * Once {@link Data} values become available, insert those.
2340 * For example, here's how you would insert a name:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002341 *
2342 * <pre>
2343 * values.clear();
2344 * values.put(Data.RAW_CONTACT_ID, rawContactId);
2345 * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
2346 * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
2347 * getContentResolver().insert(Data.CONTENT_URI, values);
2348 * </pre>
2349 * </p>
2350 * <p>
2351 * The batch method is by far preferred. It inserts the raw contact and its
2352 * constituent data rows in a single database transaction
2353 * and causes at most one aggregation pass.
2354 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07002355 * ArrayList&lt;ContentProviderOperation&gt; ops =
2356 * new ArrayList&lt;ContentProviderOperation&gt;();
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002357 * ...
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002358 * int rawContactInsertIndex = ops.size();
2359 * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
2360 * .withValue(RawContacts.ACCOUNT_TYPE, accountType)
2361 * .withValue(RawContacts.ACCOUNT_NAME, accountName)
2362 * .build());
2363 *
2364 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
2365 * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
2366 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
2367 * .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
2368 * .build());
2369 *
2370 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2371 * </pre>
2372 * </p>
2373 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002374 * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
2375 * to refer to the as-yet-unknown index value of the raw contact inserted in the
2376 * first operation.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002377 * </p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002378 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002379 * <dt><b>Update</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002380 * <dd><p>
2381 * Raw contacts can be updated incrementally or in a batch.
2382 * Batch mode should be used whenever possible.
2383 * The procedures and considerations are analogous to those documented above for inserts.
2384 * </p></dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002385 * <dt><b>Delete</b></dt>
2386 * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
2387 * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002388 * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
2389 * itself is also deleted automatically.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002390 * </p>
2391 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002392 * The invocation of {@code resolver.delete(...)}, does not immediately delete
2393 * a raw contacts row.
2394 * Instead, it sets the {@link #DELETED} flag on the raw contact and
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002395 * removes the raw contact from its aggregate contact.
2396 * The sync adapter then deletes the raw contact from the server and
2397 * finalizes phone-side deletion by calling {@code resolver.delete(...)}
Fred Quintana328c0e72009-12-07 14:52:28 -08002398 * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002399 * <p>Some sync adapters are read-only, meaning that they only sync server-side
2400 * changes to the phone, but not the reverse. If one of those raw contacts
2401 * is marked for deletion, it will remain on the phone. However it will be
2402 * effectively invisible, because it will not be part of any aggregate contact.
2403 * </dd>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002404 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002405 * <dt><b>Query</b></dt>
2406 * <dd>
2407 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002408 * It is easy to find all raw contacts in a Contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002409 * <pre>
2410 * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
2411 * new String[]{RawContacts._ID},
2412 * RawContacts.CONTACT_ID + "=?",
2413 * new String[]{String.valueOf(contactId)}, null);
2414 * </pre>
2415 * </p>
2416 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002417 * To find raw contacts within a specific account,
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002418 * you can either put the account name and type in the selection or pass them as query
2419 * parameters. The latter approach is preferable, especially when you can reuse the
2420 * URI:
2421 * <pre>
Adam Koch95e5a072013-05-21 09:47:55 -04002422 * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002423 * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
2424 * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
2425 * .build();
2426 * Cursor c1 = getContentResolver().query(rawContactUri,
2427 * RawContacts.STARRED + "&lt;&gt;0", null, null, null);
2428 * ...
2429 * Cursor c2 = getContentResolver().query(rawContactUri,
2430 * RawContacts.DELETED + "&lt;&gt;0", null, null, null);
2431 * </pre>
2432 * </p>
2433 * <p>The best way to read a raw contact along with all the data associated with it is
2434 * by using the {@link Entity} directory. If the raw contact has data rows,
2435 * the Entity cursor will contain a row for each data row. If the raw contact has no
2436 * data rows, the cursor will still contain one row with the raw contact-level information.
2437 * <pre>
2438 * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
2439 * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
2440 * Cursor c = getContentResolver().query(entityUri,
2441 * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
2442 * null, null, null);
2443 * try {
2444 * while (c.moveToNext()) {
2445 * String sourceId = c.getString(0);
2446 * if (!c.isNull(1)) {
2447 * String mimeType = c.getString(2);
2448 * String data = c.getString(3);
2449 * ...
2450 * }
2451 * }
2452 * } finally {
2453 * c.close();
2454 * }
2455 * </pre>
2456 * </p>
2457 * </dd>
2458 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002459 * <h2>Columns</h2>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002460 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002461 * <table class="jd-sumtable">
2462 * <tr>
2463 * <th colspan='4'>RawContacts</th>
2464 * </tr>
2465 * <tr>
2466 * <td>long</td>
2467 * <td>{@link #_ID}</td>
2468 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002469 * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
2470 * it is much better for a sync adapter to update a raw contact rather than to delete and
2471 * re-insert it.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002472 * </tr>
2473 * <tr>
2474 * <td>long</td>
2475 * <td>{@link #CONTACT_ID}</td>
2476 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002477 * <td>The ID of the row in the {@link ContactsContract.Contacts} table
2478 * that this raw contact belongs
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002479 * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
2480 * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
2481 * </tr>
2482 * <tr>
2483 * <td>int</td>
2484 * <td>{@link #AGGREGATION_MODE}</td>
2485 * <td>read/write</td>
2486 * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
2487 * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
2488 * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
2489 * </tr>
2490 * <tr>
2491 * <td>int</td>
2492 * <td>{@link #DELETED}</td>
2493 * <td>read/write</td>
2494 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
2495 * for deletion. When {@link android.content.ContentResolver#delete} is
2496 * called on a raw contact, it is marked for deletion and removed from its
2497 * aggregate contact. The sync adaptor deletes the raw contact on the server and
2498 * then calls ContactResolver.delete once more, this time passing the
2499 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2500 * the data removal.</td>
2501 * </tr>
2502 * <tr>
2503 * <td>int</td>
2504 * <td>{@link #TIMES_CONTACTED}</td>
2505 * <td>read/write</td>
2506 * <td>The number of times the contact has been contacted. To have an effect
2507 * on the corresponding value of the aggregate contact, this field
2508 * should be set at the time the raw contact is inserted.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002509 * After that, this value is typically updated via
2510 * {@link ContactsContract.Contacts#markAsContacted}.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002511 * </tr>
2512 * <tr>
2513 * <td>long</td>
2514 * <td>{@link #LAST_TIME_CONTACTED}</td>
2515 * <td>read/write</td>
2516 * <td>The timestamp of the last time the contact was contacted. To have an effect
2517 * on the corresponding value of the aggregate contact, this field
2518 * should be set at the time the raw contact is inserted.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002519 * After that, this value is typically updated via
2520 * {@link ContactsContract.Contacts#markAsContacted}.
2521 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002522 * </tr>
2523 * <tr>
2524 * <td>int</td>
2525 * <td>{@link #STARRED}</td>
2526 * <td>read/write</td>
2527 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002528 * Changing this field immediately affects the corresponding aggregate contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002529 * if any raw contacts in that aggregate contact are starred, then the contact
2530 * itself is marked as starred.</td>
2531 * </tr>
2532 * <tr>
2533 * <td>String</td>
2534 * <td>{@link #CUSTOM_RINGTONE}</td>
2535 * <td>read/write</td>
2536 * <td>A custom ringtone associated with a raw contact. Typically this is the
2537 * URI returned by an activity launched with the
2538 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
2539 * To have an effect on the corresponding value of the aggregate contact, this field
2540 * should be set at the time the raw contact is inserted. To set a custom
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002541 * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
2542 * Contacts.CUSTOM_RINGTONE}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002543 * instead.</td>
2544 * </tr>
2545 * <tr>
2546 * <td>int</td>
2547 * <td>{@link #SEND_TO_VOICEMAIL}</td>
2548 * <td>read/write</td>
2549 * <td>An indicator of whether calls from this raw contact should be forwarded
2550 * directly to voice mail ('1') or not ('0'). To have an effect
2551 * on the corresponding value of the aggregate contact, this field
2552 * should be set at the time the raw contact is inserted.</td>
2553 * </tr>
2554 * <tr>
2555 * <td>String</td>
2556 * <td>{@link #ACCOUNT_NAME}</td>
2557 * <td>read/write-once</td>
2558 * <td>The name of the account instance to which this row belongs, which when paired with
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002559 * {@link #ACCOUNT_TYPE} identifies a specific account.
2560 * For example, this will be the Gmail address if it is a Google account.
Dave Santorod7bdc182011-06-24 15:39:39 -07002561 * It should be set at the time the raw contact is inserted and never
2562 * changed afterwards.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002563 * </tr>
2564 * <tr>
2565 * <td>String</td>
2566 * <td>{@link #ACCOUNT_TYPE}</td>
2567 * <td>read/write-once</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002568 * <td>
2569 * <p>
2570 * The type of account to which this row belongs, which when paired with
2571 * {@link #ACCOUNT_NAME} identifies a specific account.
Dave Santorod7bdc182011-06-24 15:39:39 -07002572 * It should be set at the time the raw contact is inserted and never
2573 * changed afterwards.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002574 * </p>
2575 * <p>
2576 * To ensure uniqueness, new account types should be chosen according to the
2577 * Java package naming convention. Thus a Google account is of type "com.google".
2578 * </p>
2579 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002580 * </tr>
2581 * <tr>
2582 * <td>String</td>
Dave Santorod7bdc182011-06-24 15:39:39 -07002583 * <td>{@link #DATA_SET}</td>
2584 * <td>read/write-once</td>
2585 * <td>
2586 * <p>
2587 * The data set within the account that this row belongs to. This allows
2588 * multiple sync adapters for the same account type to distinguish between
2589 * each others' data. The combination of {@link #ACCOUNT_TYPE},
2590 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
2591 * that is associated with a single sync adapter.
2592 * </p>
2593 * <p>
2594 * This is empty by default, and is completely optional. It only needs to
2595 * be populated if multiple sync adapters are entering distinct data for
2596 * the same account type and account name.
2597 * </p>
2598 * <p>
2599 * It should be set at the time the raw contact is inserted and never
2600 * changed afterwards.
2601 * </p>
2602 * </td>
2603 * </tr>
2604 * <tr>
2605 * <td>String</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002606 * <td>{@link #SOURCE_ID}</td>
2607 * <td>read/write</td>
2608 * <td>String that uniquely identifies this row to its source account.
2609 * Typically it is set at the time the raw contact is inserted and never
2610 * changed afterwards. The one notable exception is a new raw contact: it
Dave Santorod7bdc182011-06-24 15:39:39 -07002611 * will have an account name and type (and possibly a data set), but no
2612 * source id. This indicates to the sync adapter that a new contact needs
2613 * to be created server-side and its ID stored in the corresponding
2614 * SOURCE_ID field on the phone.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002615 * </td>
2616 * </tr>
2617 * <tr>
2618 * <td>int</td>
2619 * <td>{@link #VERSION}</td>
2620 * <td>read-only</td>
2621 * <td>Version number that is updated whenever this row or its related data
2622 * changes. This field can be used for optimistic locking of a raw contact.
2623 * </td>
2624 * </tr>
2625 * <tr>
2626 * <td>int</td>
2627 * <td>{@link #DIRTY}</td>
2628 * <td>read/write</td>
2629 * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
2630 * to be synchronized by its owning account. The value is set to "1" automatically
2631 * whenever the raw contact changes, unless the URI has the
2632 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
2633 * The sync adapter should always supply this query parameter to prevent
2634 * unnecessary synchronization: user changes some data on the server,
2635 * the sync adapter updates the contact on the phone (without the
2636 * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
2637 * which triggers a sync to bring the changes to the server.
2638 * </td>
2639 * </tr>
2640 * <tr>
2641 * <td>String</td>
2642 * <td>{@link #SYNC1}</td>
2643 * <td>read/write</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002644 * <td>Generic column provided for arbitrary use by sync adapters.
2645 * The content provider
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002646 * stores this information on behalf of the sync adapter but does not
2647 * interpret it in any way.
2648 * </td>
2649 * </tr>
2650 * <tr>
2651 * <td>String</td>
2652 * <td>{@link #SYNC2}</td>
2653 * <td>read/write</td>
2654 * <td>Generic column for use by sync adapters.
2655 * </td>
2656 * </tr>
2657 * <tr>
2658 * <td>String</td>
2659 * <td>{@link #SYNC3}</td>
2660 * <td>read/write</td>
2661 * <td>Generic column for use by sync adapters.
2662 * </td>
2663 * </tr>
2664 * <tr>
2665 * <td>String</td>
2666 * <td>{@link #SYNC4}</td>
2667 * <td>read/write</td>
2668 * <td>Generic column for use by sync adapters.
2669 * </td>
2670 * </tr>
2671 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002672 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002673 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08002674 ContactOptionsColumns, ContactNameColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002675 /**
2676 * This utility class cannot be instantiated
2677 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002678 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002679 }
2680
2681 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002682 * The content:// style URI for this table, which requests a directory of
2683 * raw contact rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07002684 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002685 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -07002686
2687 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002688 * The MIME type of the results from {@link #CONTENT_URI} when a specific
2689 * ID value is not provided, and multiple raw contacts may be returned.
Evan Millar088b2912009-05-28 15:24:37 -07002690 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002691 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002692
2693 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002694 * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
2695 * yielding a subdirectory of a single person.
Evan Millar088b2912009-05-28 15:24:37 -07002696 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002697 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002698
2699 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002700 * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002701 */
2702 public static final int AGGREGATION_MODE_DEFAULT = 0;
2703
2704 /**
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002705 * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
2706 * @deprecated Aggregation is synchronous, this historic value is a no-op
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002707 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002708 @Deprecated
Omari Stephensbc9aa772009-09-08 19:10:53 -07002709 public static final int AGGREGATION_MODE_IMMEDIATE = 1;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002710
2711 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002712 * <p>
2713 * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
2714 * Changes to the raw contact will update the associated aggregate contact but will not
2715 * result in any change in how the contact is aggregated. Similar to
2716 * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
2717 * {@link Contacts} aggregate.
2718 * </p>
2719 * <p>
2720 * This can be used to postpone aggregation until after a series of updates, for better
2721 * performance and/or user experience.
2722 * </p>
2723 * <p>
2724 * Note that changing
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002725 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002726 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
2727 * subsequent
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002728 * change to the raw contact's data will.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002729 * </p>
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002730 */
2731 public static final int AGGREGATION_MODE_SUSPENDED = 2;
2732
2733 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002734 * <p>
2735 * Aggregation mode: never aggregate this raw contact. The raw contact will not
2736 * have a corresponding {@link Contacts} aggregate and therefore will not be included in
2737 * {@link Contacts} query results.
2738 * </p>
2739 * <p>
2740 * For example, this mode can be used for a raw contact that is marked for deletion while
2741 * waiting for the deletion to occur on the server side.
2742 * </p>
2743 *
2744 * @see #AGGREGATION_MODE_SUSPENDED
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002745 */
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002746 public static final int AGGREGATION_MODE_DISABLED = 3;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002747
2748 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -05002749 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
2750 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
2751 * entry of the given {@link RawContacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002752 */
2753 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
2754 // TODO: use a lighter query by joining rawcontacts with contacts in provider
2755 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
2756 final Cursor cursor = resolver.query(dataUri, new String[] {
2757 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
2758 }, null, null, null);
2759
2760 Uri lookupUri = null;
2761 try {
2762 if (cursor != null && cursor.moveToFirst()) {
2763 final long contactId = cursor.getLong(0);
2764 final String lookupKey = cursor.getString(1);
2765 return Contacts.getLookupUri(contactId, lookupKey);
2766 }
2767 } finally {
2768 if (cursor != null) cursor.close();
2769 }
2770 return lookupUri;
2771 }
2772
2773 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002774 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002775 * {@link ContactsContract.Data} rows. To access this directory
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002776 * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI.
Evan Millar088b2912009-05-28 15:24:37 -07002777 */
2778 public static final class Data implements BaseColumns, DataColumns {
2779 /**
2780 * no public constructor since this is a utility class
2781 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002782 private Data() {
2783 }
Evan Millar088b2912009-05-28 15:24:37 -07002784
2785 /**
2786 * The directory twig for this sub-table
2787 */
2788 public static final String CONTENT_DIRECTORY = "data";
2789 }
Fred Quintana5bba6322009-10-05 14:21:12 -07002790
2791 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002792 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002793 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002794 * {@link ContactsContract.Data} rows. To access this directory append
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002795 * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002796 * {@link RawContactsEntity} for a stand-alone table containing the same
2797 * data.
2798 * </p>
2799 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002800 * Entity has two ID fields: {@link #_ID} for the raw contact
2801 * and {@link #DATA_ID} for the data rows.
2802 * Entity always contains at least one row, even if there are no
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002803 * actual data rows. In this case the {@link #DATA_ID} field will be
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002804 * null.
2805 * </p>
2806 * <p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002807 * Using Entity should be preferred to using two separate queries:
2808 * RawContacts followed by Data. The reason is that Entity reads all
2809 * data for a raw contact in one transaction, so there is no possibility
2810 * of the data changing between the two queries.
Fred Quintana5bba6322009-10-05 14:21:12 -07002811 */
2812 public static final class Entity implements BaseColumns, DataColumns {
2813 /**
2814 * no public constructor since this is a utility class
2815 */
2816 private Entity() {
2817 }
2818
2819 /**
2820 * The directory twig for this sub-table
2821 */
2822 public static final String CONTENT_DIRECTORY = "entity";
2823
2824 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07002825 * The ID of the data row. The value will be null if this raw contact has no
Fred Quintana5bba6322009-10-05 14:21:12 -07002826 * data rows.
2827 * <P>Type: INTEGER</P>
2828 */
2829 public static final String DATA_ID = "data_id";
2830 }
Fred Quintana328c0e72009-12-07 14:52:28 -08002831
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002832 /**
Dave Santorod414f102011-06-20 14:35:06 -07002833 * <p>
2834 * A sub-directory of a single raw contact that contains all of its
2835 * {@link ContactsContract.StreamItems} rows. To access this directory append
2836 * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See
2837 * {@link ContactsContract.StreamItems} for a stand-alone table containing the
2838 * same data.
2839 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07002840 * <p>
2841 * Access to the social stream through this sub-directory requires additional permissions
2842 * beyond the read/write contact permissions required by the provider. Querying for
2843 * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and
2844 * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM
2845 * permission.
2846 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07002847 *
2848 * @deprecated - Do not use. This will not be supported in the future. In the future,
2849 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002850 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002851 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002852 public static final class StreamItems implements BaseColumns, StreamItemsColumns {
2853 /**
2854 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07002855 *
2856 * @deprecated - Do not use. This will not be supported in the future. In the future,
2857 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002858 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002859 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002860 private StreamItems() {
2861 }
2862
2863 /**
2864 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07002865 *
2866 * @deprecated - Do not use. This will not be supported in the future. In the future,
2867 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002868 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002869 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002870 public static final String CONTENT_DIRECTORY = "stream_items";
2871 }
2872
2873 /**
Dave Santoroa5282372011-06-29 00:25:16 -07002874 * <p>
2875 * A sub-directory of a single raw contact that represents its primary
2876 * display photo. To access this directory append
2877 * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI.
2878 * The resulting URI represents an image file, and should be interacted with
Dave Santoro040e6b32011-07-15 15:14:08 -07002879 * using ContentResolver.openAssetFileDescriptor.
Dave Santoroa5282372011-06-29 00:25:16 -07002880 * <p>
2881 * <p>
2882 * Note that this sub-directory also supports opening the photo as an asset file
2883 * in write mode. Callers can create or replace the primary photo associated
2884 * with this raw contact by opening the asset file and writing the full-size
2885 * photo contents into it. When the file is closed, the image will be parsed,
2886 * sized down if necessary for the full-size display photo and thumbnail
2887 * dimensions, and stored.
2888 * </p>
2889 * <p>
2890 * Usage example:
2891 * <pre>
2892 * public void writeDisplayPhoto(long rawContactId, byte[] photo) {
2893 * Uri rawContactPhotoUri = Uri.withAppendedPath(
2894 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
2895 * RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
2896 * try {
2897 * AssetFileDescriptor fd =
Dave Santoro040e6b32011-07-15 15:14:08 -07002898 * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw");
Dave Santoroa5282372011-06-29 00:25:16 -07002899 * OutputStream os = fd.createOutputStream();
2900 * os.write(photo);
2901 * os.close();
2902 * fd.close();
2903 * } catch (IOException e) {
2904 * // Handle error cases.
2905 * }
2906 * }
2907 * </pre>
2908 * </p>
2909 */
2910 public static final class DisplayPhoto {
2911 /**
2912 * No public constructor since this is a utility class
2913 */
2914 private DisplayPhoto() {
2915 }
2916
2917 /**
2918 * The directory twig for this sub-table
2919 */
2920 public static final String CONTENT_DIRECTORY = "display_photo";
2921 }
2922
2923 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002924 * TODO: javadoc
2925 * @param cursor
2926 * @return
2927 */
Fred Quintana328c0e72009-12-07 14:52:28 -08002928 public static EntityIterator newEntityIterator(Cursor cursor) {
2929 return new EntityIteratorImpl(cursor);
2930 }
2931
2932 private static class EntityIteratorImpl extends CursorEntityIterator {
2933 private static final String[] DATA_KEYS = new String[]{
2934 Data.DATA1,
2935 Data.DATA2,
2936 Data.DATA3,
2937 Data.DATA4,
2938 Data.DATA5,
2939 Data.DATA6,
2940 Data.DATA7,
2941 Data.DATA8,
2942 Data.DATA9,
2943 Data.DATA10,
2944 Data.DATA11,
2945 Data.DATA12,
2946 Data.DATA13,
2947 Data.DATA14,
2948 Data.DATA15,
2949 Data.SYNC1,
2950 Data.SYNC2,
2951 Data.SYNC3,
2952 Data.SYNC4};
2953
2954 public EntityIteratorImpl(Cursor cursor) {
2955 super(cursor);
2956 }
2957
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08002958 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08002959 public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
2960 throws RemoteException {
2961 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
2962 final long rawContactId = cursor.getLong(columnRawContactId);
2963
2964 // we expect the cursor is already at the row we need to read from
2965 ContentValues cv = new ContentValues();
2966 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
2967 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
Katherine Kuan1d837232011-08-24 16:06:06 -07002968 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET);
Fred Quintana328c0e72009-12-07 14:52:28 -08002969 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
2970 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
2971 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
2972 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
2973 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
2974 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
2975 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
2976 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
2977 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
2978 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
2979 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002980 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED);
Fred Quintana328c0e72009-12-07 14:52:28 -08002981 android.content.Entity contact = new android.content.Entity(cv);
2982
2983 // read data rows until the contact id changes
2984 do {
2985 if (rawContactId != cursor.getLong(columnRawContactId)) {
2986 break;
2987 }
2988 // add the data to to the contact
2989 cv = new ContentValues();
2990 cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
2991 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2992 Data.RES_PACKAGE);
2993 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
2994 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
2995 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
2996 Data.IS_SUPER_PRIMARY);
2997 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
2998 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2999 CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
3000 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3001 Data.DATA_VERSION);
3002 for (String key : DATA_KEYS) {
3003 final int columnIndex = cursor.getColumnIndexOrThrow(key);
Daniel Lehmann156add92010-07-19 18:01:10 -07003004 switch (cursor.getType(columnIndex)) {
3005 case Cursor.FIELD_TYPE_NULL:
3006 // don't put anything
3007 break;
3008 case Cursor.FIELD_TYPE_INTEGER:
3009 case Cursor.FIELD_TYPE_FLOAT:
3010 case Cursor.FIELD_TYPE_STRING:
Fred Quintana274dc9d2009-12-11 13:17:08 -08003011 cv.put(key, cursor.getString(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07003012 break;
3013 case Cursor.FIELD_TYPE_BLOB:
Fred Quintana274dc9d2009-12-11 13:17:08 -08003014 cv.put(key, cursor.getBlob(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07003015 break;
3016 default:
3017 throw new IllegalStateException("Invalid or unhandled data type");
Fred Quintana328c0e72009-12-07 14:52:28 -08003018 }
Fred Quintana328c0e72009-12-07 14:52:28 -08003019 }
3020 contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
3021 } while (cursor.moveToNext());
3022
3023 return contact;
3024 }
3025
3026 }
Evan Millar088b2912009-05-28 15:24:37 -07003027 }
3028
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003029 /**
3030 * Social status update columns.
3031 *
3032 * @see StatusUpdates
3033 * @see ContactsContract.Data
3034 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003035 protected interface StatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003036 /**
Dmitri Plotnikova60479d2009-09-27 20:16:31 -07003037 * Contact's latest presence level.
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003038 * <P>Type: INTEGER (one of the values below)</P>
3039 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003040 public static final String PRESENCE = "mode";
3041
3042 /**
3043 * @deprecated use {@link #PRESENCE}
3044 */
3045 @Deprecated
3046 public static final String PRESENCE_STATUS = PRESENCE;
3047
Tom O'Neill244327e2010-01-08 11:11:15 -08003048 /**
3049 * An allowed value of {@link #PRESENCE}.
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003050 */
3051 int OFFLINE = 0;
Tom O'Neill244327e2010-01-08 11:11:15 -08003052
3053 /**
3054 * An allowed value of {@link #PRESENCE}.
3055 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003056 int INVISIBLE = 1;
Tom O'Neill244327e2010-01-08 11:11:15 -08003057
3058 /**
3059 * An allowed value of {@link #PRESENCE}.
3060 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003061 int AWAY = 2;
Tom O'Neill244327e2010-01-08 11:11:15 -08003062
3063 /**
3064 * An allowed value of {@link #PRESENCE}.
3065 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003066 int IDLE = 3;
Tom O'Neill244327e2010-01-08 11:11:15 -08003067
3068 /**
3069 * An allowed value of {@link #PRESENCE}.
3070 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003071 int DO_NOT_DISTURB = 4;
Tom O'Neill244327e2010-01-08 11:11:15 -08003072
3073 /**
3074 * An allowed value of {@link #PRESENCE}.
3075 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003076 int AVAILABLE = 5;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003077
3078 /**
3079 * Contact latest status update.
3080 * <p>Type: TEXT</p>
3081 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003082 public static final String STATUS = "status";
3083
3084 /**
3085 * @deprecated use {@link #STATUS}
3086 */
Tom O'Neill244327e2010-01-08 11:11:15 -08003087 @Deprecated
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003088 public static final String PRESENCE_CUSTOM_STATUS = STATUS;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003089
3090 /**
3091 * The absolute time in milliseconds when the latest status was inserted/updated.
3092 * <p>Type: NUMBER</p>
3093 */
3094 public static final String STATUS_TIMESTAMP = "status_ts";
3095
3096 /**
3097 * The package containing resources for this status: label and icon.
Dave Santoro040e6b32011-07-15 15:14:08 -07003098 * <p>Type: TEXT</p>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003099 */
3100 public static final String STATUS_RES_PACKAGE = "status_res_package";
3101
3102 /**
3103 * The resource ID of the label describing the source of the status update, e.g. "Google
3104 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3105 * <p>Type: NUMBER</p>
3106 */
3107 public static final String STATUS_LABEL = "status_label";
3108
3109 /**
3110 * The resource ID of the icon for the source of the status update.
3111 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3112 * <p>Type: NUMBER</p>
3113 */
3114 public static final String STATUS_ICON = "status_icon";
Vasu Nori5b314982010-07-12 15:13:37 -07003115
3116 /**
3117 * Contact's audio/video chat capability level.
3118 * <P>Type: INTEGER (one of the values below)</P>
3119 */
3120 public static final String CHAT_CAPABILITY = "chat_capability";
3121
3122 /**
Daniel Lehmannb3327472010-08-13 15:16:11 -07003123 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone
3124 * and speaker)
3125 */
3126 public static final int CAPABILITY_HAS_VOICE = 1;
3127
3128 /**
3129 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
Vasu Nori5b314982010-07-12 15:13:37 -07003130 * display a video feed.
3131 */
Daniel Lehmannb3327472010-08-13 15:16:11 -07003132 public static final int CAPABILITY_HAS_VIDEO = 2;
Vasu Nori5b314982010-07-12 15:13:37 -07003133
3134 /**
Daniel Lehmannb3327472010-08-13 15:16:11 -07003135 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
Vasu Nori5b314982010-07-12 15:13:37 -07003136 * camera that can be used for video chat (e.g. a front-facing camera on a phone).
3137 */
3138 public static final int CAPABILITY_HAS_CAMERA = 4;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003139 }
3140
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003141 /**
Dave Santorod414f102011-06-20 14:35:06 -07003142 * <p>
3143 * Constants for the stream_items table, which contains social stream updates from
3144 * the user's contact list.
3145 * </p>
3146 * <p>
3147 * Only a certain number of stream items will ever be stored under a given raw contact.
3148 * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to
3149 * determine this limit, and should restrict the number of items inserted in any given
3150 * transaction correspondingly. Insertion of more items beyond the limit will
3151 * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}.
3152 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003153 * <p>
3154 * Access to the social stream through these URIs requires additional permissions beyond the
3155 * read/write contact permissions required by the provider. Querying for social stream data
3156 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social
3157 * stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
3158 * </p>
Makoto Onuki46891a82012-04-26 12:46:47 -07003159 * <h3>Account check</h3>
3160 * <p>
3161 * The content URIs to the insert, update and delete operations are required to have the account
3162 * information matching that of the owning raw contact as query parameters, namely
3163 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3164 * {@link RawContacts#DATA_SET} isn't required.
3165 * </p>
Dave Santorod414f102011-06-20 14:35:06 -07003166 * <h3>Operations</h3>
3167 * <dl>
3168 * <dt><b>Insert</b></dt>
3169 * <dd>
3170 * <p>Social stream updates are always associated with a raw contact. There are a couple
3171 * of ways to insert these entries.
3172 * <dl>
3173 * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt>
3174 * <dd>
3175 * <pre>
3176 * ContentValues values = new ContentValues();
3177 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3178 * values.put(StreamItems.TIMESTAMP, timestamp);
Dave Santoro040e6b32011-07-15 15:14:08 -07003179 * values.put(StreamItems.COMMENTS, "3 people reshared this");
Makoto Onuki46891a82012-04-26 12:46:47 -07003180 * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
3181 * ContentUris.appendId(builder, rawContactId);
3182 * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY);
3183 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3184 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3185 * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003186 * long streamItemId = ContentUris.parseId(streamItemUri);
3187 * </pre>
3188 * </dd>
Scott Main45107052011-09-26 21:52:05 -07003189 * <dt>Via {@link StreamItems#CONTENT_URI}:</dt>
Dave Santorod414f102011-06-20 14:35:06 -07003190 * <dd>
Scott Main45107052011-09-26 21:52:05 -07003191 *<pre>
Dave Santorod414f102011-06-20 14:35:06 -07003192 * ContentValues values = new ContentValues();
3193 * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
3194 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3195 * values.put(StreamItems.TIMESTAMP, timestamp);
Dave Santoro040e6b32011-07-15 15:14:08 -07003196 * values.put(StreamItems.COMMENTS, "3 people reshared this");
Makoto Onuki46891a82012-04-26 12:46:47 -07003197 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3198 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3199 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3200 * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003201 * long streamItemId = ContentUris.parseId(streamItemUri);
Scott Main45107052011-09-26 21:52:05 -07003202 *</pre>
Dave Santorod414f102011-06-20 14:35:06 -07003203 * </dd>
3204 * </dl>
3205 * </dd>
3206 * </p>
3207 * <p>
3208 * Once a {@link StreamItems} entry has been inserted, photos associated with that
3209 * social update can be inserted. For example, after one of the insertions above,
3210 * photos could be added to the stream item in one of the following ways:
3211 * <dl>
3212 * <dt>Via a URI including the stream item ID:</dt>
3213 * <dd>
3214 * <pre>
3215 * values.clear();
3216 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003217 * values.put(StreamItemPhotos.PHOTO, photoData);
Dave Santorod414f102011-06-20 14:35:06 -07003218 * getContentResolver().insert(Uri.withAppendedPath(
3219 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId),
3220 * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
3221 * </pre>
3222 * </dd>
Scott Main45107052011-09-26 21:52:05 -07003223 * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt>
Dave Santorod414f102011-06-20 14:35:06 -07003224 * <dd>
3225 * <pre>
3226 * values.clear();
3227 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3228 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003229 * values.put(StreamItemPhotos.PHOTO, photoData);
Dave Santorod414f102011-06-20 14:35:06 -07003230 * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
3231 * </pre>
Scott Main45107052011-09-26 21:52:05 -07003232 * <p>Note that this latter form allows the insertion of a stream item and its
Dave Santorod414f102011-06-20 14:35:06 -07003233 * photos in a single transaction, by using {@link ContentProviderOperation} with
3234 * back references to populate the stream item ID in the {@link ContentValues}.
3235 * </dd>
3236 * </dl>
3237 * </p>
3238 * </dd>
3239 * <dt><b>Update</b></dt>
3240 * <dd>Updates can be performed by appending the stream item ID to the
3241 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
3242 * created by the calling package can be updated.</dd>
3243 * <dt><b>Delete</b></dt>
3244 * <dd>Deletes can be performed by appending the stream item ID to the
3245 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
3246 * created by the calling package can be deleted.</dd>
3247 * <dt><b>Query</b></dt>
3248 * <dl>
3249 * <dt>Finding all social stream updates for a given contact</dt>
3250 * <dd>By Contact ID:
3251 * <pre>
3252 * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3253 * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
3254 * Contacts.StreamItems.CONTENT_DIRECTORY),
3255 * null, null, null, null);
3256 * </pre>
3257 * </dd>
3258 * <dd>By lookup key:
3259 * <pre>
3260 * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
3261 * .appendPath(lookupKey)
3262 * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
3263 * null, null, null, null);
3264 * </pre>
3265 * </dd>
3266 * <dt>Finding all social stream updates for a given raw contact</dt>
3267 * <dd>
3268 * <pre>
3269 * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3270 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
3271 * RawContacts.StreamItems.CONTENT_DIRECTORY)),
3272 * null, null, null, null);
3273 * </pre>
3274 * </dd>
3275 * <dt>Querying for a specific stream item by ID</dt>
3276 * <dd>
3277 * <pre>
3278 * Cursor c = getContentResolver().query(ContentUris.withAppendedId(
3279 * StreamItems.CONTENT_URI, streamItemId),
3280 * null, null, null, null);
3281 * </pre>
3282 * </dd>
3283 * </dl>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003284 *
3285 * @deprecated - Do not use. This will not be supported in the future. In the future,
3286 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003287 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003288 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003289 public static final class StreamItems implements BaseColumns, StreamItemsColumns {
3290 /**
3291 * This utility class cannot be instantiated
Brian Attwellbdb13c82014-07-16 21:43:54 -07003292 *
3293 * @deprecated - Do not use. This will not be supported in the future. In the future,
3294 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003295 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003296 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003297 private StreamItems() {
3298 }
3299
3300 /**
3301 * The content:// style URI for this table, which handles social network stream
3302 * updates for the user's contacts.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003303 *
3304 * @deprecated - Do not use. This will not be supported in the future. In the future,
3305 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003306 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003307 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003308 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items");
3309
3310 /**
3311 * <p>
3312 * A content:// style URI for the photos stored in a sub-table underneath
3313 * stream items. This is only used for inserts, and updates - queries and deletes
3314 * for photos should be performed by appending
3315 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a
3316 * specific stream item.
3317 * </p>
3318 * <p>
3319 * When using this URI, the stream item ID for the photo(s) must be identified
3320 * in the {@link ContentValues} passed in.
3321 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003322 *
3323 * @deprecated - Do not use. This will not be supported in the future. In the future,
3324 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003325 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003326 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003327 public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo");
3328
3329 /**
3330 * This URI allows the caller to query for the maximum number of stream items
Dave Santoro040e6b32011-07-15 15:14:08 -07003331 * that will be stored under any single raw contact.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003332 *
3333 * @deprecated - Do not use. This will not be supported in the future. In the future,
3334 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003335 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003336 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003337 public static final Uri CONTENT_LIMIT_URI =
3338 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
3339
3340 /**
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003341 * The MIME type of a directory of stream items.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003342 *
3343 * @deprecated - Do not use. This will not be supported in the future. In the future,
3344 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003345 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003346 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003347 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item";
3348
3349 /**
3350 * The MIME type of a single stream item.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003351 *
3352 * @deprecated - Do not use. This will not be supported in the future. In the future,
3353 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003354 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003355 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003356 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item";
3357
3358 /**
Dave Santorod414f102011-06-20 14:35:06 -07003359 * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
3360 * contain this column, with the value indicating the maximum number of
3361 * stream items that will be stored under any single raw contact.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003362 *
3363 * @deprecated - Do not use. This will not be supported in the future. In the future,
3364 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003365 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003366 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003367 public static final String MAX_ITEMS = "max_items";
3368
3369 /**
Dave Santorod414f102011-06-20 14:35:06 -07003370 * <p>
3371 * A sub-directory of a single stream item entry that contains all of its
3372 * photo rows. To access this
3373 * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to
3374 * an individual stream item URI.
3375 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003376 * <p>
3377 * Access to social stream photos requires additional permissions beyond the read/write
3378 * contact permissions required by the provider. Querying for social stream photos
3379 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3380 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3381 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003382 *
3383 * @deprecated - Do not use. This will not be supported in the future. In the future,
3384 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003385 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003386 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003387 public static final class StreamItemPhotos
3388 implements BaseColumns, StreamItemPhotosColumns {
3389 /**
3390 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07003391 *
3392 * @deprecated - Do not use. This will not be supported in the future. In the future,
3393 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003394 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003395 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003396 private StreamItemPhotos() {
3397 }
3398
3399 /**
3400 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07003401 *
3402 * @deprecated - Do not use. This will not be supported in the future. In the future,
3403 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003404 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003405 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003406 public static final String CONTENT_DIRECTORY = "photo";
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003407
3408 /**
3409 * The MIME type of a directory of stream item photos.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003410 *
3411 * @deprecated - Do not use. This will not be supported in the future. In the future,
3412 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003413 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003414 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003415 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo";
3416
3417 /**
3418 * The MIME type of a single stream item photo.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003419 *
3420 * @deprecated - Do not use. This will not be supported in the future. In the future,
3421 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003422 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003423 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003424 public static final String CONTENT_ITEM_TYPE
3425 = "vnd.android.cursor.item/stream_item_photo";
Dave Santorod414f102011-06-20 14:35:06 -07003426 }
3427 }
3428
3429 /**
3430 * Columns in the StreamItems table.
3431 *
3432 * @see ContactsContract.StreamItems
Brian Attwellbdb13c82014-07-16 21:43:54 -07003433 * @deprecated - Do not use. This will not be supported in the future. In the future,
3434 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003435 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003436 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003437 protected interface StreamItemsColumns {
3438 /**
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003439 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID}
3440 * that this stream item belongs to.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003441 *
3442 * <p>Type: INTEGER</p>
3443 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003444 *
3445 * @deprecated - Do not use. This will not be supported in the future. In the future,
3446 * cursors returned from related queries will be empty.
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003447 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003448 @Deprecated
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003449 public static final String CONTACT_ID = "contact_id";
3450
3451 /**
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003452 * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY}
3453 * that this stream item belongs to.
3454 *
3455 * <p>Type: TEXT</p>
3456 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003457 *
3458 * @deprecated - Do not use. This will not be supported in the future. In the future,
3459 * cursors returned from related queries will be empty.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003460 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003461 @Deprecated
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003462 public static final String CONTACT_LOOKUP_KEY = "contact_lookup";
3463
3464 /**
Dave Santorod414f102011-06-20 14:35:06 -07003465 * A reference to the {@link RawContacts#_ID}
3466 * that this stream item belongs to.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003467 * <p>Type: INTEGER</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003468 *
3469 * @deprecated - Do not use. This will not be supported in the future. In the future,
3470 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003471 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003472 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003473 public static final String RAW_CONTACT_ID = "raw_contact_id";
3474
3475 /**
3476 * The package name to use when creating {@link Resources} objects for
3477 * this stream item. This value is only designed for use when building
3478 * user interfaces, and should not be used to infer the owner.
Dave Santoro040e6b32011-07-15 15:14:08 -07003479 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003480 *
3481 * @deprecated - Do not use. This will not be supported in the future. In the future,
3482 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003483 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003484 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003485 public static final String RES_PACKAGE = "res_package";
3486
3487 /**
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003488 * The account type to which the raw_contact of this item is associated. See
3489 * {@link RawContacts#ACCOUNT_TYPE}
3490 *
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003491 * <p>Type: TEXT</p>
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003492 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003493 *
3494 * @deprecated - Do not use. This will not be supported in the future. In the future,
3495 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003496 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003497 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003498 public static final String ACCOUNT_TYPE = "account_type";
3499
3500 /**
3501 * The account name to which the raw_contact of this item is associated. See
3502 * {@link RawContacts#ACCOUNT_NAME}
3503 *
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003504 * <p>Type: TEXT</p>
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003505 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003506 *
3507 * @deprecated - Do not use. This will not be supported in the future. In the future,
3508 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003509 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003510 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003511 public static final String ACCOUNT_NAME = "account_name";
3512
3513 /**
3514 * The data set within the account that the raw_contact of this row belongs to. This allows
3515 * multiple sync adapters for the same account type to distinguish between
3516 * each others' data.
3517 * {@link RawContacts#DATA_SET}
3518 *
3519 * <P>Type: TEXT</P>
3520 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003521 *
3522 * @deprecated - Do not use. This will not be supported in the future. In the future,
3523 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003524 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003525 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003526 public static final String DATA_SET = "data_set";
3527
3528 /**
3529 * The source_id of the raw_contact that this row belongs to.
3530 * {@link RawContacts#SOURCE_ID}
3531 *
3532 * <P>Type: TEXT</P>
3533 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003534 *
3535 * @deprecated - Do not use. This will not be supported in the future. In the future,
3536 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003537 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003538 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003539 public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id";
3540
3541 /**
3542 * The resource name of the icon for the source of the stream item.
3543 * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference
3544 * drawables, the "@drawable/" prefix must be omitted.
3545 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003546 *
3547 * @deprecated - Do not use. This will not be supported in the future. In the future,
3548 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003549 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003550 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003551 public static final String RES_ICON = "icon";
3552
3553 /**
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003554 * The resource name of the label describing the source of the status update, e.g. "Google
3555 * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only
3556 * reference strings, the "@string/" prefix must be omitted.
3557 * <p>Type: TEXT</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003558 *
3559 * @deprecated - Do not use. This will not be supported in the future. In the future,
3560 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003561 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003562 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003563 public static final String RES_LABEL = "label";
3564
3565 /**
3566 * <P>
3567 * The main textual contents of the item. Typically this is content
3568 * that was posted by the source of this stream item, but it can also
3569 * be a textual representation of an action (e.g. ”Checked in at Joe's”).
3570 * This text is displayed to the user and allows formatting and embedded
3571 * resource images via HTML (as parseable via
3572 * {@link android.text.Html#fromHtml}).
3573 * </P>
3574 * <P>
3575 * Long content may be truncated and/or ellipsized - the exact behavior
3576 * is unspecified, but it should not break tags.
3577 * </P>
3578 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003579 *
3580 * @deprecated - Do not use. This will not be supported in the future. In the future,
3581 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003582 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003583 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003584 public static final String TEXT = "text";
3585
3586 /**
3587 * The absolute time (milliseconds since epoch) when this stream item was
3588 * inserted/updated.
3589 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003590 *
3591 * @deprecated - Do not use. This will not be supported in the future. In the future,
3592 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003593 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003594 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003595 public static final String TIMESTAMP = "timestamp";
3596
3597 /**
3598 * <P>
3599 * Summary information about the stream item, for example to indicate how
3600 * many people have reshared it, how many have liked it, how many thumbs
3601 * up and/or thumbs down it has, what the original source was, etc.
3602 * </P>
3603 * <P>
3604 * This text is displayed to the user and allows simple formatting via
3605 * HTML, in the same manner as {@link #TEXT} allows.
3606 * </P>
3607 * <P>
3608 * Long content may be truncated and/or ellipsized - the exact behavior
3609 * is unspecified, but it should not break tags.
3610 * </P>
3611 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003612 *
3613 * @deprecated - Do not use. This will not be supported in the future. In the future,
3614 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003615 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003616 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003617 public static final String COMMENTS = "comments";
3618
Brian Attwellbdb13c82014-07-16 21:43:54 -07003619 /**
3620 * Generic column for use by sync adapters.
3621 *
3622 * @deprecated - Do not use. This will not be supported in the future. In the future,
3623 * cursors returned from related queries will be empty.
3624 */
3625 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003626 public static final String SYNC1 = "stream_item_sync1";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003627 /**
3628 * Generic column for use by sync adapters.
3629 *
3630 * @deprecated - Do not use. This will not be supported in the future. In the future,
3631 * cursors returned from related queries will be empty.
3632 */
3633 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003634 public static final String SYNC2 = "stream_item_sync2";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003635 /**
3636 * Generic column for use by sync adapters.
3637 *
3638 * @deprecated - Do not use. This will not be supported in the future. In the future,
3639 * cursors returned from related queries will be empty.
3640 */
3641 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003642 public static final String SYNC3 = "stream_item_sync3";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003643 /**
3644 * Generic column for use by sync adapters.
3645 *
3646 * @deprecated - Do not use. This will not be supported in the future. In the future,
3647 * cursors returned from related queries will be empty.
3648 */
3649 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003650 public static final String SYNC4 = "stream_item_sync4";
Dave Santorod414f102011-06-20 14:35:06 -07003651 }
3652
3653 /**
3654 * <p>
3655 * Constants for the stream_item_photos table, which contains photos associated with
3656 * social stream updates.
3657 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003658 * <p>
3659 * Access to social stream photos requires additional permissions beyond the read/write
3660 * contact permissions required by the provider. Querying for social stream photos
3661 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3662 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3663 * </p>
Makoto Onuki46891a82012-04-26 12:46:47 -07003664 * <h3>Account check</h3>
3665 * <p>
3666 * The content URIs to the insert, update and delete operations are required to have the account
3667 * information matching that of the owning raw contact as query parameters, namely
3668 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3669 * {@link RawContacts#DATA_SET} isn't required.
3670 * </p>
Dave Santorod414f102011-06-20 14:35:06 -07003671 * <h3>Operations</h3>
3672 * <dl>
3673 * <dt><b>Insert</b></dt>
3674 * <dd>
3675 * <p>Social stream photo entries are associated with a social stream item. Photos
3676 * can be inserted into a social stream item in a couple of ways:
3677 * <dl>
3678 * <dt>
3679 * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3680 * stream item:
3681 * </dt>
3682 * <dd>
3683 * <pre>
3684 * ContentValues values = new ContentValues();
3685 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003686 * values.put(StreamItemPhotos.PHOTO, photoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003687 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3688 * ContentUris.appendId(builder, streamItemId);
3689 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3690 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3691 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3692 * Uri photoUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003693 * long photoId = ContentUris.parseId(photoUri);
3694 * </pre>
3695 * </dd>
3696 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3697 * <dd>
3698 * <pre>
3699 * ContentValues values = new ContentValues();
3700 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3701 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003702 * values.put(StreamItemPhotos.PHOTO, photoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003703 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3704 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3705 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3706 * Uri photoUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003707 * long photoId = ContentUris.parseId(photoUri);
3708 * </pre>
3709 * </dd>
3710 * </dl>
3711 * </p>
3712 * </dd>
3713 * <dt><b>Update</b></dt>
3714 * <dd>
3715 * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry,
3716 * identified by both the stream item ID it belongs to and the stream item photo ID.
3717 * This can be specified in two ways.
3718 * <dl>
3719 * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3720 * stream item:
3721 * </dt>
3722 * <dd>
3723 * <pre>
3724 * ContentValues values = new ContentValues();
Dave Santoro040e6b32011-07-15 15:14:08 -07003725 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003726 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3727 * ContentUris.appendId(builder, streamItemId);
3728 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3729 * ContentUris.appendId(builder, streamItemPhotoId);
3730 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3731 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3732 * getContentResolver().update(builder.build(), values, null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003733 * </pre>
3734 * </dd>
3735 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3736 * <dd>
3737 * <pre>
3738 * ContentValues values = new ContentValues();
3739 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
Dave Santoro040e6b32011-07-15 15:14:08 -07003740 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003741 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3742 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3743 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3744 * getContentResolver().update(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003745 * </pre>
3746 * </dd>
3747 * </dl>
3748 * </p>
3749 * </dd>
3750 * <dt><b>Delete</b></dt>
3751 * <dd>Deletes can be made against either a specific photo item in a stream item, or
3752 * against all or a selected subset of photo items under a stream item.
3753 * For example:
3754 * <dl>
3755 * <dt>Deleting a single photo via the
3756 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item:
3757 * </dt>
3758 * <dd>
3759 * <pre>
Makoto Onuki46891a82012-04-26 12:46:47 -07003760 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3761 * ContentUris.appendId(builder, streamItemId);
3762 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3763 * ContentUris.appendId(builder, streamItemPhotoId);
3764 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3765 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3766 * getContentResolver().delete(builder.build(), null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003767 * </pre>
3768 * </dd>
3769 * <dt>Deleting all photos under a stream item</dt>
3770 * <dd>
3771 * <pre>
Makoto Onuki46891a82012-04-26 12:46:47 -07003772 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3773 * ContentUris.appendId(builder, streamItemId);
3774 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3775 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3776 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3777 * getContentResolver().delete(builder.build(), null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003778 * </pre>
3779 * </dd>
3780 * </dl>
3781 * </dd>
3782 * <dt><b>Query</b></dt>
3783 * <dl>
3784 * <dt>Querying for a specific photo in a stream item</dt>
3785 * <dd>
3786 * <pre>
3787 * Cursor c = getContentResolver().query(
3788 * ContentUris.withAppendedId(
3789 * Uri.withAppendedPath(
3790 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3791 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3792 * streamItemPhotoId), null, null, null, null);
3793 * </pre>
3794 * </dd>
3795 * <dt>Querying for all photos in a stream item</dt>
3796 * <dd>
3797 * <pre>
3798 * Cursor c = getContentResolver().query(
3799 * Uri.withAppendedPath(
3800 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3801 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3802 * null, null, null, StreamItemPhotos.SORT_INDEX);
3803 * </pre>
3804 * </dl>
Dave Santoro040e6b32011-07-15 15:14:08 -07003805 * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a
3806 * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID}
3807 * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to
3808 * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as
3809 * an asset file, as follows:
3810 * <pre>
3811 * public InputStream openDisplayPhoto(String photoUri) {
3812 * try {
3813 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
3814 * return fd.createInputStream();
3815 * } catch (IOException e) {
3816 * return null;
3817 * }
3818 * }
3819 * <pre>
Dave Santorod414f102011-06-20 14:35:06 -07003820 * </dd>
3821 * </dl>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003822 *
3823 * @deprecated - Do not use. This will not be supported in the future. In the future,
3824 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003825 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003826 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003827 public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns {
3828 /**
3829 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07003830 *
3831 * @deprecated - Do not use. This will not be supported in the future. In the future,
3832 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003833 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003834 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003835 private StreamItemPhotos() {
3836 }
Dave Santoro040e6b32011-07-15 15:14:08 -07003837
3838 /**
3839 * <p>
3840 * The binary representation of the photo. Any size photo can be inserted;
3841 * the provider will resize it appropriately for storage and display.
3842 * </p>
3843 * <p>
3844 * This is only intended for use when inserting or updating a stream item photo.
3845 * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI}
3846 * as an asset file.
3847 * </p>
3848 * <P>Type: BLOB</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003849 *
3850 * @deprecated - Do not use. This will not be supported in the future. In the future,
3851 * cursors returned from related queries will be empty.
Dave Santoro040e6b32011-07-15 15:14:08 -07003852 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003853 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003854 public static final String PHOTO = "photo";
Dave Santorod414f102011-06-20 14:35:06 -07003855 }
3856
3857 /**
3858 * Columns in the StreamItemPhotos table.
3859 *
3860 * @see ContactsContract.StreamItemPhotos
Brian Attwellbdb13c82014-07-16 21:43:54 -07003861 * @deprecated - Do not use. This will not be supported in the future. In the future,
3862 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003863 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003864 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003865 protected interface StreamItemPhotosColumns {
3866 /**
3867 * A reference to the {@link StreamItems#_ID} this photo is associated with.
3868 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003869 *
3870 * @deprecated - Do not use. This will not be supported in the future. In the future,
3871 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003872 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003873 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003874 public static final String STREAM_ITEM_ID = "stream_item_id";
3875
3876 /**
3877 * An integer to use for sort order for photos in the stream item. If not
3878 * specified, the {@link StreamItemPhotos#_ID} will be used for sorting.
3879 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003880 *
3881 * @deprecated - Do not use. This will not be supported in the future. In the future,
3882 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003883 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003884 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003885 public static final String SORT_INDEX = "sort_index";
3886
3887 /**
Dave Santoro040e6b32011-07-15 15:14:08 -07003888 * Photo file ID for the photo.
3889 * See {@link ContactsContract.DisplayPhoto}.
3890 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003891 *
3892 * @deprecated - Do not use. This will not be supported in the future. In the future,
3893 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003894 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003895 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003896 public static final String PHOTO_FILE_ID = "photo_file_id";
3897
3898 /**
3899 * URI for retrieving the photo content, automatically populated. Callers
3900 * may retrieve the photo content by opening this URI as an asset file.
3901 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003902 *
3903 * @deprecated - Do not use. This will not be supported in the future. In the future,
3904 * cursors returned from related queries will be empty.
Dave Santoro040e6b32011-07-15 15:14:08 -07003905 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003906 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003907 public static final String PHOTO_URI = "photo_uri";
Dave Santorod414f102011-06-20 14:35:06 -07003908
Brian Attwellbdb13c82014-07-16 21:43:54 -07003909 /**
3910 * Generic column for use by sync adapters.
3911 *
3912 * @deprecated - Do not use. This will not be supported in the future. In the future,
3913 * cursors returned from related queries will be empty.
3914 */
3915 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003916 public static final String SYNC1 = "stream_item_photo_sync1";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003917 /**
3918 * Generic column for use by sync adapters.
3919 *
3920 * @deprecated - Do not use. This will not be supported in the future. In the future,
3921 * cursors returned from related queries will be empty.
3922 */
3923 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003924 public static final String SYNC2 = "stream_item_photo_sync2";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003925 /**
3926 * Generic column for use by sync adapters.
3927 *
3928 * @deprecated - Do not use. This will not be supported in the future. In the future,
3929 * cursors returned from related queries will be empty.
3930 */
3931 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003932 public static final String SYNC3 = "stream_item_photo_sync3";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003933 /**
3934 * Generic column for use by sync adapters.
3935 *
3936 * @deprecated - Do not use. This will not be supported in the future. In the future,
3937 * cursors returned from related queries will be empty.
3938 */
3939 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003940 public static final String SYNC4 = "stream_item_photo_sync4";
Dave Santorod414f102011-06-20 14:35:06 -07003941 }
3942
3943 /**
Dave Santoroa5282372011-06-29 00:25:16 -07003944 * <p>
3945 * Constants for the photo files table, which tracks metadata for hi-res photos
3946 * stored in the file system.
3947 * </p>
3948 *
3949 * @hide
3950 */
3951 public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns {
3952 /**
3953 * No public constructor since this is a utility class
3954 */
3955 private PhotoFiles() {
3956 }
3957 }
3958
3959 /**
3960 * Columns in the PhotoFiles table.
3961 *
3962 * @see ContactsContract.PhotoFiles
3963 *
3964 * @hide
3965 */
3966 protected interface PhotoFilesColumns {
3967
3968 /**
3969 * The height, in pixels, of the photo this entry is associated with.
3970 * <P>Type: NUMBER</P>
3971 */
3972 public static final String HEIGHT = "height";
3973
3974 /**
3975 * The width, in pixels, of the photo this entry is associated with.
3976 * <P>Type: NUMBER</P>
3977 */
3978 public static final String WIDTH = "width";
3979
3980 /**
3981 * The size, in bytes, of the photo stored on disk.
3982 * <P>Type: NUMBER</P>
3983 */
3984 public static final String FILESIZE = "filesize";
3985 }
3986
3987 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003988 * Columns in the Data table.
3989 *
3990 * @see ContactsContract.Data
3991 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07003992 protected interface DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07003993 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003994 * The package name to use when creating {@link Resources} objects for
3995 * this data row. This value is only designed for use when building user
3996 * interfaces, and should not be used to infer the owner.
3997 */
3998 public static final String RES_PACKAGE = "res_package";
3999
4000 /**
4001 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -07004002 */
4003 public static final String MIMETYPE = "mimetype";
4004
4005 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004006 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -07004007 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -07004008 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07004009 public static final String RAW_CONTACT_ID = "raw_contact_id";
4010
Evan Millarab5742d2009-06-02 16:21:45 -07004011 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08004012 * Whether this is the primary entry of its kind for the raw contact it belongs to.
Evan Millarab5742d2009-06-02 16:21:45 -07004013 * <P>Type: INTEGER (if set, non-0 means true)</P>
4014 */
4015 public static final String IS_PRIMARY = "is_primary";
4016
4017 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004018 * Whether this is the primary entry of its kind for the aggregate
4019 * contact it belongs to. Any data record that is "super primary" must
4020 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -07004021 * <P>Type: INTEGER (if set, non-0 means true)</P>
4022 */
4023 public static final String IS_SUPER_PRIMARY = "is_super_primary";
4024
Jeff Sharkey28b68e52009-06-10 15:26:58 -07004025 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07004026 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
4027 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
4028 * <P>Type: INTEGER</P>
4029 */
4030 public static final String IS_READ_ONLY = "is_read_only";
4031
4032 /**
Fred Quintanac933fb62009-06-11 12:14:40 -07004033 * The version of this data record. This is a read-only value. The data column is
4034 * guaranteed to not change without the version going up. This value is monotonically
4035 * increasing.
4036 * <P>Type: INTEGER</P>
4037 */
4038 public static final String DATA_VERSION = "data_version";
4039
Evan Millar088b2912009-05-28 15:24:37 -07004040 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4041 public static final String DATA1 = "data1";
4042 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4043 public static final String DATA2 = "data2";
4044 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4045 public static final String DATA3 = "data3";
4046 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4047 public static final String DATA4 = "data4";
4048 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4049 public static final String DATA5 = "data5";
4050 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4051 public static final String DATA6 = "data6";
4052 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4053 public static final String DATA7 = "data7";
4054 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4055 public static final String DATA8 = "data8";
4056 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4057 public static final String DATA9 = "data9";
4058 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4059 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004060 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4061 public static final String DATA11 = "data11";
4062 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4063 public static final String DATA12 = "data12";
4064 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4065 public static final String DATA13 = "data13";
4066 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4067 public static final String DATA14 = "data14";
Tom O'Neill244327e2010-01-08 11:11:15 -08004068 /**
4069 * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
4070 * this field is used to store BLOBs (binary data).
4071 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004072 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07004073
Fred Quintana8851e162009-08-05 21:06:45 -07004074 /** Generic column for use by sync adapters. */
4075 public static final String SYNC1 = "data_sync1";
4076 /** Generic column for use by sync adapters. */
4077 public static final String SYNC2 = "data_sync2";
4078 /** Generic column for use by sync adapters. */
4079 public static final String SYNC3 = "data_sync3";
4080 /** Generic column for use by sync adapters. */
4081 public static final String SYNC4 = "data_sync4";
Evan Millar088b2912009-05-28 15:24:37 -07004082 }
4083
4084 /**
Yorke Lee0dc523f2013-03-12 12:48:06 -07004085 * Columns in the Data_Usage_Stat table
4086 */
4087 protected interface DataUsageStatColumns {
Yorke Lee0dc523f2013-03-12 12:48:06 -07004088 /** The last time (in milliseconds) this {@link Data} was used. */
4089 public static final String LAST_TIME_USED = "last_time_used";
4090
Yorke Lee5a53d702013-03-29 18:08:47 -07004091 /** The number of times the referenced {@link Data} has been used. */
Yorke Lee0dc523f2013-03-12 12:48:06 -07004092 public static final String TIMES_USED = "times_used";
Yorke Lee0dc523f2013-03-12 12:48:06 -07004093 }
4094
4095 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004096 * Combines all columns returned by {@link ContactsContract.Data} table queries.
4097 *
4098 * @see ContactsContract.Data
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004099 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07004100 protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08004101 RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
Yorke Lee0dc523f2013-03-12 12:48:06 -07004102 ContactStatusColumns, DataUsageStatColumns {
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004103 }
4104
4105 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004106 * <p>
4107 * Constants for the data table, which contains data points tied to a raw
Tom O'Neill244327e2010-01-08 11:11:15 -08004108 * contact. Each row of the data table is typically used to store a single
4109 * piece of contact
4110 * information (such as a phone number) and its
4111 * associated metadata (such as whether it is a work or home number).
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004112 * </p>
4113 * <h3>Data kinds</h3>
4114 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004115 * Data is a generic table that can hold any kind of contact data.
4116 * The kind of data stored in a given row is specified by the row's
4117 * {@link #MIMETYPE} value, which determines the meaning of the
4118 * generic columns {@link #DATA1} through
4119 * {@link #DATA15}.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004120 * For example, if the data kind is
Tom O'Neill244327e2010-01-08 11:11:15 -08004121 * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
4122 * {@link #DATA1} stores the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004123 * phone number, but if the data kind is
Tom O'Neill244327e2010-01-08 11:11:15 -08004124 * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
4125 * stores the email address.
4126 * Sync adapters and applications can introduce their own data kinds.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004127 * </p>
4128 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004129 * ContactsContract defines a small number of pre-defined data kinds, e.g.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004130 * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
4131 * convenience, these classes define data kind specific aliases for DATA1 etc.
4132 * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
4133 * {@link ContactsContract.Data Data.DATA1}.
4134 * </p>
4135 * <p>
4136 * {@link #DATA1} is an indexed column and should be used for the data element that is
4137 * expected to be most frequently used in query selections. For example, in the
4138 * case of a row representing email addresses {@link #DATA1} should probably
4139 * be used for the email address itself, while {@link #DATA2} etc can be
4140 * used for auxiliary information like type of email address.
4141 * <p>
4142 * <p>
4143 * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
4144 * </p>
4145 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08004146 * The sync adapter for a given account type must correctly handle every data type
4147 * used in the corresponding raw contacts. Otherwise it could result in lost or
4148 * corrupted data.
4149 * </p>
4150 * <p>
4151 * Similarly, you should refrain from introducing new kinds of data for an other
Tom O'Neill244327e2010-01-08 11:11:15 -08004152 * party's account types. For example, if you add a data row for
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004153 * "favorite song" to a raw contact owned by a Google account, it will not
4154 * get synced to the server, because the Google sync adapter does not know
4155 * how to handle this data kind. Thus new data kinds are typically
4156 * introduced along with new account types, i.e. new sync adapters.
4157 * </p>
4158 * <h3>Batch operations</h3>
4159 * <p>
4160 * Data rows can be inserted/updated/deleted using the traditional
4161 * {@link ContentResolver#insert}, {@link ContentResolver#update} and
4162 * {@link ContentResolver#delete} methods, however the newer mechanism based
4163 * on a batch of {@link ContentProviderOperation} will prove to be a better
4164 * choice in almost all cases. All operations in a batch are executed in a
4165 * single transaction, which ensures that the phone-side and server-side
4166 * state of a raw contact are always consistent. Also, the batch-based
4167 * approach is far more efficient: not only are the database operations
4168 * faster when executed in a single transaction, but also sending a batch of
4169 * commands to the content provider saves a lot of time on context switching
4170 * between your process and the process in which the content provider runs.
4171 * </p>
4172 * <p>
4173 * The flip side of using batched operations is that a large batch may lock
4174 * up the database for a long time preventing other applications from
4175 * accessing data and potentially causing ANRs ("Application Not Responding"
4176 * dialogs.)
4177 * </p>
4178 * <p>
4179 * To avoid such lockups of the database, make sure to insert "yield points"
4180 * in the batch. A yield point indicates to the content provider that before
4181 * executing the next operation it can commit the changes that have already
4182 * been made, yield to other requests, open another transaction and continue
4183 * processing operations. A yield point will not automatically commit the
4184 * transaction, but only if there is another request waiting on the
4185 * database. Normally a sync adapter should insert a yield point at the
4186 * beginning of each raw contact operation sequence in the batch. See
4187 * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
4188 * </p>
4189 * <h3>Operations</h3>
4190 * <dl>
4191 * <dt><b>Insert</b></dt>
4192 * <dd>
4193 * <p>
4194 * An individual data row can be inserted using the traditional
4195 * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
4196 * should always be inserted as a batch.
4197 * </p>
4198 * <p>
4199 * An example of a traditional insert:
4200 * <pre>
4201 * ContentValues values = new ContentValues();
4202 * values.put(Data.RAW_CONTACT_ID, rawContactId);
4203 * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
4204 * values.put(Phone.NUMBER, "1-800-GOOG-411");
4205 * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
4206 * values.put(Phone.LABEL, "free directory assistance");
4207 * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
4208 * </pre>
4209 * <p>
4210 * The same done using ContentProviderOperations:
4211 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004212 * ArrayList&lt;ContentProviderOperation&gt; ops =
4213 * new ArrayList&lt;ContentProviderOperation&gt;();
4214 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004215 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
4216 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
4217 * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
4218 * .withValue(Phone.NUMBER, "1-800-GOOG-411")
4219 * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
4220 * .withValue(Phone.LABEL, "free directory assistance")
4221 * .build());
4222 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4223 * </pre>
4224 * </p>
4225 * <dt><b>Update</b></dt>
4226 * <dd>
4227 * <p>
4228 * Just as with insert, update can be done incrementally or as a batch,
4229 * the batch mode being the preferred method:
4230 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004231 * ArrayList&lt;ContentProviderOperation&gt; ops =
4232 * new ArrayList&lt;ContentProviderOperation&gt;();
4233 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004234 * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
4235 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4236 * .withValue(Email.DATA, "somebody@android.com")
4237 * .build());
4238 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4239 * </pre>
4240 * </p>
4241 * </dd>
4242 * <dt><b>Delete</b></dt>
4243 * <dd>
4244 * <p>
4245 * Just as with insert and update, deletion can be done either using the
4246 * {@link ContentResolver#delete} method or using a ContentProviderOperation:
4247 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004248 * ArrayList&lt;ContentProviderOperation&gt; ops =
4249 * new ArrayList&lt;ContentProviderOperation&gt;();
4250 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004251 * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
4252 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4253 * .build());
4254 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4255 * </pre>
4256 * </p>
4257 * </dd>
4258 * <dt><b>Query</b></dt>
4259 * <dd>
4260 * <p>
4261 * <dl>
4262 * <dt>Finding all Data of a given type for a given contact</dt>
4263 * <dd>
4264 * <pre>
4265 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4266 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4267 * Data.CONTACT_ID + &quot;=?&quot; + " AND "
4268 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4269 * new String[] {String.valueOf(contactId)}, null);
4270 * </pre>
4271 * </p>
4272 * <p>
4273 * </dd>
4274 * <dt>Finding all Data of a given type for a given raw contact</dt>
4275 * <dd>
4276 * <pre>
4277 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4278 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4279 * Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
4280 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4281 * new String[] {String.valueOf(rawContactId)}, null);
4282 * </pre>
4283 * </dd>
4284 * <dt>Finding all Data for a given raw contact</dt>
4285 * <dd>
4286 * Most sync adapters will want to read all data rows for a raw contact
4287 * along with the raw contact itself. For that you should use the
4288 * {@link RawContactsEntity}. See also {@link RawContacts}.
4289 * </dd>
4290 * </dl>
4291 * </p>
4292 * </dd>
4293 * </dl>
4294 * <h2>Columns</h2>
Tom O'Neill244327e2010-01-08 11:11:15 -08004295 * <p>
4296 * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you
4297 * should explicitly specify a projection to only those columns that you need.
4298 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004299 * <table class="jd-sumtable">
4300 * <tr>
4301 * <th colspan='4'>Data</th>
4302 * </tr>
4303 * <tr>
4304 * <td style="width: 7em;">long</td>
4305 * <td style="width: 20em;">{@link #_ID}</td>
4306 * <td style="width: 5em;">read-only</td>
4307 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
Tom O'Neill244327e2010-01-08 11:11:15 -08004308 * it would be a bad idea to delete and reinsert a data row. A sync adapter should
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004309 * always do an update instead.</td>
4310 * </tr>
4311 * <tr>
4312 * <td>String</td>
4313 * <td>{@link #MIMETYPE}</td>
4314 * <td>read/write-once</td>
4315 * <td>
4316 * <p>The MIME type of the item represented by this row. Examples of common
4317 * MIME types are:
4318 * <ul>
4319 * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
4320 * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
4321 * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
4322 * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
4323 * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
4324 * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
4325 * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
4326 * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
4327 * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
4328 * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
4329 * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
4330 * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
4331 * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
David Brown846eb302010-08-23 17:40:51 -07004332 * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004333 * </ul>
4334 * </p>
4335 * </td>
4336 * </tr>
4337 * <tr>
4338 * <td>long</td>
4339 * <td>{@link #RAW_CONTACT_ID}</td>
4340 * <td>read/write-once</td>
Tom O'Neill244327e2010-01-08 11:11:15 -08004341 * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004342 * </tr>
4343 * <tr>
4344 * <td>int</td>
4345 * <td>{@link #IS_PRIMARY}</td>
4346 * <td>read/write</td>
4347 * <td>Whether this is the primary entry of its kind for the raw contact it belongs to.
Tom O'Neill244327e2010-01-08 11:11:15 -08004348 * "1" if true, "0" if false.
4349 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004350 * </tr>
4351 * <tr>
4352 * <td>int</td>
4353 * <td>{@link #IS_SUPER_PRIMARY}</td>
4354 * <td>read/write</td>
4355 * <td>Whether this is the primary entry of its kind for the aggregate
4356 * contact it belongs to. Any data record that is "super primary" must
Tom O'Neill244327e2010-01-08 11:11:15 -08004357 * also be "primary". For example, the super-primary entry may be
4358 * interpreted as the default contact value of its kind (for example,
4359 * the default phone number to use for the contact).</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004360 * </tr>
4361 * <tr>
4362 * <td>int</td>
4363 * <td>{@link #DATA_VERSION}</td>
4364 * <td>read-only</td>
4365 * <td>The version of this data record. Whenever the data row changes
4366 * the version goes up. This value is monotonically increasing.</td>
4367 * </tr>
4368 * <tr>
4369 * <td>Any type</td>
4370 * <td>
4371 * {@link #DATA1}<br>
4372 * {@link #DATA2}<br>
4373 * {@link #DATA3}<br>
4374 * {@link #DATA4}<br>
4375 * {@link #DATA5}<br>
4376 * {@link #DATA6}<br>
4377 * {@link #DATA7}<br>
4378 * {@link #DATA8}<br>
4379 * {@link #DATA9}<br>
4380 * {@link #DATA10}<br>
4381 * {@link #DATA11}<br>
4382 * {@link #DATA12}<br>
4383 * {@link #DATA13}<br>
4384 * {@link #DATA14}<br>
4385 * {@link #DATA15}
4386 * </td>
4387 * <td>read/write</td>
Tom O'Neill244327e2010-01-08 11:11:15 -08004388 * <td>
4389 * <p>
4390 * Generic data columns. The meaning of each column is determined by the
4391 * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing
4392 * BLOBs (binary data).
4393 * </p>
4394 * <p>
4395 * Data columns whose meaning is not explicitly defined for a given MIMETYPE
4396 * should not be used. There is no guarantee that any sync adapter will
4397 * preserve them. Sync adapters themselves should not use such columns either,
4398 * but should instead use {@link #SYNC1}-{@link #SYNC4}.
4399 * </p>
4400 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004401 * </tr>
4402 * <tr>
4403 * <td>Any type</td>
4404 * <td>
4405 * {@link #SYNC1}<br>
4406 * {@link #SYNC2}<br>
4407 * {@link #SYNC3}<br>
4408 * {@link #SYNC4}
4409 * </td>
4410 * <td>read/write</td>
4411 * <td>Generic columns for use by sync adapters. For example, a Photo row
4412 * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
4413 * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
4414 * </tr>
4415 * </table>
4416 *
Tom O'Neill244327e2010-01-08 11:11:15 -08004417 * <p>
4418 * Some columns from the most recent associated status update are also available
4419 * through an implicit join.
4420 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004421 * <table class="jd-sumtable">
4422 * <tr>
4423 * <th colspan='4'>Join with {@link StatusUpdates}</th>
4424 * </tr>
4425 * <tr>
4426 * <td style="width: 7em;">int</td>
4427 * <td style="width: 20em;">{@link #PRESENCE}</td>
4428 * <td style="width: 5em;">read-only</td>
4429 * <td>IM presence status linked to this data row. Compare with
4430 * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
4431 * all IM rows. See {@link StatusUpdates} for individual status definitions.
4432 * The provider may choose not to store this value
4433 * in persistent storage. The expectation is that presence status will be
kmccormick50e27c82013-03-28 16:33:11 -07004434 * updated on a regular basis.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004435 * </td>
4436 * </tr>
4437 * <tr>
4438 * <td>String</td>
4439 * <td>{@link #STATUS}</td>
4440 * <td>read-only</td>
4441 * <td>Latest status update linked with this data row.</td>
4442 * </tr>
4443 * <tr>
4444 * <td>long</td>
4445 * <td>{@link #STATUS_TIMESTAMP}</td>
4446 * <td>read-only</td>
4447 * <td>The absolute time in milliseconds when the latest status was
4448 * inserted/updated for this data row.</td>
4449 * </tr>
4450 * <tr>
4451 * <td>String</td>
4452 * <td>{@link #STATUS_RES_PACKAGE}</td>
4453 * <td>read-only</td>
4454 * <td>The package containing resources for this status: label and icon.</td>
4455 * </tr>
4456 * <tr>
4457 * <td>long</td>
4458 * <td>{@link #STATUS_LABEL}</td>
4459 * <td>read-only</td>
4460 * <td>The resource ID of the label describing the source of status update linked
4461 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4462 * </tr>
4463 * <tr>
4464 * <td>long</td>
4465 * <td>{@link #STATUS_ICON}</td>
4466 * <td>read-only</td>
4467 * <td>The resource ID of the icon for the source of the status update linked
4468 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4469 * </tr>
4470 * </table>
4471 *
4472 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004473 * Some columns from the associated raw contact are also available through an
4474 * implicit join. The other columns are excluded as uninteresting in this
4475 * context.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004476 * </p>
4477 *
4478 * <table class="jd-sumtable">
4479 * <tr>
Tom O'Neill244327e2010-01-08 11:11:15 -08004480 * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004481 * </tr>
4482 * <tr>
Tom O'Neill244327e2010-01-08 11:11:15 -08004483 * <td style="width: 7em;">long</td>
4484 * <td style="width: 20em;">{@link #CONTACT_ID}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004485 * <td style="width: 5em;">read-only</td>
Tom O'Neill244327e2010-01-08 11:11:15 -08004486 * <td>The id of the row in the {@link Contacts} table that this data belongs
4487 * to.</td>
4488 * </tr>
4489 * <tr>
4490 * <td>int</td>
4491 * <td>{@link #AGGREGATION_MODE}</td>
4492 * <td>read-only</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004493 * <td>See {@link RawContacts}.</td>
4494 * </tr>
4495 * <tr>
4496 * <td>int</td>
4497 * <td>{@link #DELETED}</td>
4498 * <td>read-only</td>
4499 * <td>See {@link RawContacts}.</td>
4500 * </tr>
4501 * </table>
4502 *
4503 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004504 * The ID column for the associated aggregated contact table
4505 * {@link ContactsContract.Contacts} is available
4506 * via the implicit join to the {@link RawContacts} table, see above.
4507 * The remaining columns from this table are also
4508 * available, through an implicit join. This
4509 * facilitates lookup by
4510 * the value of a single data element, such as the email address.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004511 * </p>
4512 *
4513 * <table class="jd-sumtable">
4514 * <tr>
Tom O'Neill244327e2010-01-08 11:11:15 -08004515 * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004516 * </tr>
4517 * <tr>
4518 * <td style="width: 7em;">String</td>
4519 * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
4520 * <td style="width: 5em;">read-only</td>
4521 * <td>See {@link ContactsContract.Contacts}</td>
4522 * </tr>
4523 * <tr>
4524 * <td>String</td>
4525 * <td>{@link #DISPLAY_NAME}</td>
4526 * <td>read-only</td>
4527 * <td>See {@link ContactsContract.Contacts}</td>
4528 * </tr>
4529 * <tr>
4530 * <td>long</td>
4531 * <td>{@link #PHOTO_ID}</td>
4532 * <td>read-only</td>
4533 * <td>See {@link ContactsContract.Contacts}.</td>
4534 * </tr>
4535 * <tr>
4536 * <td>int</td>
4537 * <td>{@link #IN_VISIBLE_GROUP}</td>
4538 * <td>read-only</td>
4539 * <td>See {@link ContactsContract.Contacts}.</td>
4540 * </tr>
4541 * <tr>
4542 * <td>int</td>
4543 * <td>{@link #HAS_PHONE_NUMBER}</td>
4544 * <td>read-only</td>
4545 * <td>See {@link ContactsContract.Contacts}.</td>
4546 * </tr>
4547 * <tr>
4548 * <td>int</td>
4549 * <td>{@link #TIMES_CONTACTED}</td>
4550 * <td>read-only</td>
4551 * <td>See {@link ContactsContract.Contacts}.</td>
4552 * </tr>
4553 * <tr>
4554 * <td>long</td>
4555 * <td>{@link #LAST_TIME_CONTACTED}</td>
4556 * <td>read-only</td>
4557 * <td>See {@link ContactsContract.Contacts}.</td>
4558 * </tr>
4559 * <tr>
4560 * <td>int</td>
4561 * <td>{@link #STARRED}</td>
4562 * <td>read-only</td>
4563 * <td>See {@link ContactsContract.Contacts}.</td>
4564 * </tr>
4565 * <tr>
4566 * <td>String</td>
4567 * <td>{@link #CUSTOM_RINGTONE}</td>
4568 * <td>read-only</td>
4569 * <td>See {@link ContactsContract.Contacts}.</td>
4570 * </tr>
4571 * <tr>
4572 * <td>int</td>
4573 * <td>{@link #SEND_TO_VOICEMAIL}</td>
4574 * <td>read-only</td>
4575 * <td>See {@link ContactsContract.Contacts}.</td>
4576 * </tr>
4577 * <tr>
4578 * <td>int</td>
4579 * <td>{@link #CONTACT_PRESENCE}</td>
4580 * <td>read-only</td>
4581 * <td>See {@link ContactsContract.Contacts}.</td>
4582 * </tr>
4583 * <tr>
4584 * <td>String</td>
4585 * <td>{@link #CONTACT_STATUS}</td>
4586 * <td>read-only</td>
4587 * <td>See {@link ContactsContract.Contacts}.</td>
4588 * </tr>
4589 * <tr>
4590 * <td>long</td>
4591 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
4592 * <td>read-only</td>
4593 * <td>See {@link ContactsContract.Contacts}.</td>
4594 * </tr>
4595 * <tr>
4596 * <td>String</td>
4597 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
4598 * <td>read-only</td>
4599 * <td>See {@link ContactsContract.Contacts}.</td>
4600 * </tr>
4601 * <tr>
4602 * <td>long</td>
4603 * <td>{@link #CONTACT_STATUS_LABEL}</td>
4604 * <td>read-only</td>
4605 * <td>See {@link ContactsContract.Contacts}.</td>
4606 * </tr>
4607 * <tr>
4608 * <td>long</td>
4609 * <td>{@link #CONTACT_STATUS_ICON}</td>
4610 * <td>read-only</td>
4611 * <td>See {@link ContactsContract.Contacts}.</td>
4612 * </tr>
4613 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004614 */
Yorke Lee94c87612014-07-18 18:57:17 -07004615 public final static class Data implements DataColumnsWithJoins, ContactCounts {
Evan Millar088b2912009-05-28 15:24:37 -07004616 /**
4617 * This utility class cannot be instantiated
4618 */
4619 private Data() {}
4620
4621 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08004622 * The content:// style URI for this table, which requests a directory
4623 * of data rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07004624 */
4625 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
4626
4627 /**
Yorke Lee4f401eb2013-03-06 17:17:17 -08004628 * A boolean parameter for {@link Data#CONTENT_URI}.
4629 * This specifies whether or not the returned data items should be filtered to show
4630 * data items belonging to visible contacts only.
4631 */
4632 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
4633
4634 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08004635 * The MIME type of the results from {@link #CONTENT_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07004636 */
4637 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07004638
4639 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08004640 * <p>
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004641 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
4642 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004643 * entry of the given {@link ContactsContract.Data} entry.
Tom O'Neill244327e2010-01-08 11:11:15 -08004644 * </p>
4645 * <p>
4646 * Returns the Uri for the contact in the first entry returned by
4647 * {@link ContentResolver#query(Uri, String[], String, String[], String)}
4648 * for the provided {@code dataUri}. If the query returns null or empty
4649 * results, silently returns null.
4650 * </p>
Jeff Sharkey6449eb02009-09-16 21:41:51 -07004651 */
4652 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
4653 final Cursor cursor = resolver.query(dataUri, new String[] {
4654 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
4655 }, null, null, null);
4656
4657 Uri lookupUri = null;
4658 try {
4659 if (cursor != null && cursor.moveToFirst()) {
4660 final long contactId = cursor.getLong(0);
4661 final String lookupKey = cursor.getString(1);
4662 return Contacts.getLookupUri(contactId, lookupKey);
4663 }
4664 } finally {
4665 if (cursor != null) cursor.close();
4666 }
4667 return lookupUri;
4668 }
Evan Millar088b2912009-05-28 15:24:37 -07004669 }
4670
Fred Quintana5bba6322009-10-05 14:21:12 -07004671 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004672 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004673 * Constants for the raw contacts entities table, which can be thought of as
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004674 * an outer join of the raw_contacts table with the data table. It is a strictly
4675 * read-only table.
4676 * </p>
4677 * <p>
4678 * If a raw contact has data rows, the RawContactsEntity cursor will contain
4679 * a one row for each data row. If the raw contact has no data rows, the
4680 * cursor will still contain one row with the raw contact-level information
4681 * and nulls for data columns.
4682 *
4683 * <pre>
4684 * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
4685 * Cursor c = getContentResolver().query(entityUri,
4686 * new String[]{
4687 * RawContactsEntity.SOURCE_ID,
4688 * RawContactsEntity.DATA_ID,
4689 * RawContactsEntity.MIMETYPE,
4690 * RawContactsEntity.DATA1
4691 * }, null, null, null);
4692 * try {
4693 * while (c.moveToNext()) {
4694 * String sourceId = c.getString(0);
4695 * if (!c.isNull(1)) {
4696 * String mimeType = c.getString(2);
4697 * String data = c.getString(3);
4698 * ...
4699 * }
4700 * }
4701 * } finally {
4702 * c.close();
4703 * }
4704 * </pre>
4705 *
4706 * <h3>Columns</h3>
4707 * RawContactsEntity has a combination of RawContact and Data columns.
4708 *
4709 * <table class="jd-sumtable">
4710 * <tr>
4711 * <th colspan='4'>RawContacts</th>
4712 * </tr>
4713 * <tr>
4714 * <td style="width: 7em;">long</td>
4715 * <td style="width: 20em;">{@link #_ID}</td>
4716 * <td style="width: 5em;">read-only</td>
4717 * <td>Raw contact row ID. See {@link RawContacts}.</td>
4718 * </tr>
4719 * <tr>
4720 * <td>long</td>
4721 * <td>{@link #CONTACT_ID}</td>
4722 * <td>read-only</td>
4723 * <td>See {@link RawContacts}.</td>
4724 * </tr>
4725 * <tr>
4726 * <td>int</td>
4727 * <td>{@link #AGGREGATION_MODE}</td>
4728 * <td>read-only</td>
4729 * <td>See {@link RawContacts}.</td>
4730 * </tr>
4731 * <tr>
4732 * <td>int</td>
4733 * <td>{@link #DELETED}</td>
4734 * <td>read-only</td>
4735 * <td>See {@link RawContacts}.</td>
4736 * </tr>
4737 * </table>
4738 *
4739 * <table class="jd-sumtable">
4740 * <tr>
4741 * <th colspan='4'>Data</th>
4742 * </tr>
4743 * <tr>
4744 * <td style="width: 7em;">long</td>
4745 * <td style="width: 20em;">{@link #DATA_ID}</td>
4746 * <td style="width: 5em;">read-only</td>
4747 * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
4748 * </tr>
4749 * <tr>
4750 * <td>String</td>
4751 * <td>{@link #MIMETYPE}</td>
4752 * <td>read-only</td>
4753 * <td>See {@link ContactsContract.Data}.</td>
4754 * </tr>
4755 * <tr>
4756 * <td>int</td>
4757 * <td>{@link #IS_PRIMARY}</td>
4758 * <td>read-only</td>
4759 * <td>See {@link ContactsContract.Data}.</td>
4760 * </tr>
4761 * <tr>
4762 * <td>int</td>
4763 * <td>{@link #IS_SUPER_PRIMARY}</td>
4764 * <td>read-only</td>
4765 * <td>See {@link ContactsContract.Data}.</td>
4766 * </tr>
4767 * <tr>
4768 * <td>int</td>
4769 * <td>{@link #DATA_VERSION}</td>
4770 * <td>read-only</td>
4771 * <td>See {@link ContactsContract.Data}.</td>
4772 * </tr>
4773 * <tr>
4774 * <td>Any type</td>
4775 * <td>
4776 * {@link #DATA1}<br>
4777 * {@link #DATA2}<br>
4778 * {@link #DATA3}<br>
4779 * {@link #DATA4}<br>
4780 * {@link #DATA5}<br>
4781 * {@link #DATA6}<br>
4782 * {@link #DATA7}<br>
4783 * {@link #DATA8}<br>
4784 * {@link #DATA9}<br>
4785 * {@link #DATA10}<br>
4786 * {@link #DATA11}<br>
4787 * {@link #DATA12}<br>
4788 * {@link #DATA13}<br>
4789 * {@link #DATA14}<br>
4790 * {@link #DATA15}
4791 * </td>
4792 * <td>read-only</td>
4793 * <td>See {@link ContactsContract.Data}.</td>
4794 * </tr>
4795 * <tr>
4796 * <td>Any type</td>
4797 * <td>
4798 * {@link #SYNC1}<br>
4799 * {@link #SYNC2}<br>
4800 * {@link #SYNC3}<br>
4801 * {@link #SYNC4}
4802 * </td>
4803 * <td>read-only</td>
4804 * <td>See {@link ContactsContract.Data}.</td>
4805 * </tr>
4806 * </table>
Fred Quintana5bba6322009-10-05 14:21:12 -07004807 */
4808 public final static class RawContactsEntity
4809 implements BaseColumns, DataColumns, RawContactsColumns {
4810 /**
4811 * This utility class cannot be instantiated
4812 */
4813 private RawContactsEntity() {}
4814
4815 /**
4816 * The content:// style URI for this table
4817 */
4818 public static final Uri CONTENT_URI =
4819 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
4820
4821 /**
Dave Santoro2b4d0752011-09-07 17:37:33 -07004822 * The content:// style URI for this table, specific to the user's profile.
4823 */
4824 public static final Uri PROFILE_CONTENT_URI =
4825 Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities");
4826
4827 /**
Fred Quintana5bba6322009-10-05 14:21:12 -07004828 * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
4829 */
4830 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
4831
4832 /**
4833 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
4834 * Data.CONTENT_URI contains only exportable data.
4835 *
4836 * This flag is useful (currently) only for vCard exporter in Contacts app, which
4837 * needs to exclude "un-exportable" data from available data to export, while
4838 * Contacts app itself has priviledge to access all data including "un-expotable"
4839 * ones and providers return all of them regardless of the callers' intention.
4840 * <P>Type: INTEGER</p>
4841 *
4842 * @hide Maybe available only in Eclair and not really ready for public use.
4843 * TODO: remove, or implement this feature completely. As of now (Eclair),
4844 * we only use this flag in queryEntities(), not query().
4845 */
4846 public static final String FOR_EXPORT_ONLY = "for_export_only";
4847
4848 /**
4849 * The ID of the data column. The value will be null if this raw contact has no data rows.
4850 * <P>Type: INTEGER</P>
4851 */
4852 public static final String DATA_ID = "data_id";
4853 }
4854
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004855 /**
4856 * @see PhoneLookup
4857 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07004858 protected interface PhoneLookupColumns {
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004859 /**
4860 * The phone number as the user entered it.
4861 * <P>Type: TEXT</P>
4862 */
4863 public static final String NUMBER = "number";
4864
4865 /**
4866 * The type of phone number, for example Home or Work.
4867 * <P>Type: INTEGER</P>
4868 */
4869 public static final String TYPE = "type";
4870
4871 /**
4872 * The user defined label for the phone number.
4873 * <P>Type: TEXT</P>
4874 */
4875 public static final String LABEL = "label";
Bai Tao224744c2010-08-31 09:59:13 +08004876
4877 /**
4878 * The phone number's E164 representation.
4879 * <P>Type: TEXT</P>
Bai Tao224744c2010-08-31 09:59:13 +08004880 */
4881 public static final String NORMALIZED_NUMBER = "normalized_number";
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004882 }
4883
Evan Millar088b2912009-05-28 15:24:37 -07004884 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004885 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004886 * example for caller ID. To perform a lookup you must append the number you
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004887 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly
4888 * optimized.
4889 * <pre>
4890 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
4891 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
4892 * </pre>
4893 *
4894 * <h3>Columns</h3>
4895 *
4896 * <table class="jd-sumtable">
4897 * <tr>
4898 * <th colspan='4'>PhoneLookup</th>
4899 * </tr>
4900 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004901 * <td>String</td>
4902 * <td>{@link #NUMBER}</td>
4903 * <td>read-only</td>
4904 * <td>Phone number.</td>
4905 * </tr>
4906 * <tr>
4907 * <td>String</td>
4908 * <td>{@link #TYPE}</td>
4909 * <td>read-only</td>
4910 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
4911 * </tr>
4912 * <tr>
4913 * <td>String</td>
4914 * <td>{@link #LABEL}</td>
4915 * <td>read-only</td>
4916 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
4917 * </tr>
4918 * </table>
4919 * <p>
4920 * Columns from the Contacts table are also available through a join.
4921 * </p>
4922 * <table class="jd-sumtable">
4923 * <tr>
4924 * <th colspan='4'>Join with {@link Contacts}</th>
4925 * </tr>
4926 * <tr>
Dmitri Plotnikov817b3f92011-01-09 17:07:13 -08004927 * <td>long</td>
4928 * <td>{@link #_ID}</td>
4929 * <td>read-only</td>
4930 * <td>Contact ID.</td>
4931 * </tr>
4932 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004933 * <td>String</td>
4934 * <td>{@link #LOOKUP_KEY}</td>
4935 * <td>read-only</td>
4936 * <td>See {@link ContactsContract.Contacts}</td>
4937 * </tr>
4938 * <tr>
4939 * <td>String</td>
4940 * <td>{@link #DISPLAY_NAME}</td>
4941 * <td>read-only</td>
4942 * <td>See {@link ContactsContract.Contacts}</td>
4943 * </tr>
4944 * <tr>
4945 * <td>long</td>
4946 * <td>{@link #PHOTO_ID}</td>
4947 * <td>read-only</td>
4948 * <td>See {@link ContactsContract.Contacts}.</td>
4949 * </tr>
4950 * <tr>
4951 * <td>int</td>
4952 * <td>{@link #IN_VISIBLE_GROUP}</td>
4953 * <td>read-only</td>
4954 * <td>See {@link ContactsContract.Contacts}.</td>
4955 * </tr>
4956 * <tr>
4957 * <td>int</td>
4958 * <td>{@link #HAS_PHONE_NUMBER}</td>
4959 * <td>read-only</td>
4960 * <td>See {@link ContactsContract.Contacts}.</td>
4961 * </tr>
4962 * <tr>
4963 * <td>int</td>
4964 * <td>{@link #TIMES_CONTACTED}</td>
4965 * <td>read-only</td>
4966 * <td>See {@link ContactsContract.Contacts}.</td>
4967 * </tr>
4968 * <tr>
4969 * <td>long</td>
4970 * <td>{@link #LAST_TIME_CONTACTED}</td>
4971 * <td>read-only</td>
4972 * <td>See {@link ContactsContract.Contacts}.</td>
4973 * </tr>
4974 * <tr>
4975 * <td>int</td>
4976 * <td>{@link #STARRED}</td>
4977 * <td>read-only</td>
4978 * <td>See {@link ContactsContract.Contacts}.</td>
4979 * </tr>
4980 * <tr>
4981 * <td>String</td>
4982 * <td>{@link #CUSTOM_RINGTONE}</td>
4983 * <td>read-only</td>
4984 * <td>See {@link ContactsContract.Contacts}.</td>
4985 * </tr>
4986 * <tr>
4987 * <td>int</td>
4988 * <td>{@link #SEND_TO_VOICEMAIL}</td>
4989 * <td>read-only</td>
4990 * <td>See {@link ContactsContract.Contacts}.</td>
4991 * </tr>
4992 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004993 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004994 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
4995 ContactsColumns, ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -07004996 /**
4997 * This utility class cannot be instantiated
4998 */
4999 private PhoneLookup() {}
5000
5001 /**
5002 * The content:// style URI for this table. Append the phone number you want to lookup
5003 * to this URI and query it to perform a lookup. For example:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005004 * <pre>
Scott Kennedy7ed189e2013-01-11 22:31:43 -08005005 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
5006 * Uri.encode(phoneNumber));
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005007 * </pre>
Evan Millar088b2912009-05-28 15:24:37 -07005008 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005009 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5010 "phone_lookup");
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08005011
5012 /**
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005013 * URI used for the "enterprise caller-id".
5014 *
5015 * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same
5016 * columns. If the device has no corp profile that is linked to the current profile, it
5017 * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile
5018 * linked to the current profile, it first queries against the personal contact database,
5019 * and if no matching contacts are found there, then queries against the
5020 * corp contacts database.
5021 * <p>
5022 * If a result is from the corp profile, it makes the following changes to the data:
5023 * <ul>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005024 * <li>
5025 * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
5026 * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
5027 * load pictures from them.
Makoto Onuki80b3ab62014-07-10 11:24:21 -07005028 * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them.
5029 * </li>
5030 * <li>
5031 * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact
Makoto Onuki0e917332014-08-26 14:06:30 -07005032 * is from the corp profile, use
5033 * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005034 * </li>
5035 * </ul>
Makoto Onuki95a9cfb2014-07-08 17:11:54 -07005036 * <p>
5037 * This URI does NOT support selection nor order-by.
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005038 *
5039 * <pre>
5040 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
5041 * Uri.encode(phoneNumber));
5042 * </pre>
5043 */
5044 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5045 "phone_lookup_enterprise");
5046
5047 /**
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08005048 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows.
5049 *
5050 * @hide
5051 */
5052 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup";
Flavio Lerda52c01c22011-11-02 22:16:23 +00005053
Yorke Lee217d8a72013-11-27 10:14:04 -08005054 /**
5055 * If this boolean parameter is set to true, then the appended query is treated as a
5056 * SIP address and the lookup will be performed against SIP addresses in the user's
5057 * contacts.
5058 */
Flavio Lerda52c01c22011-11-02 22:16:23 +00005059 public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005060 }
5061
5062 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005063 * Additional data mixed in with {@link StatusColumns} to link
5064 * back to specific {@link ContactsContract.Data#_ID} entries.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005065 *
5066 * @see StatusUpdates
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005067 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005068 protected interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -07005069
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005070 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005071 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005072 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005073 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005074 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005075
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005076 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005077 * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07005078 * <p>Type: NUMBER</p>
5079 */
5080 public static final String PROTOCOL = "protocol";
5081
5082 /**
5083 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
5084 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
5085 * omitted if {@link #PROTOCOL} value is not
5086 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
5087 *
5088 * <p>Type: NUMBER</p>
5089 */
5090 public static final String CUSTOM_PROTOCOL = "custom_protocol";
5091
5092 /**
5093 * The IM handle the presence item is for. The handle is scoped to
5094 * {@link #PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005095 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005096 */
5097 public static final String IM_HANDLE = "im_handle";
5098
5099 /**
5100 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005101 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005102 */
5103 public static final String IM_ACCOUNT = "im_account";
5104 }
5105
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005106 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005107 * <p>
5108 * A status update is linked to a {@link ContactsContract.Data} row and captures
5109 * the user's latest status update via the corresponding source, e.g.
5110 * "Having lunch" via "Google Talk".
5111 * </p>
5112 * <p>
5113 * There are two ways a status update can be inserted: by explicitly linking
5114 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
5115 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5116 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use
5117 * either.
5118 * </p>
5119 * <p>
Dave Santoro063084e2011-08-23 15:42:49 -07005120 * Inserting or updating a status update for the user's profile requires either using
5121 * the {@link #DATA_ID} to identify the data row to attach the update to, or
5122 * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the
5123 * profile.
5124 * </p>
5125 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005126 * You cannot use {@link ContentResolver#update} to change a status, but
5127 * {@link ContentResolver#insert} will replace the latests status if it already
5128 * exists.
5129 * </p>
5130 * <p>
5131 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
5132 * for multiple contacts at once.
5133 * </p>
5134 *
5135 * <h3>Columns</h3>
5136 * <table class="jd-sumtable">
5137 * <tr>
5138 * <th colspan='4'>StatusUpdates</th>
5139 * </tr>
5140 * <tr>
5141 * <td>long</td>
5142 * <td>{@link #DATA_ID}</td>
5143 * <td>read/write</td>
5144 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
5145 * field is <i>not</i> specified, the provider will attempt to find a data row
5146 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5147 * {@link #IM_HANDLE} columns.
5148 * </td>
5149 * </tr>
5150 * <tr>
5151 * <td>long</td>
5152 * <td>{@link #PROTOCOL}</td>
5153 * <td>read/write</td>
5154 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
5155 * </tr>
5156 * <tr>
5157 * <td>String</td>
5158 * <td>{@link #CUSTOM_PROTOCOL}</td>
5159 * <td>read/write</td>
5160 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
5161 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
5162 * omitted if {@link #PROTOCOL} value is not
5163 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
5164 * </tr>
5165 * <tr>
5166 * <td>String</td>
5167 * <td>{@link #IM_HANDLE}</td>
5168 * <td>read/write</td>
5169 * <td> The IM handle the presence item is for. The handle is scoped to
5170 * {@link #PROTOCOL}.</td>
5171 * </tr>
5172 * <tr>
5173 * <td>String</td>
5174 * <td>{@link #IM_ACCOUNT}</td>
5175 * <td>read/write</td>
5176 * <td>The IM account for the local user that the presence data came from.</td>
5177 * </tr>
5178 * <tr>
5179 * <td>int</td>
5180 * <td>{@link #PRESENCE}</td>
5181 * <td>read/write</td>
5182 * <td>Contact IM presence status. The allowed values are:
5183 * <p>
5184 * <ul>
5185 * <li>{@link #OFFLINE}</li>
5186 * <li>{@link #INVISIBLE}</li>
5187 * <li>{@link #AWAY}</li>
5188 * <li>{@link #IDLE}</li>
5189 * <li>{@link #DO_NOT_DISTURB}</li>
5190 * <li>{@link #AVAILABLE}</li>
5191 * </ul>
5192 * </p>
5193 * <p>
5194 * Since presence status is inherently volatile, the content provider
5195 * may choose not to store this field in long-term storage.
5196 * </p>
5197 * </td>
5198 * </tr>
5199 * <tr>
Vasu Nori5b314982010-07-12 15:13:37 -07005200 * <td>int</td>
5201 * <td>{@link #CHAT_CAPABILITY}</td>
5202 * <td>read/write</td>
Daniel Lehmannb3327472010-08-13 15:16:11 -07005203 * <td>Contact IM chat compatibility value. The allowed values combinations of the following
5204 * flags. If None of these flags is set, the device can only do text messaging.
Vasu Nori5b314982010-07-12 15:13:37 -07005205 * <p>
5206 * <ul>
Daniel Lehmannb3327472010-08-13 15:16:11 -07005207 * <li>{@link #CAPABILITY_HAS_VIDEO}</li>
Vasu Nori5b314982010-07-12 15:13:37 -07005208 * <li>{@link #CAPABILITY_HAS_VOICE}</li>
5209 * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
5210 * </ul>
5211 * </p>
5212 * <p>
5213 * Since chat compatibility is inherently volatile as the contact's availability moves from
5214 * one device to another, the content provider may choose not to store this field in long-term
5215 * storage.
5216 * </p>
5217 * </td>
5218 * </tr>
5219 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005220 * <td>String</td>
5221 * <td>{@link #STATUS}</td>
5222 * <td>read/write</td>
5223 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
5224 * </tr>
5225 * <tr>
5226 * <td>long</td>
5227 * <td>{@link #STATUS_TIMESTAMP}</td>
5228 * <td>read/write</td>
5229 * <td>The absolute time in milliseconds when the status was
5230 * entered by the user. If this value is not provided, the provider will follow
5231 * this logic: if there was no prior status update, the value will be left as null.
5232 * If there was a prior status update, the provider will default this field
5233 * to the current time.</td>
5234 * </tr>
5235 * <tr>
5236 * <td>String</td>
5237 * <td>{@link #STATUS_RES_PACKAGE}</td>
5238 * <td>read/write</td>
5239 * <td> The package containing resources for this status: label and icon.</td>
5240 * </tr>
5241 * <tr>
5242 * <td>long</td>
5243 * <td>{@link #STATUS_LABEL}</td>
5244 * <td>read/write</td>
5245 * <td>The resource ID of the label describing the source of contact status,
5246 * e.g. "Google Talk". This resource is scoped by the
5247 * {@link #STATUS_RES_PACKAGE}.</td>
5248 * </tr>
5249 * <tr>
5250 * <td>long</td>
5251 * <td>{@link #STATUS_ICON}</td>
5252 * <td>read/write</td>
5253 * <td>The resource ID of the icon for the source of contact status. This
5254 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
5255 * </tr>
5256 * </table>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005257 */
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005258 public static class StatusUpdates implements StatusColumns, PresenceColumns {
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005259
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005260 /**
5261 * This utility class cannot be instantiated
5262 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005263 private StatusUpdates() {}
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005264
5265 /**
5266 * The content:// style URI for this table
5267 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005268 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005269
5270 /**
Dave Santoro063084e2011-08-23 15:42:49 -07005271 * The content:// style URI for this table, specific to the user's profile.
5272 */
5273 public static final Uri PROFILE_CONTENT_URI =
5274 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates");
5275
5276 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005277 * Gets the resource ID for the proper presence icon.
5278 *
5279 * @param status the status to get the icon for
5280 * @return the resource ID for the proper presence icon
5281 */
5282 public static final int getPresenceIconResourceId(int status) {
5283 switch (status) {
5284 case AVAILABLE:
5285 return android.R.drawable.presence_online;
5286 case IDLE:
5287 case AWAY:
5288 return android.R.drawable.presence_away;
5289 case DO_NOT_DISTURB:
5290 return android.R.drawable.presence_busy;
5291 case INVISIBLE:
5292 return android.R.drawable.presence_invisible;
5293 case OFFLINE:
5294 default:
5295 return android.R.drawable.presence_offline;
5296 }
5297 }
5298
5299 /**
Evan Millarc0437522009-06-23 17:31:05 -07005300 * Returns the precedence of the status code the higher number being the higher precedence.
5301 *
5302 * @param status The status code.
5303 * @return An integer representing the precedence, 0 being the lowest.
5304 */
5305 public static final int getPresencePrecedence(int status) {
5306 // Keep this function here incase we want to enforce a different precedence than the
5307 // natural order of the status constants.
5308 return status;
5309 }
5310
5311 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005312 * The MIME type of {@link #CONTENT_URI} providing a directory of
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005313 * status update details.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005314 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005315 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005316
5317 /**
5318 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005319 * status update detail.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005320 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005321 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
5322 }
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005323
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005324 /**
5325 * @deprecated This old name was never meant to be made public. Do not use.
5326 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005327 @Deprecated
5328 public static final class Presence extends StatusUpdates {
5329
Evan Millar088b2912009-05-28 15:24:37 -07005330 }
5331
5332 /**
Yorke Lee8d370092014-06-26 10:32:17 -07005333 * Additional column returned by
5334 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining
Yorke Leeeaf09492014-07-01 10:28:56 -07005335 * why the filter matched the contact. This column will contain extracts from the contact's
5336 * constituent {@link Data Data} items, formatted in a way that indicates the section of the
5337 * snippet that matched the filter.
5338 *
5339 * <p>
5340 * The following example searches for all contacts that match the query "presi" and requests
5341 * the snippet column as well.
5342 * <pre>
5343 * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
5344 * builder.appendPath("presi");
5345 * // Defer snippeting to the client side if possible, for performance reasons.
5346 * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");
5347 *
5348 * Cursor cursor = getContentResolver().query(builder.build());
5349 *
5350 * Bundle extras = cursor.getExtras();
5351 * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
5352 * // Do our own snippet formatting.
5353 * // For a contact with the email address (president@organization.com), the snippet
5354 * // column will contain the string "president@organization.com".
5355 * } else {
5356 * // The snippet has already been pre-formatted, we can display it as is.
5357 * // For a contact with the email address (president@organization.com), the snippet
5358 * // column will contain the string "[presi]dent@organization.com".
5359 * }
5360 * </pre>
5361 * </p>
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005362 */
Yorke Leeeaf09492014-07-01 10:28:56 -07005363 public static class SearchSnippets {
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005364
5365 /**
Yorke Leeeaf09492014-07-01 10:28:56 -07005366 * The search snippet constructed by SQLite snippeting functionality.
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005367 * <p>
Yorke Leeeaf09492014-07-01 10:28:56 -07005368 * The snippet may contain (parts of) several data elements belonging to the contact,
5369 * with the matching parts optionally surrounded by special characters that indicate the
5370 * start and end of matching text.
5371 *
5372 * For example, if a contact has an address "123 Main Street", using a filter "mai" would
5373 * return the formatted snippet "123 [Mai]n street".
5374 *
5375 * @see <a href="http://www.sqlite.org/fts3.html#snippet">
5376 * http://www.sqlite.org/fts3.html#snippet</a>
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005377 */
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005378 public static final String SNIPPET = "snippet";
5379
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005380 /**
5381 * Comma-separated parameters for the generation of the snippet:
5382 * <ul>
Yorke Leeeaf09492014-07-01 10:28:56 -07005383 * <li>The "start match" text. Default is '['</li>
5384 * <li>The "end match" text. Default is ']'</li>
5385 * <li>The "ellipsis" text. Default is "..."</li>
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005386 * <li>Maximum number of tokens to include in the snippet. Can be either
5387 * a positive or a negative number: A positive number indicates how many
5388 * tokens can be returned in total. A negative number indicates how many
5389 * tokens can be returned per occurrence of the search terms.</li>
5390 * </ul>
Yorke Leeeaf09492014-07-01 10:28:56 -07005391 *
5392 * @hide
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005393 */
5394 public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args";
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005395
5396 /**
Yorke Leeeaf09492014-07-01 10:28:56 -07005397 * The key to ask the provider to defer the formatting of the snippet to the client if
5398 * possible, for performance reasons.
5399 * A value of 1 indicates true, 0 indicates false. False is the default.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005400 * When a cursor is returned to the client, it should check for an extra with the name
5401 * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client
Yorke Leeeaf09492014-07-01 10:28:56 -07005402 * should do its own formatting of the snippet. If it doesn't exist, the snippet column
5403 * in the cursor should already contain a formatted snippet.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005404 */
5405 public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting";
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005406 }
5407
5408 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005409 * Container for definitions of common data types stored in the {@link ContactsContract.Data}
5410 * table.
Evan Millar088b2912009-05-28 15:24:37 -07005411 */
5412 public static final class CommonDataKinds {
5413 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005414 * This utility class cannot be instantiated
5415 */
5416 private CommonDataKinds() {}
5417
5418 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005419 * The {@link Data#RES_PACKAGE} value for common data that should be
5420 * shown using a default style.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005421 *
5422 * @hide RES_PACKAGE is hidden
Evan Millar088b2912009-05-28 15:24:37 -07005423 */
5424 public static final String PACKAGE_COMMON = "common";
5425
5426 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005427 * The base types that all "Typed" data kinds support.
5428 */
5429 public interface BaseTypes {
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005430 /**
5431 * A custom type. The custom label should be supplied by user.
5432 */
5433 public static int TYPE_CUSTOM = 0;
5434 }
5435
5436 /**
Evan Millar088b2912009-05-28 15:24:37 -07005437 * Columns common across the specific types.
5438 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005439 protected interface CommonColumns extends BaseTypes {
Evan Millar088b2912009-05-28 15:24:37 -07005440 /**
Evan Millar088b2912009-05-28 15:24:37 -07005441 * The data for the contact method.
5442 * <P>Type: TEXT</P>
5443 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005444 public static final String DATA = DataColumns.DATA1;
5445
5446 /**
5447 * The type of data, for example Home or Work.
5448 * <P>Type: INTEGER</P>
5449 */
5450 public static final String TYPE = DataColumns.DATA2;
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005451
5452 /**
5453 * The user defined label for the the contact method.
5454 * <P>Type: TEXT</P>
5455 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005456 public static final String LABEL = DataColumns.DATA3;
Evan Millar088b2912009-05-28 15:24:37 -07005457 }
5458
5459 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005460 * A data kind representing the contact's proper name. You can use all
5461 * columns defined for {@link ContactsContract.Data} as well as the following aliases.
5462 *
5463 * <h2>Column aliases</h2>
5464 * <table class="jd-sumtable">
5465 * <tr>
5466 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5467 * </tr>
5468 * <tr>
5469 * <td>String</td>
5470 * <td>{@link #DISPLAY_NAME}</td>
5471 * <td>{@link #DATA1}</td>
5472 * <td></td>
5473 * </tr>
5474 * <tr>
5475 * <td>String</td>
5476 * <td>{@link #GIVEN_NAME}</td>
5477 * <td>{@link #DATA2}</td>
5478 * <td></td>
5479 * </tr>
5480 * <tr>
5481 * <td>String</td>
5482 * <td>{@link #FAMILY_NAME}</td>
5483 * <td>{@link #DATA3}</td>
5484 * <td></td>
5485 * </tr>
5486 * <tr>
5487 * <td>String</td>
5488 * <td>{@link #PREFIX}</td>
5489 * <td>{@link #DATA4}</td>
5490 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
5491 * </tr>
5492 * <tr>
5493 * <td>String</td>
5494 * <td>{@link #MIDDLE_NAME}</td>
5495 * <td>{@link #DATA5}</td>
5496 * <td></td>
5497 * </tr>
5498 * <tr>
5499 * <td>String</td>
5500 * <td>{@link #SUFFIX}</td>
5501 * <td>{@link #DATA6}</td>
5502 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
5503 * </tr>
5504 * <tr>
5505 * <td>String</td>
5506 * <td>{@link #PHONETIC_GIVEN_NAME}</td>
5507 * <td>{@link #DATA7}</td>
5508 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
5509 * </tr>
5510 * <tr>
5511 * <td>String</td>
5512 * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
5513 * <td>{@link #DATA8}</td>
5514 * <td></td>
5515 * </tr>
5516 * <tr>
5517 * <td>String</td>
5518 * <td>{@link #PHONETIC_FAMILY_NAME}</td>
5519 * <td>{@link #DATA9}</td>
5520 * <td></td>
5521 * </tr>
5522 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005523 */
Yorke Lee94c87612014-07-18 18:57:17 -07005524 public static final class StructuredName implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005525 /**
5526 * This utility class cannot be instantiated
5527 */
Evan Millar088b2912009-05-28 15:24:37 -07005528 private StructuredName() {}
5529
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005530 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005531 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
5532
5533 /**
Evan Millar088b2912009-05-28 15:24:37 -07005534 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -07005535 * <i>Unstructured component of the name should be consistent with
5536 * its structured representation.</i>
5537 * <p>
5538 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -07005539 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005540 public static final String DISPLAY_NAME = DATA1;
5541
5542 /**
5543 * The given name for the contact.
5544 * <P>Type: TEXT</P>
5545 */
5546 public static final String GIVEN_NAME = DATA2;
5547
5548 /**
5549 * The family name for the contact.
5550 * <P>Type: TEXT</P>
5551 */
5552 public static final String FAMILY_NAME = DATA3;
5553
5554 /**
5555 * The contact's honorific prefix, e.g. "Sir"
5556 * <P>Type: TEXT</P>
5557 */
5558 public static final String PREFIX = DATA4;
5559
5560 /**
5561 * The contact's middle name
5562 * <P>Type: TEXT</P>
5563 */
5564 public static final String MIDDLE_NAME = DATA5;
5565
5566 /**
5567 * The contact's honorific suffix, e.g. "Jr"
5568 */
5569 public static final String SUFFIX = DATA6;
5570
5571 /**
5572 * The phonetic version of the given name for the contact.
5573 * <P>Type: TEXT</P>
5574 */
5575 public static final String PHONETIC_GIVEN_NAME = DATA7;
5576
5577 /**
5578 * The phonetic version of the additional name for the contact.
5579 * <P>Type: TEXT</P>
5580 */
5581 public static final String PHONETIC_MIDDLE_NAME = DATA8;
5582
5583 /**
5584 * The phonetic version of the family name for the contact.
5585 * <P>Type: TEXT</P>
5586 */
5587 public static final String PHONETIC_FAMILY_NAME = DATA9;
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005588
5589 /**
5590 * The style used for combining given/middle/family name into a full name.
5591 * See {@link ContactsContract.FullNameStyle}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005592 */
5593 public static final String FULL_NAME_STYLE = DATA10;
5594
5595 /**
5596 * The alphabet used for capturing the phonetic name.
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08005597 * See ContactsContract.PhoneticNameStyle.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005598 * @hide
5599 */
5600 public static final String PHONETIC_NAME_STYLE = DATA11;
Evan Millar088b2912009-05-28 15:24:37 -07005601 }
5602
5603 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005604 * <p>A data kind representing the contact's nickname. For example, for
5605 * Bob Parr ("Mr. Incredible"):
5606 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07005607 * ArrayList&lt;ContentProviderOperation&gt; ops =
5608 * new ArrayList&lt;ContentProviderOperation&gt;();
5609 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005610 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5611 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
5612 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
5613 * .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
5614 * .build());
5615 *
5616 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5617 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
5618 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
5619 * .withValue(Nickname.NAME, "Mr. Incredible")
5620 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
5621 * .withValue(Nickname.LABEL, "Superhero")
5622 * .build());
5623 *
5624 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
5625 * </pre>
5626 * </p>
5627 * <p>
5628 * You can use all columns defined for {@link ContactsContract.Data} as well as the
5629 * following aliases.
5630 * </p>
5631 *
5632 * <h2>Column aliases</h2>
5633 * <table class="jd-sumtable">
5634 * <tr>
5635 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5636 * </tr>
5637 * <tr>
5638 * <td>String</td>
5639 * <td>{@link #NAME}</td>
5640 * <td>{@link #DATA1}</td>
5641 * <td></td>
5642 * </tr>
5643 * <tr>
5644 * <td>int</td>
5645 * <td>{@link #TYPE}</td>
5646 * <td>{@link #DATA2}</td>
5647 * <td>
5648 * Allowed values are:
5649 * <p>
5650 * <ul>
5651 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5652 * <li>{@link #TYPE_DEFAULT}</li>
5653 * <li>{@link #TYPE_OTHER_NAME}</li>
David Brown747c6152010-09-15 13:34:13 -07005654 * <li>{@link #TYPE_MAIDEN_NAME}</li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005655 * <li>{@link #TYPE_SHORT_NAME}</li>
5656 * <li>{@link #TYPE_INITIALS}</li>
5657 * </ul>
5658 * </p>
5659 * </td>
5660 * </tr>
5661 * <tr>
5662 * <td>String</td>
5663 * <td>{@link #LABEL}</td>
5664 * <td>{@link #DATA3}</td>
5665 * <td></td>
5666 * </tr>
5667 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005668 */
Yorke Lee94c87612014-07-18 18:57:17 -07005669 public static final class Nickname implements DataColumnsWithJoins, CommonColumns,
5670 ContactCounts{
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005671 /**
5672 * This utility class cannot be instantiated
5673 */
Evan Millar088b2912009-05-28 15:24:37 -07005674 private Nickname() {}
5675
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005676 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005677 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
5678
Evan Millar78e79ad2009-06-08 10:24:44 -07005679 public static final int TYPE_DEFAULT = 1;
5680 public static final int TYPE_OTHER_NAME = 2;
David Brown747c6152010-09-15 13:34:13 -07005681 public static final int TYPE_MAIDEN_NAME = 3;
5682 /** @deprecated Use TYPE_MAIDEN_NAME instead. */
5683 @Deprecated
Evan Millar78e79ad2009-06-08 10:24:44 -07005684 public static final int TYPE_MAINDEN_NAME = 3;
5685 public static final int TYPE_SHORT_NAME = 4;
5686 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -07005687
5688 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005689 * The name itself
5690 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005691 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07005692 }
5693
5694 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005695 * <p>
5696 * A data kind representing a telephone number.
5697 * </p>
5698 * <p>
5699 * You can use all columns defined for {@link ContactsContract.Data} as
5700 * well as the following aliases.
5701 * </p>
5702 * <h2>Column aliases</h2>
5703 * <table class="jd-sumtable">
5704 * <tr>
5705 * <th>Type</th>
5706 * <th>Alias</th><th colspan='2'>Data column</th>
5707 * </tr>
5708 * <tr>
5709 * <td>String</td>
5710 * <td>{@link #NUMBER}</td>
5711 * <td>{@link #DATA1}</td>
5712 * <td></td>
5713 * </tr>
5714 * <tr>
5715 * <td>int</td>
5716 * <td>{@link #TYPE}</td>
5717 * <td>{@link #DATA2}</td>
5718 * <td>Allowed values are:
5719 * <p>
5720 * <ul>
5721 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5722 * <li>{@link #TYPE_HOME}</li>
5723 * <li>{@link #TYPE_MOBILE}</li>
5724 * <li>{@link #TYPE_WORK}</li>
5725 * <li>{@link #TYPE_FAX_WORK}</li>
5726 * <li>{@link #TYPE_FAX_HOME}</li>
5727 * <li>{@link #TYPE_PAGER}</li>
5728 * <li>{@link #TYPE_OTHER}</li>
5729 * <li>{@link #TYPE_CALLBACK}</li>
5730 * <li>{@link #TYPE_CAR}</li>
5731 * <li>{@link #TYPE_COMPANY_MAIN}</li>
5732 * <li>{@link #TYPE_ISDN}</li>
5733 * <li>{@link #TYPE_MAIN}</li>
5734 * <li>{@link #TYPE_OTHER_FAX}</li>
5735 * <li>{@link #TYPE_RADIO}</li>
5736 * <li>{@link #TYPE_TELEX}</li>
5737 * <li>{@link #TYPE_TTY_TDD}</li>
5738 * <li>{@link #TYPE_WORK_MOBILE}</li>
5739 * <li>{@link #TYPE_WORK_PAGER}</li>
5740 * <li>{@link #TYPE_ASSISTANT}</li>
5741 * <li>{@link #TYPE_MMS}</li>
5742 * </ul>
5743 * </p>
5744 * </td>
5745 * </tr>
5746 * <tr>
5747 * <td>String</td>
5748 * <td>{@link #LABEL}</td>
5749 * <td>{@link #DATA3}</td>
5750 * <td></td>
5751 * </tr>
5752 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005753 */
Yorke Lee94c87612014-07-18 18:57:17 -07005754 public static final class Phone implements DataColumnsWithJoins, CommonColumns,
5755 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005756 /**
5757 * This utility class cannot be instantiated
5758 */
Evan Millar088b2912009-05-28 15:24:37 -07005759 private Phone() {}
5760
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005761 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07005762 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
Evan Millar088b2912009-05-28 15:24:37 -07005763
Evan Millar161dd862009-06-12 16:02:43 -07005764 /**
5765 * The MIME type of {@link #CONTENT_URI} providing a directory of
5766 * phones.
5767 */
Evan Millarb3c49982009-09-01 11:38:04 -07005768 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
Evan Millar161dd862009-06-12 16:02:43 -07005769
5770 /**
5771 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005772 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07005773 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -07005774 */
5775 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
5776 "phones");
5777
5778 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005779 * The content:// style URL for phone lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005780 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005781 * to display names as well as phone numbers. The filter argument should be passed
5782 * as an additional path segment after this URI.
Evan Millar161dd862009-06-12 16:02:43 -07005783 */
5784 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
5785 "filter");
5786
Daniel Lehmann1024de52012-06-15 20:32:33 -07005787 /**
5788 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
5789 * If "1" or "true", display names are searched. If "0" or "false", display names
5790 * are not searched. Default is "1".
5791 */
5792 public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name";
5793
5794 /**
5795 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
5796 * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers
5797 * are not searched. Default is "1".
5798 */
5799 public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number";
5800
Evan Millar088b2912009-05-28 15:24:37 -07005801 public static final int TYPE_HOME = 1;
5802 public static final int TYPE_MOBILE = 2;
5803 public static final int TYPE_WORK = 3;
5804 public static final int TYPE_FAX_WORK = 4;
5805 public static final int TYPE_FAX_HOME = 5;
5806 public static final int TYPE_PAGER = 6;
5807 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -07005808 public static final int TYPE_CALLBACK = 8;
5809 public static final int TYPE_CAR = 9;
5810 public static final int TYPE_COMPANY_MAIN = 10;
5811 public static final int TYPE_ISDN = 11;
5812 public static final int TYPE_MAIN = 12;
5813 public static final int TYPE_OTHER_FAX = 13;
5814 public static final int TYPE_RADIO = 14;
5815 public static final int TYPE_TELEX = 15;
5816 public static final int TYPE_TTY_TDD = 16;
5817 public static final int TYPE_WORK_MOBILE = 17;
5818 public static final int TYPE_WORK_PAGER = 18;
5819 public static final int TYPE_ASSISTANT = 19;
Jeff Sharkeyd5abd462009-09-16 19:54:29 -07005820 public static final int TYPE_MMS = 20;
Evan Millar088b2912009-05-28 15:24:37 -07005821
5822 /**
5823 * The phone number as the user entered it.
5824 * <P>Type: TEXT</P>
5825 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005826 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005827
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005828 /**
Daniel Lehmanndb919152012-03-09 14:30:50 -08005829 * The phone number's E164 representation. This value can be omitted in which
Makoto Onukie5420e92012-04-25 13:24:41 -07005830 * case the provider will try to automatically infer it. (It'll be left null if the
5831 * provider fails to infer.)
5832 * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise).
Bai Tao224744c2010-08-31 09:59:13 +08005833 * <P>Type: TEXT</P>
Bai Tao224744c2010-08-31 09:59:13 +08005834 */
5835 public static final String NORMALIZED_NUMBER = DATA4;
5836
5837 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005838 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005839 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005840 */
5841 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005842 public static final CharSequence getDisplayLabel(Context context, int type,
5843 CharSequence label, CharSequence[] labelArray) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005844 return getTypeLabel(context.getResources(), type, label);
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005845 }
5846
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005847 /**
5848 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005849 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005850 */
5851 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005852 public static final CharSequence getDisplayLabel(Context context, int type,
5853 CharSequence label) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005854 return getTypeLabel(context.getResources(), type, label);
5855 }
5856
5857 /**
5858 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005859 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005860 */
5861 public static final int getTypeLabelResource(int type) {
5862 switch (type) {
5863 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
5864 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
5865 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
5866 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
5867 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
5868 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
5869 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
5870 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
5871 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
5872 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
5873 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
5874 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
5875 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
5876 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
5877 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
5878 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
5879 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
5880 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
5881 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
5882 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
5883 default: return com.android.internal.R.string.phoneTypeCustom;
5884 }
5885 }
5886
5887 /**
5888 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005889 * possibly substituting the given {@link #LABEL} value
5890 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005891 */
5892 public static final CharSequence getTypeLabel(Resources res, int type,
5893 CharSequence label) {
5894 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
5895 return label;
5896 } else {
5897 final int labelRes = getTypeLabelResource(type);
5898 return res.getText(labelRes);
5899 }
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005900 }
Evan Millar088b2912009-05-28 15:24:37 -07005901 }
5902
5903 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005904 * <p>
5905 * A data kind representing an email address.
5906 * </p>
5907 * <p>
5908 * You can use all columns defined for {@link ContactsContract.Data} as
5909 * well as the following aliases.
5910 * </p>
5911 * <h2>Column aliases</h2>
5912 * <table class="jd-sumtable">
5913 * <tr>
5914 * <th>Type</th>
5915 * <th>Alias</th><th colspan='2'>Data column</th>
5916 * </tr>
5917 * <tr>
5918 * <td>String</td>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07005919 * <td>{@link #ADDRESS}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005920 * <td>{@link #DATA1}</td>
5921 * <td>Email address itself.</td>
5922 * </tr>
5923 * <tr>
5924 * <td>int</td>
5925 * <td>{@link #TYPE}</td>
5926 * <td>{@link #DATA2}</td>
5927 * <td>Allowed values are:
5928 * <p>
5929 * <ul>
5930 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5931 * <li>{@link #TYPE_HOME}</li>
5932 * <li>{@link #TYPE_WORK}</li>
5933 * <li>{@link #TYPE_OTHER}</li>
5934 * <li>{@link #TYPE_MOBILE}</li>
5935 * </ul>
5936 * </p>
5937 * </td>
5938 * </tr>
5939 * <tr>
5940 * <td>String</td>
5941 * <td>{@link #LABEL}</td>
5942 * <td>{@link #DATA3}</td>
5943 * <td></td>
5944 * </tr>
5945 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005946 */
Yorke Lee94c87612014-07-18 18:57:17 -07005947 public static final class Email implements DataColumnsWithJoins, CommonColumns,
5948 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005949 /**
5950 * This utility class cannot be instantiated
5951 */
Evan Millar088b2912009-05-28 15:24:37 -07005952 private Email() {}
5953
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005954 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07005955 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
Evan Millar088b2912009-05-28 15:24:37 -07005956
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005957 /**
Dmitri Plotnikovabf15c32009-09-18 20:29:11 -07005958 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
5959 */
5960 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
5961
5962 /**
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005963 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005964 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005965 * associated raw contact and aggregate contact data.
5966 */
5967 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
5968 "emails");
5969
5970 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005971 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005972 * The content:// style URL for looking up data rows by email address. The
5973 * lookup argument, an email address, should be passed as an additional path segment
5974 * after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005975 * </p>
5976 * <p>Example:
5977 * <pre>
5978 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
5979 * Cursor c = getContentResolver().query(uri,
5980 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
5981 * null, null, null);
5982 * </pre>
5983 * </p>
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005984 */
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005985 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
5986 "lookup");
5987
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005988 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005989 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005990 * The content:// style URL for email lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005991 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005992 * to display names as well as email addresses. The filter argument should be passed
5993 * as an additional path segment after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005994 * </p>
5995 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)"
5996 * as well as "Bob Parr (incredible@android.com)".
5997 * <pre>
5998 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
5999 * Cursor c = getContentResolver().query(uri,
6000 * new String[]{Email.DISPLAY_NAME, Email.DATA},
6001 * null, null, null);
6002 * </pre>
6003 * </p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07006004 */
6005 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006006 "filter");
6007
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006008 /**
6009 * The email address.
6010 * <P>Type: TEXT</P>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006011 */
6012 public static final String ADDRESS = DATA1;
6013
Evan Millar088b2912009-05-28 15:24:37 -07006014 public static final int TYPE_HOME = 1;
6015 public static final int TYPE_WORK = 2;
6016 public static final int TYPE_OTHER = 3;
Jeff Sharkey14fb1532009-08-29 15:54:26 -07006017 public static final int TYPE_MOBILE = 4;
Fred Quintana8851e162009-08-05 21:06:45 -07006018
6019 /**
6020 * The display name for the email address
6021 * <P>Type: TEXT</P>
6022 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006023 public static final String DISPLAY_NAME = DATA4;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006024
6025 /**
6026 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006027 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006028 */
6029 public static final int getTypeLabelResource(int type) {
6030 switch (type) {
6031 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
6032 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
6033 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
6034 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
6035 default: return com.android.internal.R.string.emailTypeCustom;
6036 }
6037 }
6038
6039 /**
6040 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006041 * possibly substituting the given {@link #LABEL} value
6042 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006043 */
6044 public static final CharSequence getTypeLabel(Resources res, int type,
6045 CharSequence label) {
6046 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6047 return label;
6048 } else {
6049 final int labelRes = getTypeLabelResource(type);
6050 return res.getText(labelRes);
6051 }
6052 }
Evan Millar088b2912009-05-28 15:24:37 -07006053 }
6054
6055 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006056 * <p>
6057 * A data kind representing a postal addresses.
6058 * </p>
6059 * <p>
6060 * You can use all columns defined for {@link ContactsContract.Data} as
6061 * well as the following aliases.
6062 * </p>
6063 * <h2>Column aliases</h2>
6064 * <table class="jd-sumtable">
6065 * <tr>
6066 * <th>Type</th>
6067 * <th>Alias</th><th colspan='2'>Data column</th>
6068 * </tr>
6069 * <tr>
6070 * <td>String</td>
6071 * <td>{@link #FORMATTED_ADDRESS}</td>
6072 * <td>{@link #DATA1}</td>
6073 * <td></td>
6074 * </tr>
6075 * <tr>
6076 * <td>int</td>
6077 * <td>{@link #TYPE}</td>
6078 * <td>{@link #DATA2}</td>
6079 * <td>Allowed values are:
6080 * <p>
6081 * <ul>
6082 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6083 * <li>{@link #TYPE_HOME}</li>
6084 * <li>{@link #TYPE_WORK}</li>
6085 * <li>{@link #TYPE_OTHER}</li>
6086 * </ul>
6087 * </p>
6088 * </td>
6089 * </tr>
6090 * <tr>
6091 * <td>String</td>
6092 * <td>{@link #LABEL}</td>
6093 * <td>{@link #DATA3}</td>
6094 * <td></td>
6095 * </tr>
6096 * <tr>
6097 * <td>String</td>
6098 * <td>{@link #STREET}</td>
6099 * <td>{@link #DATA4}</td>
6100 * <td></td>
6101 * </tr>
6102 * <tr>
6103 * <td>String</td>
6104 * <td>{@link #POBOX}</td>
6105 * <td>{@link #DATA5}</td>
6106 * <td>Post Office Box number</td>
6107 * </tr>
6108 * <tr>
6109 * <td>String</td>
6110 * <td>{@link #NEIGHBORHOOD}</td>
6111 * <td>{@link #DATA6}</td>
6112 * <td></td>
6113 * </tr>
6114 * <tr>
6115 * <td>String</td>
6116 * <td>{@link #CITY}</td>
6117 * <td>{@link #DATA7}</td>
6118 * <td></td>
6119 * </tr>
6120 * <tr>
6121 * <td>String</td>
6122 * <td>{@link #REGION}</td>
6123 * <td>{@link #DATA8}</td>
6124 * <td></td>
6125 * </tr>
6126 * <tr>
6127 * <td>String</td>
6128 * <td>{@link #POSTCODE}</td>
6129 * <td>{@link #DATA9}</td>
6130 * <td></td>
6131 * </tr>
6132 * <tr>
6133 * <td>String</td>
6134 * <td>{@link #COUNTRY}</td>
6135 * <td>{@link #DATA10}</td>
6136 * <td></td>
6137 * </tr>
6138 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006139 */
Yorke Lee94c87612014-07-18 18:57:17 -07006140 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns,
6141 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006142 /**
6143 * This utility class cannot be instantiated
6144 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006145 private StructuredPostal() {
6146 }
Evan Millar088b2912009-05-28 15:24:37 -07006147
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006148 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07006149 public static final String CONTENT_ITEM_TYPE =
6150 "vnd.android.cursor.item/postal-address_v2";
Evan Millar088b2912009-05-28 15:24:37 -07006151
Evan Millar161dd862009-06-12 16:02:43 -07006152 /**
6153 * The MIME type of {@link #CONTENT_URI} providing a directory of
6154 * postal addresses.
6155 */
Evan Millarb3c49982009-09-01 11:38:04 -07006156 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
Evan Millar161dd862009-06-12 16:02:43 -07006157
6158 /**
6159 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006160 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07006161 */
6162 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6163 "postals");
6164
Evan Millar088b2912009-05-28 15:24:37 -07006165 public static final int TYPE_HOME = 1;
6166 public static final int TYPE_WORK = 2;
6167 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006168
6169 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07006170 * The full, unstructured postal address. <i>This field must be
6171 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006172 * <p>
6173 * Type: TEXT
6174 */
6175 public static final String FORMATTED_ADDRESS = DATA;
6176
6177 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006178 * Can be street, avenue, road, etc. This element also includes the
6179 * house number and room/apartment/flat/floor number.
6180 * <p>
6181 * Type: TEXT
6182 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006183 public static final String STREET = DATA4;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006184
6185 /**
6186 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
6187 * usually but not always mutually exclusive with street.
6188 * <p>
6189 * Type: TEXT
6190 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006191 public static final String POBOX = DATA5;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006192
6193 /**
6194 * This is used to disambiguate a street address when a city
6195 * contains more than one street with the same name, or to specify a
6196 * small place whose mail is routed through a larger postal town. In
6197 * China it could be a county or a minor city.
6198 * <p>
6199 * Type: TEXT
6200 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006201 public static final String NEIGHBORHOOD = DATA6;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006202
6203 /**
6204 * Can be city, village, town, borough, etc. This is the postal town
6205 * and not necessarily the place of residence or place of business.
6206 * <p>
6207 * Type: TEXT
6208 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006209 public static final String CITY = DATA7;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006210
6211 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006212 * A state, province, county (in Ireland), Land (in Germany),
6213 * departement (in France), etc.
6214 * <p>
6215 * Type: TEXT
6216 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006217 public static final String REGION = DATA8;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006218
6219 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07006220 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006221 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
6222 * <p>
6223 * Type: TEXT
6224 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006225 public static final String POSTCODE = DATA9;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006226
6227 /**
6228 * The name or code of the country.
6229 * <p>
6230 * Type: TEXT
6231 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006232 public static final String COUNTRY = DATA10;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006233
6234 /**
6235 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006236 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006237 */
6238 public static final int getTypeLabelResource(int type) {
6239 switch (type) {
6240 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
6241 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
6242 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
6243 default: return com.android.internal.R.string.postalTypeCustom;
6244 }
6245 }
6246
6247 /**
6248 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006249 * possibly substituting the given {@link #LABEL} value
6250 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006251 */
6252 public static final CharSequence getTypeLabel(Resources res, int type,
6253 CharSequence label) {
6254 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6255 return label;
6256 } else {
6257 final int labelRes = getTypeLabelResource(type);
6258 return res.getText(labelRes);
6259 }
6260 }
Evan Millar088b2912009-05-28 15:24:37 -07006261 }
6262
Fred Quintana8851e162009-08-05 21:06:45 -07006263 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006264 * <p>
6265 * A data kind representing an IM address
6266 * </p>
6267 * <p>
6268 * You can use all columns defined for {@link ContactsContract.Data} as
6269 * well as the following aliases.
6270 * </p>
6271 * <h2>Column aliases</h2>
6272 * <table class="jd-sumtable">
6273 * <tr>
6274 * <th>Type</th>
6275 * <th>Alias</th><th colspan='2'>Data column</th>
6276 * </tr>
6277 * <tr>
6278 * <td>String</td>
6279 * <td>{@link #DATA}</td>
6280 * <td>{@link #DATA1}</td>
6281 * <td></td>
6282 * </tr>
6283 * <tr>
6284 * <td>int</td>
6285 * <td>{@link #TYPE}</td>
6286 * <td>{@link #DATA2}</td>
6287 * <td>Allowed values are:
6288 * <p>
6289 * <ul>
6290 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6291 * <li>{@link #TYPE_HOME}</li>
6292 * <li>{@link #TYPE_WORK}</li>
6293 * <li>{@link #TYPE_OTHER}</li>
6294 * </ul>
6295 * </p>
6296 * </td>
6297 * </tr>
6298 * <tr>
6299 * <td>String</td>
6300 * <td>{@link #LABEL}</td>
6301 * <td>{@link #DATA3}</td>
6302 * <td></td>
6303 * </tr>
6304 * <tr>
6305 * <td>String</td>
6306 * <td>{@link #PROTOCOL}</td>
6307 * <td>{@link #DATA5}</td>
6308 * <td>
6309 * <p>
6310 * Allowed values:
6311 * <ul>
6312 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
6313 * as {@link #CUSTOM_PROTOCOL}.</li>
6314 * <li>{@link #PROTOCOL_AIM}</li>
6315 * <li>{@link #PROTOCOL_MSN}</li>
6316 * <li>{@link #PROTOCOL_YAHOO}</li>
6317 * <li>{@link #PROTOCOL_SKYPE}</li>
6318 * <li>{@link #PROTOCOL_QQ}</li>
6319 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
6320 * <li>{@link #PROTOCOL_ICQ}</li>
6321 * <li>{@link #PROTOCOL_JABBER}</li>
6322 * <li>{@link #PROTOCOL_NETMEETING}</li>
6323 * </ul>
6324 * </p>
6325 * </td>
6326 * </tr>
6327 * <tr>
6328 * <td>String</td>
6329 * <td>{@link #CUSTOM_PROTOCOL}</td>
6330 * <td>{@link #DATA6}</td>
6331 * <td></td>
6332 * </tr>
6333 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006334 */
Yorke Lee94c87612014-07-18 18:57:17 -07006335 public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006336 /**
6337 * This utility class cannot be instantiated
6338 */
Evan Millar088b2912009-05-28 15:24:37 -07006339 private Im() {}
6340
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006341 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006342 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
6343
Evan Millar088b2912009-05-28 15:24:37 -07006344 public static final int TYPE_HOME = 1;
6345 public static final int TYPE_WORK = 2;
6346 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006347
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07006348 /**
6349 * This column should be populated with one of the defined
6350 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
6351 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
6352 * should contain the name of the custom protocol.
6353 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006354 public static final String PROTOCOL = DATA5;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006355
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006356 public static final String CUSTOM_PROTOCOL = DATA6;
Jeff Sharkey732da922009-07-30 09:59:31 -07006357
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07006358 /*
6359 * The predefined IM protocol types.
Evan Millar088b2912009-05-28 15:24:37 -07006360 */
Jeff Sharkey732da922009-07-30 09:59:31 -07006361 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07006362 public static final int PROTOCOL_AIM = 0;
6363 public static final int PROTOCOL_MSN = 1;
6364 public static final int PROTOCOL_YAHOO = 2;
6365 public static final int PROTOCOL_SKYPE = 3;
6366 public static final int PROTOCOL_QQ = 4;
6367 public static final int PROTOCOL_GOOGLE_TALK = 5;
6368 public static final int PROTOCOL_ICQ = 6;
6369 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07006370 public static final int PROTOCOL_NETMEETING = 8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006371
6372 /**
6373 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006374 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006375 */
6376 public static final int getTypeLabelResource(int type) {
6377 switch (type) {
6378 case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
6379 case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
6380 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
6381 default: return com.android.internal.R.string.imTypeCustom;
6382 }
6383 }
6384
6385 /**
6386 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006387 * possibly substituting the given {@link #LABEL} value
6388 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006389 */
6390 public static final CharSequence getTypeLabel(Resources res, int type,
6391 CharSequence label) {
6392 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6393 return label;
6394 } else {
6395 final int labelRes = getTypeLabelResource(type);
6396 return res.getText(labelRes);
6397 }
6398 }
6399
6400 /**
6401 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006402 * {@link #PROTOCOL}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006403 */
6404 public static final int getProtocolLabelResource(int type) {
6405 switch (type) {
6406 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
6407 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
6408 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
6409 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
6410 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
6411 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
6412 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
6413 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
6414 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
6415 default: return com.android.internal.R.string.imProtocolCustom;
6416 }
6417 }
6418
6419 /**
6420 * Return a {@link CharSequence} that best describes the given
6421 * protocol, possibly substituting the given
6422 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
6423 */
6424 public static final CharSequence getProtocolLabel(Resources res, int type,
6425 CharSequence label) {
6426 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
6427 return label;
6428 } else {
6429 final int labelRes = getProtocolLabelResource(type);
6430 return res.getText(labelRes);
6431 }
6432 }
Evan Millar088b2912009-05-28 15:24:37 -07006433 }
6434
6435 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006436 * <p>
6437 * A data kind representing an organization.
6438 * </p>
6439 * <p>
6440 * You can use all columns defined for {@link ContactsContract.Data} as
6441 * well as the following aliases.
6442 * </p>
6443 * <h2>Column aliases</h2>
6444 * <table class="jd-sumtable">
6445 * <tr>
6446 * <th>Type</th>
6447 * <th>Alias</th><th colspan='2'>Data column</th>
6448 * </tr>
6449 * <tr>
6450 * <td>String</td>
6451 * <td>{@link #COMPANY}</td>
6452 * <td>{@link #DATA1}</td>
6453 * <td></td>
6454 * </tr>
6455 * <tr>
6456 * <td>int</td>
6457 * <td>{@link #TYPE}</td>
6458 * <td>{@link #DATA2}</td>
6459 * <td>Allowed values are:
6460 * <p>
6461 * <ul>
6462 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6463 * <li>{@link #TYPE_WORK}</li>
6464 * <li>{@link #TYPE_OTHER}</li>
6465 * </ul>
6466 * </p>
6467 * </td>
6468 * </tr>
6469 * <tr>
6470 * <td>String</td>
6471 * <td>{@link #LABEL}</td>
6472 * <td>{@link #DATA3}</td>
6473 * <td></td>
6474 * </tr>
6475 * <tr>
6476 * <td>String</td>
6477 * <td>{@link #TITLE}</td>
6478 * <td>{@link #DATA4}</td>
6479 * <td></td>
6480 * </tr>
6481 * <tr>
6482 * <td>String</td>
6483 * <td>{@link #DEPARTMENT}</td>
6484 * <td>{@link #DATA5}</td>
6485 * <td></td>
6486 * </tr>
6487 * <tr>
6488 * <td>String</td>
6489 * <td>{@link #JOB_DESCRIPTION}</td>
6490 * <td>{@link #DATA6}</td>
6491 * <td></td>
6492 * </tr>
6493 * <tr>
6494 * <td>String</td>
6495 * <td>{@link #SYMBOL}</td>
6496 * <td>{@link #DATA7}</td>
6497 * <td></td>
6498 * </tr>
6499 * <tr>
6500 * <td>String</td>
6501 * <td>{@link #PHONETIC_NAME}</td>
6502 * <td>{@link #DATA8}</td>
6503 * <td></td>
6504 * </tr>
6505 * <tr>
6506 * <td>String</td>
6507 * <td>{@link #OFFICE_LOCATION}</td>
6508 * <td>{@link #DATA9}</td>
6509 * <td></td>
6510 * </tr>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006511 * <tr>
6512 * <td>String</td>
6513 * <td>PHONETIC_NAME_STYLE</td>
6514 * <td>{@link #DATA10}</td>
6515 * <td></td>
6516 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006517 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006518 */
Yorke Lee94c87612014-07-18 18:57:17 -07006519 public static final class Organization implements DataColumnsWithJoins, CommonColumns,
6520 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006521 /**
6522 * This utility class cannot be instantiated
6523 */
Evan Millar088b2912009-05-28 15:24:37 -07006524 private Organization() {}
6525
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006526 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006527 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
6528
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006529 public static final int TYPE_WORK = 1;
6530 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07006531
6532 /**
6533 * The company as the user entered it.
6534 * <P>Type: TEXT</P>
6535 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006536 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07006537
6538 /**
6539 * The position title at this company as the user entered it.
6540 * <P>Type: TEXT</P>
6541 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006542 public static final String TITLE = DATA4;
Fred Quintana8851e162009-08-05 21:06:45 -07006543
6544 /**
6545 * The department at this company as the user entered it.
6546 * <P>Type: TEXT</P>
6547 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006548 public static final String DEPARTMENT = DATA5;
Fred Quintana8851e162009-08-05 21:06:45 -07006549
6550 /**
6551 * The job description at this company as the user entered it.
6552 * <P>Type: TEXT</P>
6553 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006554 public static final String JOB_DESCRIPTION = DATA6;
Fred Quintana8851e162009-08-05 21:06:45 -07006555
6556 /**
6557 * The symbol of this company as the user entered it.
6558 * <P>Type: TEXT</P>
6559 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006560 public static final String SYMBOL = DATA7;
Fred Quintana8851e162009-08-05 21:06:45 -07006561
6562 /**
6563 * The phonetic name of this company as the user entered it.
6564 * <P>Type: TEXT</P>
6565 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006566 public static final String PHONETIC_NAME = DATA8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006567
6568 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07006569 * The office location of this organization.
6570 * <P>Type: TEXT</P>
6571 */
6572 public static final String OFFICE_LOCATION = DATA9;
6573
6574 /**
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006575 * The alphabet used for capturing the phonetic name.
6576 * See {@link ContactsContract.PhoneticNameStyle}.
6577 * @hide
6578 */
6579 public static final String PHONETIC_NAME_STYLE = DATA10;
6580
6581 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006582 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006583 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006584 */
6585 public static final int getTypeLabelResource(int type) {
6586 switch (type) {
6587 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
6588 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
6589 default: return com.android.internal.R.string.orgTypeCustom;
6590 }
6591 }
6592
6593 /**
6594 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006595 * possibly substituting the given {@link #LABEL} value
6596 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006597 */
6598 public static final CharSequence getTypeLabel(Resources res, int type,
6599 CharSequence label) {
6600 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6601 return label;
6602 } else {
6603 final int labelRes = getTypeLabelResource(type);
6604 return res.getText(labelRes);
6605 }
6606 }
Fred Quintana8851e162009-08-05 21:06:45 -07006607 }
6608
6609 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006610 * <p>
6611 * A data kind representing a relation.
6612 * </p>
6613 * <p>
6614 * You can use all columns defined for {@link ContactsContract.Data} as
6615 * well as the following aliases.
6616 * </p>
6617 * <h2>Column aliases</h2>
6618 * <table class="jd-sumtable">
6619 * <tr>
6620 * <th>Type</th>
6621 * <th>Alias</th><th colspan='2'>Data column</th>
6622 * </tr>
6623 * <tr>
6624 * <td>String</td>
6625 * <td>{@link #NAME}</td>
6626 * <td>{@link #DATA1}</td>
6627 * <td></td>
6628 * </tr>
6629 * <tr>
6630 * <td>int</td>
6631 * <td>{@link #TYPE}</td>
6632 * <td>{@link #DATA2}</td>
6633 * <td>Allowed values are:
6634 * <p>
6635 * <ul>
6636 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6637 * <li>{@link #TYPE_ASSISTANT}</li>
6638 * <li>{@link #TYPE_BROTHER}</li>
6639 * <li>{@link #TYPE_CHILD}</li>
6640 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
6641 * <li>{@link #TYPE_FATHER}</li>
6642 * <li>{@link #TYPE_FRIEND}</li>
6643 * <li>{@link #TYPE_MANAGER}</li>
6644 * <li>{@link #TYPE_MOTHER}</li>
6645 * <li>{@link #TYPE_PARENT}</li>
6646 * <li>{@link #TYPE_PARTNER}</li>
6647 * <li>{@link #TYPE_REFERRED_BY}</li>
6648 * <li>{@link #TYPE_RELATIVE}</li>
6649 * <li>{@link #TYPE_SISTER}</li>
6650 * <li>{@link #TYPE_SPOUSE}</li>
6651 * </ul>
6652 * </p>
6653 * </td>
6654 * </tr>
6655 * <tr>
6656 * <td>String</td>
6657 * <td>{@link #LABEL}</td>
6658 * <td>{@link #DATA3}</td>
6659 * <td></td>
6660 * </tr>
6661 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006662 */
Yorke Lee94c87612014-07-18 18:57:17 -07006663 public static final class Relation implements DataColumnsWithJoins, CommonColumns,
6664 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006665 /**
6666 * This utility class cannot be instantiated
6667 */
Fred Quintana8851e162009-08-05 21:06:45 -07006668 private Relation() {}
6669
6670 /** MIME type used when storing this in data table. */
6671 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
6672
6673 public static final int TYPE_ASSISTANT = 1;
6674 public static final int TYPE_BROTHER = 2;
6675 public static final int TYPE_CHILD = 3;
6676 public static final int TYPE_DOMESTIC_PARTNER = 4;
6677 public static final int TYPE_FATHER = 5;
6678 public static final int TYPE_FRIEND = 6;
6679 public static final int TYPE_MANAGER = 7;
6680 public static final int TYPE_MOTHER = 8;
6681 public static final int TYPE_PARENT = 9;
6682 public static final int TYPE_PARTNER = 10;
6683 public static final int TYPE_REFERRED_BY = 11;
6684 public static final int TYPE_RELATIVE = 12;
6685 public static final int TYPE_SISTER = 13;
6686 public static final int TYPE_SPOUSE = 14;
6687
6688 /**
6689 * The name of the relative as the user entered it.
6690 * <P>Type: TEXT</P>
6691 */
6692 public static final String NAME = DATA;
Daniel Lehmann1fb39f02010-10-28 13:40:38 -07006693
6694 /**
6695 * Return the string resource that best describes the given
6696 * {@link #TYPE}. Will always return a valid resource.
6697 */
6698 public static final int getTypeLabelResource(int type) {
6699 switch (type) {
6700 case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant;
6701 case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother;
6702 case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild;
6703 case TYPE_DOMESTIC_PARTNER:
6704 return com.android.internal.R.string.relationTypeDomesticPartner;
6705 case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather;
6706 case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend;
6707 case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager;
6708 case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother;
6709 case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent;
6710 case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner;
6711 case TYPE_REFERRED_BY:
6712 return com.android.internal.R.string.relationTypeReferredBy;
6713 case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative;
6714 case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister;
6715 case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse;
6716 default: return com.android.internal.R.string.orgTypeCustom;
6717 }
6718 }
6719
6720 /**
6721 * Return a {@link CharSequence} that best describes the given type,
6722 * possibly substituting the given {@link #LABEL} value
6723 * for {@link #TYPE_CUSTOM}.
6724 */
6725 public static final CharSequence getTypeLabel(Resources res, int type,
6726 CharSequence label) {
6727 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6728 return label;
6729 } else {
6730 final int labelRes = getTypeLabelResource(type);
6731 return res.getText(labelRes);
6732 }
6733 }
Fred Quintana8851e162009-08-05 21:06:45 -07006734 }
6735
6736 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006737 * <p>
6738 * A data kind representing an event.
6739 * </p>
6740 * <p>
6741 * You can use all columns defined for {@link ContactsContract.Data} as
6742 * well as the following aliases.
6743 * </p>
6744 * <h2>Column aliases</h2>
6745 * <table class="jd-sumtable">
6746 * <tr>
6747 * <th>Type</th>
6748 * <th>Alias</th><th colspan='2'>Data column</th>
6749 * </tr>
6750 * <tr>
6751 * <td>String</td>
6752 * <td>{@link #START_DATE}</td>
6753 * <td>{@link #DATA1}</td>
6754 * <td></td>
6755 * </tr>
6756 * <tr>
6757 * <td>int</td>
6758 * <td>{@link #TYPE}</td>
6759 * <td>{@link #DATA2}</td>
6760 * <td>Allowed values are:
6761 * <p>
6762 * <ul>
6763 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6764 * <li>{@link #TYPE_ANNIVERSARY}</li>
6765 * <li>{@link #TYPE_OTHER}</li>
6766 * <li>{@link #TYPE_BIRTHDAY}</li>
6767 * </ul>
6768 * </p>
6769 * </td>
6770 * </tr>
6771 * <tr>
6772 * <td>String</td>
6773 * <td>{@link #LABEL}</td>
6774 * <td>{@link #DATA3}</td>
6775 * <td></td>
6776 * </tr>
6777 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006778 */
Yorke Lee94c87612014-07-18 18:57:17 -07006779 public static final class Event implements DataColumnsWithJoins, CommonColumns,
6780 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006781 /**
6782 * This utility class cannot be instantiated
6783 */
Fred Quintana8851e162009-08-05 21:06:45 -07006784 private Event() {}
6785
6786 /** MIME type used when storing this in data table. */
Fred Quintanac868acf2009-09-30 18:17:47 -07006787 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
Fred Quintana8851e162009-08-05 21:06:45 -07006788
6789 public static final int TYPE_ANNIVERSARY = 1;
6790 public static final int TYPE_OTHER = 2;
Fred Quintanac868acf2009-09-30 18:17:47 -07006791 public static final int TYPE_BIRTHDAY = 3;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006792
Fred Quintana8851e162009-08-05 21:06:45 -07006793 /**
6794 * The event start date as the user entered it.
6795 * <P>Type: TEXT</P>
6796 */
6797 public static final String START_DATE = DATA;
Fred Quintanac868acf2009-09-30 18:17:47 -07006798
6799 /**
6800 * Return the string resource that best describes the given
6801 * {@link #TYPE}. Will always return a valid resource.
6802 */
6803 public static int getTypeResource(Integer type) {
6804 if (type == null) {
6805 return com.android.internal.R.string.eventTypeOther;
6806 }
6807 switch (type) {
6808 case TYPE_ANNIVERSARY:
6809 return com.android.internal.R.string.eventTypeAnniversary;
6810 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
6811 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
Daniel Lehmanndd384a72010-11-01 18:40:50 -07006812 default: return com.android.internal.R.string.eventTypeCustom;
Fred Quintanac868acf2009-09-30 18:17:47 -07006813 }
6814 }
Paul Soulos6b2dd632014-07-24 17:17:42 -07006815
6816 /**
6817 * Return a {@link CharSequence} that best describes the given type,
6818 * possibly substituting the given {@link #LABEL} value
6819 * for {@link #TYPE_CUSTOM}.
6820 */
6821 public static final CharSequence getTypeLabel(Resources res, int type,
6822 CharSequence label) {
6823 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6824 return label;
6825 } else {
6826 final int labelRes = getTypeResource(type);
6827 return res.getText(labelRes);
6828 }
6829 }
Evan Millar088b2912009-05-28 15:24:37 -07006830 }
6831
6832 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006833 * <p>
Dave Santoroa5282372011-06-29 00:25:16 -07006834 * A data kind representing a photo for the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006835 * </p>
6836 * <p>
6837 * Some sync adapters will choose to download photos in a separate
6838 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
6839 * through {@link ContactsContract.Data#SYNC4} to store temporary
6840 * data, e.g. the image URL or ID, state of download, server-side version
6841 * of the image. It is allowed for the {@link #PHOTO} to be null.
6842 * </p>
6843 * <p>
6844 * You can use all columns defined for {@link ContactsContract.Data} as
6845 * well as the following aliases.
6846 * </p>
6847 * <h2>Column aliases</h2>
6848 * <table class="jd-sumtable">
6849 * <tr>
6850 * <th>Type</th>
6851 * <th>Alias</th><th colspan='2'>Data column</th>
6852 * </tr>
6853 * <tr>
Dave Santoroa5282372011-06-29 00:25:16 -07006854 * <td>NUMBER</td>
6855 * <td>{@link #PHOTO_FILE_ID}</td>
6856 * <td>{@link #DATA14}</td>
6857 * <td>ID of the hi-res photo file.</td>
6858 * </tr>
6859 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006860 * <td>BLOB</td>
6861 * <td>{@link #PHOTO}</td>
6862 * <td>{@link #DATA15}</td>
Dave Santoroa5282372011-06-29 00:25:16 -07006863 * <td>By convention, binary data is stored in DATA15. The thumbnail of the
6864 * photo is stored in this column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006865 * </tr>
6866 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006867 */
Yorke Lee94c87612014-07-18 18:57:17 -07006868 public static final class Photo implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006869 /**
6870 * This utility class cannot be instantiated
6871 */
Evan Millar088b2912009-05-28 15:24:37 -07006872 private Photo() {}
6873
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006874 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006875 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
6876
6877 /**
Dave Santoroa5282372011-06-29 00:25:16 -07006878 * Photo file ID for the display photo of the raw contact.
6879 * See {@link ContactsContract.DisplayPhoto}.
6880 * <p>
6881 * Type: NUMBER
6882 */
6883 public static final String PHOTO_FILE_ID = DATA14;
6884
6885 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07006886 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07006887 * that could be inflated using {@link android.graphics.BitmapFactory}.
Evan Millar088b2912009-05-28 15:24:37 -07006888 * <p>
6889 * Type: BLOB
6890 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006891 public static final String PHOTO = DATA15;
Evan Millar088b2912009-05-28 15:24:37 -07006892 }
6893
6894 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006895 * <p>
Evan Millar088b2912009-05-28 15:24:37 -07006896 * Notes about the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006897 * </p>
6898 * <p>
6899 * You can use all columns defined for {@link ContactsContract.Data} as
6900 * well as the following aliases.
6901 * </p>
6902 * <h2>Column aliases</h2>
6903 * <table class="jd-sumtable">
6904 * <tr>
6905 * <th>Type</th>
6906 * <th>Alias</th><th colspan='2'>Data column</th>
6907 * </tr>
6908 * <tr>
6909 * <td>String</td>
6910 * <td>{@link #NOTE}</td>
6911 * <td>{@link #DATA1}</td>
6912 * <td></td>
6913 * </tr>
6914 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006915 */
Yorke Lee94c87612014-07-18 18:57:17 -07006916 public static final class Note implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006917 /**
6918 * This utility class cannot be instantiated
6919 */
Evan Millar088b2912009-05-28 15:24:37 -07006920 private Note() {}
6921
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006922 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006923 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
6924
6925 /**
6926 * The note text.
6927 * <P>Type: TEXT</P>
6928 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006929 public static final String NOTE = DATA1;
Evan Millar088b2912009-05-28 15:24:37 -07006930 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006931
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07006932 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006933 * <p>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006934 * Group Membership.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006935 * </p>
6936 * <p>
6937 * You can use all columns defined for {@link ContactsContract.Data} as
6938 * well as the following aliases.
6939 * </p>
6940 * <h2>Column aliases</h2>
6941 * <table class="jd-sumtable">
6942 * <tr>
6943 * <th>Type</th>
6944 * <th>Alias</th><th colspan='2'>Data column</th>
6945 * </tr>
6946 * <tr>
6947 * <td>long</td>
6948 * <td>{@link #GROUP_ROW_ID}</td>
6949 * <td>{@link #DATA1}</td>
6950 * <td></td>
6951 * </tr>
6952 * <tr>
6953 * <td>String</td>
6954 * <td>{@link #GROUP_SOURCE_ID}</td>
6955 * <td>none</td>
6956 * <td>
6957 * <p>
6958 * The sourceid of the group that this group membership refers to.
6959 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
6960 * inserting a row.
6961 * </p>
6962 * <p>
6963 * If this field is specified, the provider will first try to
6964 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group
6965 * is found, it will use the corresponding row id. If the group is not
6966 * found, it will create one.
6967 * </td>
6968 * </tr>
6969 * </table>
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006970 */
Yorke Lee94c87612014-07-18 18:57:17 -07006971 public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006972 /**
6973 * This utility class cannot be instantiated
6974 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006975 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006976
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006977 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006978 public static final String CONTENT_ITEM_TYPE =
6979 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006980
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006981 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07006982 * The row id of the group that this group membership refers to. Exactly one of
6983 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006984 * <P>Type: INTEGER</P>
6985 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006986 public static final String GROUP_ROW_ID = DATA1;
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006987
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006988 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07006989 * The sourceid of the group that this group membership refers to. Exactly one of
6990 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006991 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006992 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07006993 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006994 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006995
6996 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006997 * <p>
6998 * A data kind representing a website related to the contact.
6999 * </p>
7000 * <p>
7001 * You can use all columns defined for {@link ContactsContract.Data} as
7002 * well as the following aliases.
7003 * </p>
7004 * <h2>Column aliases</h2>
7005 * <table class="jd-sumtable">
7006 * <tr>
7007 * <th>Type</th>
7008 * <th>Alias</th><th colspan='2'>Data column</th>
7009 * </tr>
7010 * <tr>
7011 * <td>String</td>
7012 * <td>{@link #URL}</td>
7013 * <td>{@link #DATA1}</td>
7014 * <td></td>
7015 * </tr>
7016 * <tr>
7017 * <td>int</td>
7018 * <td>{@link #TYPE}</td>
7019 * <td>{@link #DATA2}</td>
7020 * <td>Allowed values are:
7021 * <p>
7022 * <ul>
7023 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7024 * <li>{@link #TYPE_HOMEPAGE}</li>
7025 * <li>{@link #TYPE_BLOG}</li>
7026 * <li>{@link #TYPE_PROFILE}</li>
7027 * <li>{@link #TYPE_HOME}</li>
7028 * <li>{@link #TYPE_WORK}</li>
7029 * <li>{@link #TYPE_FTP}</li>
7030 * <li>{@link #TYPE_OTHER}</li>
7031 * </ul>
7032 * </p>
7033 * </td>
7034 * </tr>
7035 * <tr>
7036 * <td>String</td>
7037 * <td>{@link #LABEL}</td>
7038 * <td>{@link #DATA3}</td>
7039 * <td></td>
7040 * </tr>
7041 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007042 */
Yorke Lee94c87612014-07-18 18:57:17 -07007043 public static final class Website implements DataColumnsWithJoins, CommonColumns,
7044 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007045 /**
7046 * This utility class cannot be instantiated
7047 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007048 private Website() {}
7049
7050 /** MIME type used when storing this in data table. */
7051 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
7052
Fred Quintana8851e162009-08-05 21:06:45 -07007053 public static final int TYPE_HOMEPAGE = 1;
7054 public static final int TYPE_BLOG = 2;
7055 public static final int TYPE_PROFILE = 3;
7056 public static final int TYPE_HOME = 4;
7057 public static final int TYPE_WORK = 5;
7058 public static final int TYPE_FTP = 6;
7059 public static final int TYPE_OTHER = 7;
7060
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007061 /**
7062 * The website URL string.
7063 * <P>Type: TEXT</P>
7064 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07007065 public static final String URL = DATA;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007066 }
David Brown846eb302010-08-23 17:40:51 -07007067
7068 /**
7069 * <p>
7070 * A data kind representing a SIP address for the contact.
7071 * </p>
7072 * <p>
7073 * You can use all columns defined for {@link ContactsContract.Data} as
7074 * well as the following aliases.
7075 * </p>
7076 * <h2>Column aliases</h2>
7077 * <table class="jd-sumtable">
7078 * <tr>
7079 * <th>Type</th>
7080 * <th>Alias</th><th colspan='2'>Data column</th>
7081 * </tr>
7082 * <tr>
7083 * <td>String</td>
7084 * <td>{@link #SIP_ADDRESS}</td>
7085 * <td>{@link #DATA1}</td>
7086 * <td></td>
7087 * </tr>
David Brown747c6152010-09-15 13:34:13 -07007088 * <tr>
7089 * <td>int</td>
7090 * <td>{@link #TYPE}</td>
7091 * <td>{@link #DATA2}</td>
7092 * <td>Allowed values are:
7093 * <p>
7094 * <ul>
7095 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7096 * <li>{@link #TYPE_HOME}</li>
7097 * <li>{@link #TYPE_WORK}</li>
7098 * <li>{@link #TYPE_OTHER}</li>
7099 * </ul>
7100 * </p>
7101 * </td>
7102 * </tr>
7103 * <tr>
7104 * <td>String</td>
7105 * <td>{@link #LABEL}</td>
7106 * <td>{@link #DATA3}</td>
7107 * <td></td>
7108 * </tr>
David Brown846eb302010-08-23 17:40:51 -07007109 * </table>
7110 */
Yorke Lee94c87612014-07-18 18:57:17 -07007111 public static final class SipAddress implements DataColumnsWithJoins, CommonColumns,
7112 ContactCounts {
David Brown846eb302010-08-23 17:40:51 -07007113 /**
7114 * This utility class cannot be instantiated
7115 */
7116 private SipAddress() {}
7117
7118 /** MIME type used when storing this in data table. */
7119 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address";
7120
David Brown747c6152010-09-15 13:34:13 -07007121 public static final int TYPE_HOME = 1;
7122 public static final int TYPE_WORK = 2;
7123 public static final int TYPE_OTHER = 3;
7124
David Brown846eb302010-08-23 17:40:51 -07007125 /**
7126 * The SIP address.
7127 * <P>Type: TEXT</P>
7128 */
7129 public static final String SIP_ADDRESS = DATA1;
David Brown747c6152010-09-15 13:34:13 -07007130 // ...and TYPE and LABEL come from the CommonColumns interface.
7131
7132 /**
7133 * Return the string resource that best describes the given
7134 * {@link #TYPE}. Will always return a valid resource.
7135 */
7136 public static final int getTypeLabelResource(int type) {
7137 switch (type) {
7138 case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome;
7139 case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork;
7140 case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther;
7141 default: return com.android.internal.R.string.sipAddressTypeCustom;
7142 }
7143 }
7144
7145 /**
7146 * Return a {@link CharSequence} that best describes the given type,
7147 * possibly substituting the given {@link #LABEL} value
7148 * for {@link #TYPE_CUSTOM}.
7149 */
7150 public static final CharSequence getTypeLabel(Resources res, int type,
7151 CharSequence label) {
7152 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7153 return label;
7154 } else {
7155 final int labelRes = getTypeLabelResource(type);
7156 return res.getText(labelRes);
7157 }
7158 }
David Brown846eb302010-08-23 17:40:51 -07007159 }
Fred Quintana4923f1d2011-08-05 15:58:17 -07007160
7161 /**
7162 * A data kind representing an Identity related to the contact.
7163 * <p>
7164 * This can be used as a signal by the aggregator to combine raw contacts into
7165 * contacts, e.g. if two contacts have Identity rows with
7166 * the same NAMESPACE and IDENTITY values the aggregator can know that they refer
7167 * to the same person.
7168 * </p>
7169 */
Yorke Lee94c87612014-07-18 18:57:17 -07007170 public static final class Identity implements DataColumnsWithJoins, ContactCounts {
Fred Quintana4923f1d2011-08-05 15:58:17 -07007171 /**
7172 * This utility class cannot be instantiated
7173 */
7174 private Identity() {}
7175
7176 /** MIME type used when storing this in data table. */
7177 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity";
7178
7179 /**
7180 * The identity string.
7181 * <P>Type: TEXT</P>
7182 */
7183 public static final String IDENTITY = DataColumns.DATA1;
7184
7185 /**
7186 * The namespace of the identity string, e.g. "com.google"
7187 * <P>Type: TEXT</P>
7188 */
7189 public static final String NAMESPACE = DataColumns.DATA2;
7190 }
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007191
7192 /**
7193 * <p>
7194 * Convenient functionalities for "callable" data. Note that, this is NOT a separate data
7195 * kind.
7196 * </p>
7197 * <p>
7198 * This URI allows the ContactsProvider to return a unified result for "callable" data
7199 * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the
7200 * current examples for "callable", but may be expanded to the other types.
7201 * </p>
7202 * <p>
7203 * Each returned row may have a different MIMETYPE and thus different interpretation for
7204 * each column. For example the meaning for {@link Phone}'s type is different than
7205 * {@link SipAddress}'s.
7206 * </p>
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007207 */
Yorke Lee94c87612014-07-18 18:57:17 -07007208 public static final class Callable implements DataColumnsWithJoins, CommonColumns,
7209 ContactCounts {
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007210 /**
7211 * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only
7212 * phone numbers.
7213 */
7214 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7215 "callables");
7216 /**
7217 * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable
7218 * data.
7219 */
7220 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
7221 "filter");
7222 }
Yorke Lee4f401eb2013-03-06 17:17:17 -08007223
7224 /**
7225 * A special class of data items, used to refer to types of data that can be used to attempt
7226 * to start communicating with a person ({@link Phone} and {@link Email}). Note that this
7227 * is NOT a separate data kind.
7228 *
7229 * This URI allows the ContactsProvider to return a unified result for data items that users
7230 * can use to initiate communications with another contact. {@link Phone} and {@link Email}
7231 * are the current data types in this category.
7232 */
Yorke Lee94c87612014-07-18 18:57:17 -07007233 public static final class Contactables implements DataColumnsWithJoins, CommonColumns,
7234 ContactCounts {
Yorke Lee4f401eb2013-03-06 17:17:17 -08007235 /**
7236 * The content:// style URI for these data items, which requests a directory of data
7237 * rows matching the selection criteria.
7238 */
7239 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7240 "contactables");
7241
7242 /**
7243 * The content:// style URI for these data items, which allows for a query parameter to
7244 * be appended onto the end to filter for data items matching the query.
7245 */
7246 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
7247 Contactables.CONTENT_URI, "filter");
7248
7249 /**
7250 * A boolean parameter for {@link Data#CONTENT_URI}.
7251 * This specifies whether or not the returned data items should be filtered to show
7252 * data items belonging to visible contacts only.
7253 */
7254 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
7255 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07007256 }
Fred Quintana435e4272009-06-04 17:30:28 -07007257
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007258 /**
7259 * @see Groups
7260 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07007261 protected interface GroupsColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007262 /**
Dave Santorod7bdc182011-06-24 15:39:39 -07007263 * The data set within the account that this group belongs to. This allows
7264 * multiple sync adapters for the same account type to distinguish between
7265 * each others' group data.
7266 *
7267 * This is empty by default, and is completely optional. It only needs to
7268 * be populated if multiple sync adapters are entering distinct group data
7269 * for the same account type and account name.
7270 * <P>Type: TEXT</P>
7271 */
7272 public static final String DATA_SET = "data_set";
7273
7274 /**
Dave Santoro1d55c332011-07-25 16:44:45 -07007275 * A concatenation of the account type and data set (delimited by a forward
7276 * slash) - if the data set is empty, this will be the same as the account
7277 * type. For applications that need to be aware of the data set, this can
7278 * be used instead of account type to distinguish sets of data. This is
7279 * never intended to be used for specifying accounts.
7280 * @hide
7281 */
7282 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
7283
7284 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007285 * The display title of this group.
7286 * <p>
7287 * Type: TEXT
7288 */
7289 public static final String TITLE = "title";
7290
7291 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007292 * The package name to use when creating {@link Resources} objects for
7293 * this group. This value is only designed for use when building user
7294 * interfaces, and should not be used to infer the owner.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007295 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007296 public static final String RES_PACKAGE = "res_package";
7297
7298 /**
7299 * The display title of this group to load as a resource from
7300 * {@link #RES_PACKAGE}, which may be localized.
7301 * <P>Type: TEXT</P>
7302 */
7303 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007304
7305 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07007306 * Notes about the group.
7307 * <p>
7308 * Type: TEXT
7309 */
7310 public static final String NOTES = "notes";
7311
7312 /**
7313 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
7314 * to the sync adapter, null otherwise.
7315 * <P>Type: TEXT</P>
7316 */
7317 public static final String SYSTEM_ID = "system_id";
7318
7319 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007320 * The total number of {@link Contacts} that have
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007321 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007322 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
7323 * <p>
7324 * Type: INTEGER
7325 */
7326 public static final String SUMMARY_COUNT = "summ_count";
7327
7328 /**
Daisuke Miyakawa15dec392011-07-23 11:39:23 -07007329 * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}.
7330 * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}.
7331 *
7332 * @hide
7333 */
7334 public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT =
7335 "return_group_count_per_account";
7336
7337 /**
7338 * The total number of groups of the account that a group belongs to.
7339 * This column is available only when the parameter
7340 * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in
7341 * {@link Groups#CONTENT_SUMMARY_URI}.
7342 *
7343 * For example, when the account "A" has two groups "group1" and "group2", and the account
7344 * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for
7345 * "group3" returns "1" for this column.
7346 *
7347 * Note: This counts only non-favorites, non-auto-add, and not deleted groups.
7348 *
7349 * Type: INTEGER
7350 * @hide
7351 */
7352 public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account";
7353
7354 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007355 * The total number of {@link Contacts} that have both
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007356 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007357 * Read-only value that is only present when querying
7358 * {@link Groups#CONTENT_SUMMARY_URI}.
7359 * <p>
7360 * Type: INTEGER
7361 */
7362 public static final String SUMMARY_WITH_PHONES = "summ_phones";
7363
7364 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007365 * Flag indicating if the contacts belonging to this group should be
7366 * visible in any user interface.
7367 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007368 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007369 */
7370 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07007371
7372 /**
7373 * The "deleted" flag: "0" by default, "1" if the row has been marked
7374 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007375 * called on a group, it is marked for deletion. The sync adaptor
7376 * deletes the group on the server and then calls ContactResolver.delete
7377 * once more, this time setting the the
7378 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
7379 * finalize the data removal.
Fred Quintana00c89f62009-08-10 14:43:24 -07007380 * <P>Type: INTEGER</P>
7381 */
7382 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07007383
7384 /**
7385 * Whether this group should be synced if the SYNC_EVERYTHING settings
7386 * is false for this group's account.
7387 * <p>
7388 * Type: INTEGER (boolean)
7389 */
7390 public static final String SHOULD_SYNC = "should_sync";
Fred Quintanaa31a9452010-04-13 14:52:20 -07007391
7392 /**
7393 * Any newly created contacts will automatically be added to groups that have this
7394 * flag set to true.
7395 * <p>
7396 * Type: INTEGER (boolean)
7397 */
7398 public static final String AUTO_ADD = "auto_add";
7399
7400 /**
7401 * When a contacts is marked as a favorites it will be automatically added
7402 * to the groups that have this flag set, and when it is removed from favorites
7403 * it will be removed from these groups.
7404 * <p>
7405 * Type: INTEGER (boolean)
7406 */
7407 public static final String FAVORITES = "favorites";
Dmitri Plotnikov4ccf33a2010-11-19 11:10:43 -08007408
7409 /**
7410 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
7411 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
7412 * <P>Type: INTEGER</P>
7413 */
7414 public static final String GROUP_IS_READ_ONLY = "group_is_read_only";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007415 }
7416
7417 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007418 * Constants for the groups table. Only per-account groups are supported.
7419 * <h2>Columns</h2>
7420 * <table class="jd-sumtable">
7421 * <tr>
7422 * <th colspan='4'>Groups</th>
7423 * </tr>
7424 * <tr>
7425 * <td>long</td>
7426 * <td>{@link #_ID}</td>
7427 * <td>read-only</td>
7428 * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
7429 * In other words, it would be a really bad idea to delete and reinsert a
7430 * group. A sync adapter should always do an update instead.</td>
7431 * </tr>
Dave Santorod7bdc182011-06-24 15:39:39 -07007432 # <tr>
7433 * <td>String</td>
7434 * <td>{@link #DATA_SET}</td>
7435 * <td>read/write-once</td>
7436 * <td>
7437 * <p>
7438 * The data set within the account that this group belongs to. This allows
7439 * multiple sync adapters for the same account type to distinguish between
7440 * each others' group data. The combination of {@link #ACCOUNT_TYPE},
7441 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
7442 * that is associated with a single sync adapter.
7443 * </p>
7444 * <p>
7445 * This is empty by default, and is completely optional. It only needs to
7446 * be populated if multiple sync adapters are entering distinct data for
7447 * the same account type and account name.
7448 * </p>
7449 * <p>
7450 * It should be set at the time the group is inserted and never changed
7451 * afterwards.
7452 * </p>
7453 * </td>
7454 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007455 * <tr>
7456 * <td>String</td>
7457 * <td>{@link #TITLE}</td>
7458 * <td>read/write</td>
7459 * <td>The display title of this group.</td>
7460 * </tr>
7461 * <tr>
7462 * <td>String</td>
7463 * <td>{@link #NOTES}</td>
7464 * <td>read/write</td>
7465 * <td>Notes about the group.</td>
7466 * </tr>
7467 * <tr>
7468 * <td>String</td>
7469 * <td>{@link #SYSTEM_ID}</td>
7470 * <td>read/write</td>
7471 * <td>The ID of this group if it is a System Group, i.e. a group that has a
7472 * special meaning to the sync adapter, null otherwise.</td>
7473 * </tr>
7474 * <tr>
7475 * <td>int</td>
7476 * <td>{@link #SUMMARY_COUNT}</td>
7477 * <td>read-only</td>
7478 * <td>The total number of {@link Contacts} that have
7479 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
7480 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
7481 * </tr>
7482 * <tr>
7483 * <td>int</td>
7484 * <td>{@link #SUMMARY_WITH_PHONES}</td>
7485 * <td>read-only</td>
7486 * <td>The total number of {@link Contacts} that have both
7487 * {@link CommonDataKinds.GroupMembership} in this group, and also have
7488 * phone numbers. Read-only value that is only present when querying
7489 * {@link Groups#CONTENT_SUMMARY_URI}.</td>
7490 * </tr>
7491 * <tr>
7492 * <td>int</td>
7493 * <td>{@link #GROUP_VISIBLE}</td>
7494 * <td>read-only</td>
7495 * <td>Flag indicating if the contacts belonging to this group should be
7496 * visible in any user interface. Allowed values: 0 and 1.</td>
7497 * </tr>
7498 * <tr>
7499 * <td>int</td>
7500 * <td>{@link #DELETED}</td>
7501 * <td>read/write</td>
7502 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
7503 * for deletion. When {@link android.content.ContentResolver#delete} is
7504 * called on a group, it is marked for deletion. The sync adaptor deletes
7505 * the group on the server and then calls ContactResolver.delete once more,
7506 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
7507 * query parameter to finalize the data removal.</td>
7508 * </tr>
7509 * <tr>
7510 * <td>int</td>
7511 * <td>{@link #SHOULD_SYNC}</td>
7512 * <td>read/write</td>
7513 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
7514 * is false for this group's account.</td>
7515 * </tr>
7516 * </table>
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007517 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007518 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007519 /**
7520 * This utility class cannot be instantiated
7521 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007522 private Groups() {
7523 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007524
7525 /**
7526 * The content:// style URI for this table
7527 */
7528 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
7529
7530 /**
7531 * The content:// style URI for this table joined with details data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007532 * {@link ContactsContract.Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007533 */
7534 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
7535 "groups_summary");
7536
7537 /**
7538 * The MIME type of a directory of groups.
7539 */
7540 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
7541
7542 /**
7543 * The MIME type of a single group.
7544 */
7545 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
Fred Quintana328c0e72009-12-07 14:52:28 -08007546
7547 public static EntityIterator newEntityIterator(Cursor cursor) {
7548 return new EntityIteratorImpl(cursor);
7549 }
7550
7551 private static class EntityIteratorImpl extends CursorEntityIterator {
7552 public EntityIteratorImpl(Cursor cursor) {
7553 super(cursor);
7554 }
7555
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08007556 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08007557 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
7558 // we expect the cursor is already at the row we need to read from
7559 final ContentValues values = new ContentValues();
7560 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
7561 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
7562 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
7563 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
7564 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
7565 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
7566 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
7567 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
7568 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
7569 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
7570 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
7571 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
7572 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
7573 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
7574 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
7575 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
7576 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
7577 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
Fred Quintanaa31a9452010-04-13 14:52:20 -07007578 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES);
7579 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD);
Fred Quintana328c0e72009-12-07 14:52:28 -08007580 cursor.moveToNext();
7581 return new Entity(values);
7582 }
7583 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007584 }
7585
Fred Quintana435e4272009-06-04 17:30:28 -07007586 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007587 * <p>
Fred Quintana435e4272009-06-04 17:30:28 -07007588 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007589 * aggregation rules overriding those used by automatic aggregation. This
7590 * type only supports query and update. Neither insert nor delete are
7591 * supported.
7592 * </p>
7593 * <h2>Columns</h2>
7594 * <table class="jd-sumtable">
7595 * <tr>
7596 * <th colspan='4'>AggregationExceptions</th>
7597 * </tr>
7598 * <tr>
7599 * <td>int</td>
7600 * <td>{@link #TYPE}</td>
7601 * <td>read/write</td>
7602 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
7603 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
7604 * </tr>
7605 * <tr>
7606 * <td>long</td>
7607 * <td>{@link #RAW_CONTACT_ID1}</td>
7608 * <td>read/write</td>
7609 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
7610 * the rule applies to.</td>
7611 * </tr>
7612 * <tr>
7613 * <td>long</td>
7614 * <td>{@link #RAW_CONTACT_ID2}</td>
7615 * <td>read/write</td>
7616 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
7617 * that the rule applies to.</td>
7618 * </tr>
7619 * </table>
Fred Quintana435e4272009-06-04 17:30:28 -07007620 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07007621 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07007622 /**
7623 * This utility class cannot be instantiated
7624 */
7625 private AggregationExceptions() {}
7626
7627 /**
7628 * The content:// style URI for this table
7629 */
7630 public static final Uri CONTENT_URI =
7631 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
7632
7633 /**
7634 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
7635 */
7636 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
7637
7638 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07007639 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
7640 */
7641 public static final String CONTENT_ITEM_TYPE =
7642 "vnd.android.cursor.item/aggregation_exception";
7643
7644 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007645 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007646 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07007647 *
7648 * <P>Type: INTEGER</P>
7649 */
7650 public static final String TYPE = "type";
7651
Fred Quintana435e4272009-06-04 17:30:28 -07007652 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007653 * Allows the provider to automatically decide whether the specified raw contacts should
7654 * be included in the same aggregate contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07007655 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007656 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07007657
7658 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007659 * Makes sure that the specified raw contacts are included in the same
7660 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007661 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007662 public static final int TYPE_KEEP_TOGETHER = 1;
7663
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007664 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007665 * Makes sure that the specified raw contacts are NOT included in the same
7666 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007667 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007668 public static final int TYPE_KEEP_SEPARATE = 2;
7669
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007670 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007671 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07007672 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007673 public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
7674
7675 /**
7676 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
7677 * applies to.
7678 */
7679 public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
Fred Quintana435e4272009-06-04 17:30:28 -07007680 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07007681
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007682 /**
7683 * @see Settings
7684 */
Dmitri Plotnikovfe4c8712009-10-14 00:28:48 -07007685 protected interface SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007686 /**
7687 * The name of the account instance to which this row belongs.
7688 * <P>Type: TEXT</P>
7689 */
7690 public static final String ACCOUNT_NAME = "account_name";
7691
7692 /**
7693 * The type of account to which this row belongs, which when paired with
7694 * {@link #ACCOUNT_NAME} identifies a specific account.
7695 * <P>Type: TEXT</P>
7696 */
7697 public static final String ACCOUNT_TYPE = "account_type";
7698
7699 /**
Dave Santoro7c4479f2011-09-07 16:52:27 -07007700 * The data set within the account that this row belongs to. This allows
7701 * multiple sync adapters for the same account type to distinguish between
7702 * each others' data.
7703 *
7704 * This is empty by default, and is completely optional. It only needs to
7705 * be populated if multiple sync adapters are entering distinct data for
7706 * the same account type and account name.
7707 * <P>Type: TEXT</P>
7708 */
7709 public static final String DATA_SET = "data_set";
7710
7711 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07007712 * Depending on the mode defined by the sync-adapter, this flag controls
7713 * the top-level sync behavior for this data source.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007714 * <p>
7715 * Type: INTEGER (boolean)
7716 */
7717 public static final String SHOULD_SYNC = "should_sync";
7718
7719 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007720 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
Jeff Sharkeya6597442009-08-19 09:23:33 -07007721 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007722 * <p>
7723 * Type: INTEGER (boolean)
7724 */
7725 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
Jeff Sharkey06a03232009-08-21 17:37:56 -07007726
7727 /**
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07007728 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
7729 * {@link Groups#SHOULD_SYNC} under this account have been marked as
7730 * unsynced.
7731 */
7732 public static final String ANY_UNSYNCED = "any_unsynced";
7733
7734 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07007735 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07007736 * no {@link CommonDataKinds.GroupMembership} entries.
Jeff Sharkey06a03232009-08-21 17:37:56 -07007737 * <p>
7738 * Type: INTEGER
7739 */
7740 public static final String UNGROUPED_COUNT = "summ_count";
7741
7742 /**
7743 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07007744 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
Jeff Sharkey06a03232009-08-21 17:37:56 -07007745 * <p>
7746 * Type: INTEGER
7747 */
7748 public static final String UNGROUPED_WITH_PHONES = "summ_phones";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007749 }
7750
7751 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007752 * <p>
7753 * Contacts-specific settings for various {@link Account}'s.
7754 * </p>
7755 * <h2>Columns</h2>
7756 * <table class="jd-sumtable">
7757 * <tr>
7758 * <th colspan='4'>Settings</th>
7759 * </tr>
7760 * <tr>
7761 * <td>String</td>
7762 * <td>{@link #ACCOUNT_NAME}</td>
7763 * <td>read/write-once</td>
7764 * <td>The name of the account instance to which this row belongs.</td>
7765 * </tr>
7766 * <tr>
7767 * <td>String</td>
7768 * <td>{@link #ACCOUNT_TYPE}</td>
7769 * <td>read/write-once</td>
7770 * <td>The type of account to which this row belongs, which when paired with
7771 * {@link #ACCOUNT_NAME} identifies a specific account.</td>
7772 * </tr>
7773 * <tr>
7774 * <td>int</td>
7775 * <td>{@link #SHOULD_SYNC}</td>
7776 * <td>read/write</td>
7777 * <td>Depending on the mode defined by the sync-adapter, this flag controls
7778 * the top-level sync behavior for this data source.</td>
7779 * </tr>
7780 * <tr>
7781 * <td>int</td>
7782 * <td>{@link #UNGROUPED_VISIBLE}</td>
7783 * <td>read/write</td>
7784 * <td>Flag indicating if contacts without any
7785 * {@link CommonDataKinds.GroupMembership} entries should be visible in any
7786 * user interface.</td>
7787 * </tr>
7788 * <tr>
7789 * <td>int</td>
7790 * <td>{@link #ANY_UNSYNCED}</td>
7791 * <td>read-only</td>
7792 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
7793 * {@link Groups#SHOULD_SYNC} under this account have been marked as
7794 * unsynced.</td>
7795 * </tr>
7796 * <tr>
7797 * <td>int</td>
7798 * <td>{@link #UNGROUPED_COUNT}</td>
7799 * <td>read-only</td>
7800 * <td>Read-only count of {@link Contacts} from a specific source that have
7801 * no {@link CommonDataKinds.GroupMembership} entries.</td>
7802 * </tr>
7803 * <tr>
7804 * <td>int</td>
7805 * <td>{@link #UNGROUPED_WITH_PHONES}</td>
7806 * <td>read-only</td>
7807 * <td>Read-only count of {@link Contacts} from a specific source that have
7808 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
7809 * numbers.</td>
7810 * </tr>
7811 * </table>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007812 */
Jeff Sharkey06a03232009-08-21 17:37:56 -07007813 public static final class Settings implements SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007814 /**
7815 * This utility class cannot be instantiated
7816 */
7817 private Settings() {
7818 }
7819
7820 /**
7821 * The content:// style URI for this table
7822 */
7823 public static final Uri CONTENT_URI =
7824 Uri.withAppendedPath(AUTHORITY_URI, "settings");
7825
7826 /**
7827 * The MIME-type of {@link #CONTENT_URI} providing a directory of
7828 * settings.
7829 */
7830 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
7831
7832 /**
7833 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
7834 */
7835 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007836 }
7837
Evan Millardc2da5f2009-06-18 16:07:13 -07007838 /**
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08007839 * Private API for inquiring about the general status of the provider.
7840 *
7841 * @hide
7842 */
7843 public static final class ProviderStatus {
7844
7845 /**
7846 * Not instantiable.
7847 */
7848 private ProviderStatus() {
7849 }
7850
7851 /**
7852 * The content:// style URI for this table. Requests to this URI can be
7853 * performed on the UI thread because they are always unblocking.
7854 *
7855 * @hide
7856 */
7857 public static final Uri CONTENT_URI =
7858 Uri.withAppendedPath(AUTHORITY_URI, "provider_status");
7859
7860 /**
7861 * The MIME-type of {@link #CONTENT_URI} providing a directory of
7862 * settings.
7863 *
7864 * @hide
7865 */
7866 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status";
7867
7868 /**
7869 * An integer representing the current status of the provider.
7870 *
7871 * @hide
7872 */
7873 public static final String STATUS = "status";
7874
7875 /**
7876 * Default status of the provider.
7877 *
7878 * @hide
7879 */
7880 public static final int STATUS_NORMAL = 0;
7881
7882 /**
7883 * The status used when the provider is in the process of upgrading. Contacts
7884 * are temporarily unaccessible.
7885 *
7886 * @hide
7887 */
7888 public static final int STATUS_UPGRADING = 1;
7889
7890 /**
7891 * The status used if the provider was in the process of upgrading but ran
7892 * out of storage. The DATA1 column will contain the estimated amount of
7893 * storage required (in bytes). Update status to STATUS_NORMAL to force
7894 * the provider to retry the upgrade.
7895 *
7896 * @hide
7897 */
7898 public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2;
7899
7900 /**
7901 * The status used during a locale change.
7902 *
7903 * @hide
7904 */
7905 public static final int STATUS_CHANGING_LOCALE = 3;
7906
7907 /**
Dmitri Plotnikov37c34862010-11-12 16:12:53 -08007908 * The status that indicates that there are no accounts and no contacts
7909 * on the device.
7910 *
7911 * @hide
7912 */
7913 public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4;
7914
7915 /**
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08007916 * Additional data associated with the status.
7917 *
7918 * @hide
7919 */
7920 public static final String DATA1 = "data1";
7921 }
7922
7923 /**
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007924 * <p>
7925 * API allowing applications to send usage information for each {@link Data} row to the
Makoto Onukib0d22992012-04-12 17:09:58 -07007926 * Contacts Provider. Applications can also clear all usage information.
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007927 * </p>
7928 * <p>
7929 * With the feedback, Contacts Provider may return more contextually appropriate results for
7930 * Data listing, typically supplied with
7931 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI},
7932 * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI},
7933 * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit
7934 * from better ranked (sorted) lists in applications that show auto-complete list.
7935 * </p>
7936 * <p>
7937 * There is no guarantee for how this feedback is used, or even whether it is used at all.
7938 * The ranking algorithm will make best efforts to use the feedback data, but the exact
7939 * implementation, the storage data structures as well as the resulting sort order is device
7940 * and version specific and can change over time.
7941 * </p>
7942 * <p>
7943 * When updating usage information, users of this API need to use
7944 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed
7945 * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as
7946 * its last path. They also need to append a query parameter to the Uri, to specify the type of
7947 * the communication, which enables the Contacts Provider to differentiate between kinds of
7948 * interactions using the same contact data field (for example a phone number can be used to
7949 * make phone calls or send SMS).
7950 * </p>
7951 * <p>
7952 * Selection and selectionArgs are ignored and must be set to null. To get data ids,
7953 * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)}
7954 * toward {@link Data#CONTENT_URI}.
7955 * </p>
7956 * <p>
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07007957 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive
7958 * integer when successful, and returns 0 if no contact with that id was found.
7959 * </p>
7960 * <p>
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007961 * Example:
7962 * <pre>
Daisuke Miyakawa52e38232011-06-14 10:56:46 -07007963 * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007964 * .appendPath(TextUtils.join(",", dataIds))
Daisuke Miyakawa52e38232011-06-14 10:56:46 -07007965 * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
7966 * DataUsageFeedback.USAGE_TYPE_CALL)
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007967 * .build();
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07007968 * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0;
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007969 * </pre>
7970 * </p>
Makoto Onukib0d22992012-04-12 17:09:58 -07007971 * <p>
7972 * Applications can also clear all usage information with:
7973 * <pre>
Makoto Onuki7ebbfd02012-04-13 12:56:42 -07007974 * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0;
Makoto Onukib0d22992012-04-12 17:09:58 -07007975 * </pre>
7976 * </p>
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007977 */
7978 public static final class DataUsageFeedback {
7979
7980 /**
7981 * The content:// style URI for sending usage feedback.
7982 * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}.
7983 */
7984 public static final Uri FEEDBACK_URI =
7985 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback");
7986
7987 /**
Makoto Onuki7ebbfd02012-04-13 12:56:42 -07007988 * The content:// style URI for deleting all usage information.
7989 * Must be used with {@link ContentResolver#delete(Uri, String, String[])}.
7990 * The {@code where} and {@code selectionArgs} parameters are ignored.
7991 */
7992 public static final Uri DELETE_USAGE_URI =
7993 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage");
7994
7995 /**
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007996 * <p>
7997 * Name for query parameter specifying the type of data usage.
7998 * </p>
7999 */
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07008000 public static final String USAGE_TYPE = "type";
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008001
8002 /**
8003 * <p>
8004 * Type of usage for voice interaction, which includes phone call, voice chat, and
8005 * video chat.
8006 * </p>
8007 */
8008 public static final String USAGE_TYPE_CALL = "call";
8009
8010 /**
8011 * <p>
8012 * Type of usage for text interaction involving longer messages, which includes email.
8013 * </p>
8014 */
8015 public static final String USAGE_TYPE_LONG_TEXT = "long_text";
8016
8017 /**
8018 * <p>
8019 * Type of usage for text interaction involving shorter messages, which includes SMS,
8020 * text chat with email addresses.
8021 * </p>
8022 */
8023 public static final String USAGE_TYPE_SHORT_TEXT = "short_text";
8024 }
8025
8026 /**
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008027 * <p>
Yorke Leecadbe4c2014-06-20 11:52:27 -07008028 * Contact-specific information about whether or not a contact has been pinned by the user
8029 * at a particular position within the system contact application's user interface.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008030 * </p>
8031 *
8032 * <p>
8033 * This pinning information can be used by individual applications to customize how
8034 * they order particular pinned contacts. For example, a Dialer application could
8035 * use pinned information to order user-pinned contacts in a top row of favorites.
8036 * </p>
8037 *
8038 * <p>
8039 * It is possible for two or more contacts to occupy the same pinned position (due
8040 * to aggregation and sync), so this pinning information should be used on a best-effort
8041 * basis to order contacts in-application rather than an absolute guide on where a contact
8042 * should be positioned. Contacts returned by the ContactsProvider will not be ordered based
8043 * on this information, so it is up to the client application to reorder these contacts within
8044 * their own UI adhering to (or ignoring as appropriate) information stored in the pinned
8045 * column.
8046 * </p>
8047 *
8048 * <p>
8049 * By default, unpinned contacts will have a pinned position of
Yorke Lee7d246792014-07-25 10:05:55 -07008050 * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive
8051 * integers that are greater than 1.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008052 * </p>
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008053 */
8054 public static final class PinnedPositions {
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008055 /**
Yorke Lee0e040b02014-06-18 15:02:44 -07008056 * The method to invoke in order to undemote a formerly demoted contact. The contact id of
8057 * the contact must be provided as an argument. If the contact was not previously demoted,
8058 * nothing will be done.
Yorke Lee94c87612014-07-18 18:57:17 -07008059 * @hide
Yorke Lee0e040b02014-06-18 15:02:44 -07008060 */
8061 public static final String UNDEMOTE_METHOD = "undemote";
8062
8063 /**
Yorke Lee94c87612014-07-18 18:57:17 -07008064 * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing
8065 * will be done.
8066 *
8067 * @param contentResolver to perform the undemote operation on.
8068 * @param contactId the id of the contact to undemote.
8069 */
8070 public static void undemote(ContentResolver contentResolver, long contactId) {
8071 contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD,
8072 String.valueOf(contactId), null);
8073 }
8074
8075 /**
Yorke Leeb31c8ab2014-08-26 17:13:02 -07008076 * Pins a contact at a provided position, or unpins a contact.
8077 *
8078 * @param contentResolver to perform the pinning operation on.
8079 * @param pinnedPosition the position to pin the contact at. To unpin a contact, use
8080 * {@link PinnedPositions#UNPINNED}.
8081 */
8082 public static void pin(
8083 ContentResolver contentResolver, long contactId, int pinnedPosition) {
8084 final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId));
8085 final ContentValues values = new ContentValues();
8086 values.put(Contacts.PINNED, pinnedPosition);
8087 contentResolver.update(uri, values, null, null);
8088 }
8089
8090 /**
Yorke Lee94c87612014-07-18 18:57:17 -07008091 * Default value for the pinned position of an unpinned contact.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008092 */
Yorke Lee7d246792014-07-25 10:05:55 -07008093 public static final int UNPINNED = 0;
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008094
8095 /**
Yorke Lee3585e1a2013-07-31 18:53:31 -07008096 * Value of pinned position for a contact that a user has indicated should be considered
8097 * of the lowest priority. It is up to the client application to determine how to present
8098 * such a contact - for example all the way at the bottom of a contact list, or simply
8099 * just hidden from view.
8100 */
8101 public static final int DEMOTED = -1;
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008102 }
8103
8104 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008105 * Helper methods to display QuickContact dialogs that display all the information belonging to
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008106 * a specific {@link Contacts} entry.
8107 */
Evan Millare3ec9972009-09-30 19:37:36 -07008108 public static final class QuickContact {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008109 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008110 * Action used to launch the system contacts application and bring up a QuickContact dialog
8111 * for the provided {@link Contacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008112 */
Evan Millar5042f7e2009-09-30 21:28:33 -07008113 public static final String ACTION_QUICK_CONTACT =
8114 "com.android.contacts.action.QUICK_CONTACT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008115
8116 /**
8117 * Extra used to specify pivot dialog location in screen coordinates.
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008118 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008119 * @hide
8120 */
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008121 @Deprecated
Makoto Onuki0e917332014-08-26 14:06:30 -07008122 public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008123
8124 /**
8125 * Extra used to specify size of pivot dialog.
8126 * @hide
8127 */
Makoto Onuki0e917332014-08-26 14:06:30 -07008128 public static final String EXTRA_MODE = "android.provider.extra.MODE";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008129
8130 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008131 * Extra used to indicate a list of specific MIME-types to exclude and not display in the
8132 * QuickContacts dialog. Stored as a {@link String} array.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008133 */
Makoto Onuki0e917332014-08-26 14:06:30 -07008134 public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008135
8136 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008137 * Small QuickContact mode, usually presented with minimal actions.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008138 */
8139 public static final int MODE_SMALL = 1;
8140
8141 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008142 * Medium QuickContact mode, includes actions and light summary describing
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008143 * the {@link Contacts} entry being shown. This may include social
8144 * status and presence details.
8145 */
8146 public static final int MODE_MEDIUM = 2;
8147
8148 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008149 * Large QuickContact mode, includes actions and larger, card-like summary
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008150 * of the {@link Contacts} entry being shown. This may include detailed
8151 * information, such as a photo.
8152 */
8153 public static final int MODE_LARGE = 3;
8154
8155 /**
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008156 * Constructs the QuickContacts intent with a view's rect.
8157 * @hide
8158 */
8159 public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri,
8160 int mode, String[] excludeMimes) {
8161 // Find location and bounds of target view, adjusting based on the
8162 // assumed local density.
8163 final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
8164 final int[] pos = new int[2];
8165 target.getLocationOnScreen(pos);
8166
8167 final Rect rect = new Rect();
8168 rect.left = (int) (pos[0] * appScale + 0.5f);
8169 rect.top = (int) (pos[1] * appScale + 0.5f);
8170 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
8171 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
8172
8173 return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes);
8174 }
8175
8176 /**
8177 * Constructs the QuickContacts intent.
8178 * @hide
8179 */
8180 public static Intent composeQuickContactsIntent(Context context, Rect target,
8181 Uri lookupUri, int mode, String[] excludeMimes) {
8182 // When launching from an Activiy, we don't want to start a new task, but otherwise
8183 // we *must* start a new task. (Otherwise startActivity() would crash.)
8184 Context actualContext = context;
8185 while ((actualContext instanceof ContextWrapper)
8186 && !(actualContext instanceof Activity)) {
8187 actualContext = ((ContextWrapper) actualContext).getBaseContext();
8188 }
Brian Attwell9ee66402014-08-11 22:42:26 -07008189 final int intentFlags = ((actualContext instanceof Activity)
8190 ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
8191 // Workaround for b/16898764. Declaring singleTop in manifest doesn't work.
8192 | Intent.FLAG_ACTIVITY_SINGLE_TOP;
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008193
8194 // Launch pivot dialog through intent for now
8195 final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
8196
8197 intent.setData(lookupUri);
8198 intent.setSourceBounds(target);
8199 intent.putExtra(EXTRA_MODE, mode);
8200 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
8201 return intent;
8202 }
8203
8204 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008205 * Trigger a dialog that lists the various methods of interacting with
8206 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008207 * {@link ContactsContract.Data} rows under that contact, and may also
8208 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008209 *
8210 * @param context The parent {@link Context} that may be used as the
8211 * parent for this dialog.
8212 * @param target Specific {@link View} from your layout that this dialog
8213 * should be centered around. In particular, if the dialog
8214 * has a "callout" arrow, it will be pointed and centered
8215 * around this {@link View}.
Evan Millar772722e2009-09-30 22:24:07 -07008216 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008217 * {@link Uri} that describes a specific contact to feature
8218 * in this dialog.
8219 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8220 * {@link #MODE_LARGE}, indicating the desired dialog size,
8221 * when supported.
8222 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8223 * to exclude when showing this dialog. For example, when
8224 * already viewing the contact details card, this can be used
8225 * to omit the details entry from the dialog.
8226 */
Evan Millare3ec9972009-09-30 19:37:36 -07008227 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008228 String[] excludeMimes) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008229 // Trigger with obtained rectangle
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008230 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8231 excludeMimes);
Yorke Lee4fc601a2013-12-06 16:35:29 -08008232 startActivityWithErrorToast(context, intent);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008233 }
8234
8235 /**
8236 * Trigger a dialog that lists the various methods of interacting with
8237 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008238 * {@link ContactsContract.Data} rows under that contact, and may also
8239 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008240 *
8241 * @param context The parent {@link Context} that may be used as the
8242 * parent for this dialog.
8243 * @param target Specific {@link Rect} that this dialog should be
8244 * centered around, in screen coordinates. In particular, if
8245 * the dialog has a "callout" arrow, it will be pointed and
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008246 * centered around this {@link Rect}. If you are running at a
8247 * non-native density, you need to manually adjust using
8248 * {@link DisplayMetrics#density} before calling.
Jeff Sharkey223bd7a2009-12-21 14:51:19 -08008249 * @param lookupUri A
8250 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008251 * {@link Uri} that describes a specific contact to feature
8252 * in this dialog.
8253 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8254 * {@link #MODE_LARGE}, indicating the desired dialog size,
8255 * when supported.
8256 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8257 * to exclude when showing this dialog. For example, when
8258 * already viewing the contact details card, this can be used
8259 * to omit the details entry from the dialog.
8260 */
Evan Millare3ec9972009-09-30 19:37:36 -07008261 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008262 String[] excludeMimes) {
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008263 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8264 excludeMimes);
Yorke Lee4fc601a2013-12-06 16:35:29 -08008265 startActivityWithErrorToast(context, intent);
8266 }
8267
8268 private static void startActivityWithErrorToast(Context context, Intent intent) {
8269 try {
8270 context.startActivity(intent);
8271 } catch (ActivityNotFoundException e) {
8272 Toast.makeText(context, com.android.internal.R.string.quick_contacts_not_available,
8273 Toast.LENGTH_SHORT).show();
8274 }
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008275 }
8276 }
8277
8278 /**
Dave Santoroa5282372011-06-29 00:25:16 -07008279 * Helper class for accessing full-size photos by photo file ID.
8280 * <p>
8281 * Usage example:
8282 * <dl>
8283 * <dt>Retrieving a full-size photo by photo file ID (see
8284 * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID})
8285 * </dt>
8286 * <dd>
8287 * <pre>
8288 * public InputStream openDisplayPhoto(long photoFileId) {
8289 * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
8290 * try {
Dave Santoro040e6b32011-07-15 15:14:08 -07008291 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
8292 * displayPhotoUri, "r");
Dave Santoroa5282372011-06-29 00:25:16 -07008293 * return fd.createInputStream();
Dave Santoro040e6b32011-07-15 15:14:08 -07008294 * } catch (IOException e) {
Dave Santoroa5282372011-06-29 00:25:16 -07008295 * return null;
8296 * }
8297 * }
8298 * </pre>
8299 * </dd>
8300 * </dl>
8301 * </p>
8302 */
8303 public static final class DisplayPhoto {
8304 /**
8305 * no public constructor since this is a utility class
8306 */
8307 private DisplayPhoto() {}
8308
8309 /**
8310 * The content:// style URI for this class, which allows access to full-size photos,
8311 * given a key.
8312 */
8313 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo");
8314
8315 /**
8316 * This URI allows the caller to query for the maximum dimensions of a display photo
8317 * or thumbnail. Requests to this URI can be performed on the UI thread because
8318 * they are always unblocking.
8319 */
8320 public static final Uri CONTENT_MAX_DIMENSIONS_URI =
8321 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions");
8322
8323 /**
8324 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8325 * contain this column, populated with the maximum height and width (in pixels)
8326 * that will be stored for a display photo. Larger photos will be down-sized to
8327 * fit within a square of this many pixels.
8328 */
8329 public static final String DISPLAY_MAX_DIM = "display_max_dim";
8330
8331 /**
8332 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8333 * contain this column, populated with the height and width (in pixels) for photo
8334 * thumbnails.
8335 */
8336 public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim";
8337 }
8338
8339 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008340 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
8341 * that involve contacts.
8342 */
8343 public static final class Intents {
8344 /**
8345 * This is the intent that is fired when a search suggestion is clicked on.
8346 */
8347 public static final String SEARCH_SUGGESTION_CLICKED =
8348 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
8349
8350 /**
8351 * This is the intent that is fired when a search suggestion for dialing a number
8352 * is clicked on.
8353 */
8354 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
8355 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
8356
8357 /**
8358 * This is the intent that is fired when a search suggestion for creating a contact
8359 * is clicked on.
8360 */
8361 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
8362 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
8363
8364 /**
Chiao Cheng2355d132013-03-20 16:54:06 -07008365 * This is the intent that is fired when the contacts database is created. <p> The
8366 * READ_CONTACT permission is required to receive these broadcasts.
8367 */
8368 public static final String CONTACTS_DATABASE_CREATED =
8369 "android.provider.Contacts.DATABASE_CREATED";
8370
8371 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008372 * Starts an Activity that lets the user pick a contact to attach an image to.
8373 * After picking the contact it launches the image cropper in face detection mode.
8374 */
8375 public static final String ATTACH_IMAGE =
8376 "com.android.contacts.action.ATTACH_IMAGE";
8377
8378 /**
Makoto Onuki85a01a62011-07-21 15:16:31 -07008379 * This is the intent that is fired when the user clicks the "invite to the network" button
8380 * on a contact. Only sent to an activity which is explicitly registered by a contact
8381 * provider which supports the "invite to the network" feature.
8382 * <p>
8383 * {@link Intent#getData()} contains the lookup URI for the contact.
8384 */
8385 public static final String INVITE_CONTACT =
8386 "com.android.contacts.action.INVITE_CONTACT";
8387
8388 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008389 * Takes as input a data URI with a mailto: or tel: scheme. If a single
8390 * contact exists with the given data it will be shown. If no contact
8391 * exists, a dialog will ask the user if they want to create a new
8392 * contact with the provided details filled in. If multiple contacts
8393 * share the data the user will be prompted to pick which contact they
8394 * want to view.
8395 * <p>
8396 * For <code>mailto:</code> URIs, the scheme specific portion must be a
8397 * raw email address, such as one built using
8398 * {@link Uri#fromParts(String, String, String)}.
8399 * <p>
8400 * For <code>tel:</code> URIs, the scheme specific portion is compared
8401 * to existing numbers using the standard caller ID lookup algorithm.
8402 * The number must be properly encoded, for example using
8403 * {@link Uri#fromParts(String, String, String)}.
8404 * <p>
8405 * Any extras from the {@link Insert} class will be passed along to the
8406 * create activity if there are no contacts to show.
8407 * <p>
8408 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
8409 * prompting the user when the contact doesn't exist.
8410 */
8411 public static final String SHOW_OR_CREATE_CONTACT =
8412 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
8413
8414 /**
Bai Taofc7838b2010-01-22 03:34:56 +08008415 * Starts an Activity that lets the user select the multiple phones from a
8416 * list of phone numbers which come from the contacts or
8417 * {@link #EXTRA_PHONE_URIS}.
8418 * <p>
8419 * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS}
8420 * could belong to the contacts or not, and will be selected by default.
8421 * <p>
8422 * The user's selection will be returned from
8423 * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
Fred Quintanaa31a9452010-04-13 14:52:20 -07008424 * if the resultCode is
Bai Taofc7838b2010-01-22 03:34:56 +08008425 * {@link android.app.Activity#RESULT_OK}, the array of picked phone
8426 * numbers are in the Intent's
8427 * {@link #EXTRA_PHONE_URIS}; otherwise, the
8428 * {@link android.app.Activity#RESULT_CANCELED} is returned if the user
8429 * left the Activity without changing the selection.
8430 *
8431 * @hide
8432 */
8433 public static final String ACTION_GET_MULTIPLE_PHONES =
8434 "com.android.contacts.action.GET_MULTIPLE_PHONES";
8435
8436 /**
Makoto Onuki90ddc902012-09-11 18:22:53 -07008437 * A broadcast action which is sent when any change has been made to the profile, such
8438 * as the profile name or the picture. A receiver must have
8439 * the android.permission.READ_PROFILE permission.
8440 *
8441 * @hide
8442 */
8443 public static final String ACTION_PROFILE_CHANGED =
8444 "android.provider.Contacts.PROFILE_CHANGED";
8445
8446 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008447 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
8448 * contact if no matching contact found. Otherwise, default behavior is
8449 * to prompt user with dialog before creating.
8450 * <p>
8451 * Type: BOOLEAN
8452 */
8453 public static final String EXTRA_FORCE_CREATE =
8454 "com.android.contacts.action.FORCE_CREATE";
8455
8456 /**
8457 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
8458 * description to be shown when prompting user about creating a new
8459 * contact.
8460 * <p>
8461 * Type: STRING
8462 */
8463 public static final String EXTRA_CREATE_DESCRIPTION =
8464 "com.android.contacts.action.CREATE_DESCRIPTION";
8465
8466 /**
Bai Taofc7838b2010-01-22 03:34:56 +08008467 * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value.
8468 * <p>
8469 * The phone numbers want to be picked by default should be passed in as
8470 * input value. These phone numbers could belong to the contacts or not.
8471 * <p>
8472 * The phone numbers which were picked by the user are returned as output
8473 * value.
8474 * <p>
8475 * Type: array of URIs, the tel URI is used for the phone numbers which don't
8476 * belong to any contact, the content URI is used for phone id in contacts.
Fred Quintanaa31a9452010-04-13 14:52:20 -07008477 *
Bai Taofc7838b2010-01-22 03:34:56 +08008478 * @hide
8479 */
8480 public static final String EXTRA_PHONE_URIS =
8481 "com.android.contacts.extra.PHONE_URIS";
8482
8483 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07008484 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
8485 * dialog location using screen coordinates. When not specified, the
8486 * dialog will be centered.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008487 *
8488 * @hide
Jeff Sharkey11322002009-06-04 17:25:51 -07008489 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008490 @Deprecated
Jeff Sharkey11322002009-06-04 17:25:51 -07008491 public static final String EXTRA_TARGET_RECT = "target_rect";
8492
8493 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008494 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
8495 * desired dialog style, usually a variation on size. One of
8496 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008497 *
8498 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008499 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008500 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008501 public static final String EXTRA_MODE = "mode";
8502
8503 /**
8504 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008505 *
8506 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008507 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008508 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008509 public static final int MODE_SMALL = 1;
8510
8511 /**
8512 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008513 *
8514 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008515 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008516 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008517 public static final int MODE_MEDIUM = 2;
8518
8519 /**
8520 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008521 *
8522 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008523 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008524 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008525 public static final int MODE_LARGE = 3;
8526
8527 /**
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008528 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
8529 * a list of specific MIME-types to exclude and not display. Stored as a
8530 * {@link String} array.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008531 *
8532 * @hide
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008533 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008534 @Deprecated
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008535 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
8536
8537 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008538 * Intents related to the Contacts app UI.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008539 *
8540 * @hide
Evan Millardc2da5f2009-06-18 16:07:13 -07008541 */
8542 public static final class UI {
8543 /**
8544 * The action for the default contacts list tab.
8545 */
8546 public static final String LIST_DEFAULT =
8547 "com.android.contacts.action.LIST_DEFAULT";
8548
8549 /**
8550 * The action for the contacts list tab.
8551 */
8552 public static final String LIST_GROUP_ACTION =
8553 "com.android.contacts.action.LIST_GROUP";
8554
8555 /**
8556 * When in LIST_GROUP_ACTION mode, this is the group to display.
8557 */
8558 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
8559
8560 /**
8561 * The action for the all contacts list tab.
8562 */
8563 public static final String LIST_ALL_CONTACTS_ACTION =
8564 "com.android.contacts.action.LIST_ALL_CONTACTS";
8565
8566 /**
8567 * The action for the contacts with phone numbers list tab.
8568 */
8569 public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
8570 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
8571
8572 /**
8573 * The action for the starred contacts list tab.
8574 */
8575 public static final String LIST_STARRED_ACTION =
8576 "com.android.contacts.action.LIST_STARRED";
8577
8578 /**
8579 * The action for the frequent contacts list tab.
8580 */
8581 public static final String LIST_FREQUENT_ACTION =
8582 "com.android.contacts.action.LIST_FREQUENT";
8583
8584 /**
Brian Attwelle98a95c2014-07-22 20:53:59 -07008585 * The action for the "Join Contact" picker.
8586 */
8587 public static final String PICK_JOIN_CONTACT_ACTION =
8588 "com.android.contacts.action.JOIN_CONTACT";
8589
8590 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008591 * The action for the "strequent" contacts list tab. It first lists the starred
8592 * contacts in alphabetical order and then the frequent contacts in descending
8593 * order of the number of times they have been contacted.
8594 */
8595 public static final String LIST_STREQUENT_ACTION =
8596 "com.android.contacts.action.LIST_STREQUENT";
8597
8598 /**
8599 * A key for to be used as an intent extra to set the activity
8600 * title to a custom String value.
8601 */
8602 public static final String TITLE_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008603 "com.android.contacts.extra.TITLE_EXTRA";
Evan Millardc2da5f2009-06-18 16:07:13 -07008604
8605 /**
8606 * Activity Action: Display a filtered list of contacts
8607 * <p>
8608 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
8609 * filtering
8610 * <p>
8611 * Output: Nothing.
8612 */
8613 public static final String FILTER_CONTACTS_ACTION =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008614 "com.android.contacts.action.FILTER_CONTACTS";
Evan Millardc2da5f2009-06-18 16:07:13 -07008615
8616 /**
8617 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
8618 * intents to supply the text on which to filter.
8619 */
8620 public static final String FILTER_TEXT_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008621 "com.android.contacts.extra.FILTER_TEXT";
Brian Attwelle98a95c2014-07-22 20:53:59 -07008622
8623 /**
8624 * Used with JOIN_CONTACT action to set the target for aggregation. This action type
8625 * uses contact ids instead of contact uris for the sake of backwards compatibility.
8626 * <p>
8627 * Type: LONG
8628 */
8629 public static final String TARGET_CONTACT_ID_EXTRA_KEY
8630 = "com.android.contacts.action.CONTACT_ID";
Evan Millardc2da5f2009-06-18 16:07:13 -07008631 }
8632
8633 /**
8634 * Convenience class that contains string constants used
8635 * to create contact {@link android.content.Intent Intents}.
8636 */
8637 public static final class Insert {
8638 /** The action code to use when adding a contact */
8639 public static final String ACTION = Intent.ACTION_INSERT;
8640
8641 /**
8642 * If present, forces a bypass of quick insert mode.
8643 */
8644 public static final String FULL_MODE = "full_mode";
8645
8646 /**
8647 * The extra field for the contact name.
8648 * <P>Type: String</P>
8649 */
8650 public static final String NAME = "name";
8651
8652 // TODO add structured name values here.
8653
8654 /**
8655 * The extra field for the contact phonetic name.
8656 * <P>Type: String</P>
8657 */
8658 public static final String PHONETIC_NAME = "phonetic_name";
8659
8660 /**
8661 * The extra field for the contact company.
8662 * <P>Type: String</P>
8663 */
8664 public static final String COMPANY = "company";
8665
8666 /**
8667 * The extra field for the contact job title.
8668 * <P>Type: String</P>
8669 */
8670 public static final String JOB_TITLE = "job_title";
8671
8672 /**
8673 * The extra field for the contact notes.
8674 * <P>Type: String</P>
8675 */
8676 public static final String NOTES = "notes";
8677
8678 /**
8679 * The extra field for the contact phone number.
8680 * <P>Type: String</P>
8681 */
8682 public static final String PHONE = "phone";
8683
8684 /**
8685 * The extra field for the contact phone number type.
8686 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008687 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008688 * or a string specifying a custom label.</P>
8689 */
8690 public static final String PHONE_TYPE = "phone_type";
8691
8692 /**
8693 * The extra field for the phone isprimary flag.
8694 * <P>Type: boolean</P>
8695 */
8696 public static final String PHONE_ISPRIMARY = "phone_isprimary";
8697
8698 /**
8699 * The extra field for an optional second contact phone number.
8700 * <P>Type: String</P>
8701 */
8702 public static final String SECONDARY_PHONE = "secondary_phone";
8703
8704 /**
8705 * The extra field for an optional second contact phone number type.
8706 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008707 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008708 * or a string specifying a custom label.</P>
8709 */
8710 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
8711
8712 /**
8713 * The extra field for an optional third contact phone number.
8714 * <P>Type: String</P>
8715 */
8716 public static final String TERTIARY_PHONE = "tertiary_phone";
8717
8718 /**
8719 * The extra field for an optional third contact phone number type.
8720 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008721 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008722 * or a string specifying a custom label.</P>
8723 */
8724 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
8725
8726 /**
8727 * The extra field for the contact email address.
8728 * <P>Type: String</P>
8729 */
8730 public static final String EMAIL = "email";
8731
8732 /**
8733 * The extra field for the contact email type.
8734 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008735 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008736 * or a string specifying a custom label.</P>
8737 */
8738 public static final String EMAIL_TYPE = "email_type";
8739
8740 /**
8741 * The extra field for the email isprimary flag.
8742 * <P>Type: boolean</P>
8743 */
8744 public static final String EMAIL_ISPRIMARY = "email_isprimary";
8745
8746 /**
8747 * The extra field for an optional second contact email address.
8748 * <P>Type: String</P>
8749 */
8750 public static final String SECONDARY_EMAIL = "secondary_email";
8751
8752 /**
8753 * The extra field for an optional second contact email type.
8754 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008755 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008756 * or a string specifying a custom label.</P>
8757 */
8758 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
8759
8760 /**
8761 * The extra field for an optional third contact email address.
8762 * <P>Type: String</P>
8763 */
8764 public static final String TERTIARY_EMAIL = "tertiary_email";
8765
8766 /**
8767 * The extra field for an optional third contact email type.
8768 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008769 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008770 * or a string specifying a custom label.</P>
8771 */
8772 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
8773
8774 /**
8775 * The extra field for the contact postal address.
8776 * <P>Type: String</P>
8777 */
8778 public static final String POSTAL = "postal";
8779
8780 /**
8781 * The extra field for the contact postal address type.
8782 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008783 * {@link CommonDataKinds.StructuredPostal}
Evan Millardc2da5f2009-06-18 16:07:13 -07008784 * or a string specifying a custom label.</P>
8785 */
8786 public static final String POSTAL_TYPE = "postal_type";
8787
8788 /**
8789 * The extra field for the postal isprimary flag.
8790 * <P>Type: boolean</P>
8791 */
8792 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
8793
8794 /**
8795 * The extra field for an IM handle.
8796 * <P>Type: String</P>
8797 */
8798 public static final String IM_HANDLE = "im_handle";
8799
8800 /**
8801 * The extra field for the IM protocol
Evan Millardc2da5f2009-06-18 16:07:13 -07008802 */
8803 public static final String IM_PROTOCOL = "im_protocol";
8804
8805 /**
8806 * The extra field for the IM isprimary flag.
8807 * <P>Type: boolean</P>
8808 */
8809 public static final String IM_ISPRIMARY = "im_isprimary";
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008810
8811 /**
8812 * The extra field that allows the client to supply multiple rows of
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07008813 * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT}
8814 * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of
8815 * {@link ContentValues}, one per data row. Supplying this extra is
8816 * similar to inserting multiple rows into the {@link Data} table,
8817 * except the user gets a chance to see and edit them before saving.
8818 * Each ContentValues object must have a value for {@link Data#MIMETYPE}.
8819 * If supplied values are not visible in the editor UI, they will be
8820 * dropped. Duplicate data will dropped. Some fields
8821 * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically
8822 * adjusted to comply with the constraints of the specific account type.
8823 * For example, an Exchange contact can only have one phone numbers of type Home,
8824 * so the contact editor may choose a different type for this phone number to
8825 * avoid dropping the valueable part of the row, which is the phone number.
8826 * <p>
8827 * Example:
8828 * <pre>
8829 * ArrayList&lt;ContentValues&gt; data = new ArrayList&lt;ContentValues&gt;();
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008830 *
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07008831 * ContentValues row1 = new ContentValues();
8832 * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE);
8833 * row1.put(Organization.COMPANY, "Android");
8834 * data.add(row1);
8835 *
8836 * ContentValues row2 = new ContentValues();
8837 * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
8838 * row2.put(Email.TYPE, Email.TYPE_CUSTOM);
8839 * row2.put(Email.LABEL, "Green Bot");
8840 * row2.put(Email.ADDRESS, "android@android.com");
8841 * data.add(row2);
8842 *
8843 * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
8844 * intent.putParcelableArrayListExtra(Insert.DATA, data);
8845 *
8846 * startActivity(intent);
8847 * </pre>
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008848 */
8849 public static final String DATA = "data";
Daniel Lehmanncde1ac62010-10-21 20:40:11 -07008850
8851 /**
8852 * Used to specify the account in which to create the new contact.
8853 * <p>
8854 * If this value is not provided, the user is presented with a disambiguation
8855 * dialog to chose an account
8856 * <p>
8857 * Type: {@link Account}
8858 *
8859 * @hide
8860 */
8861 public static final String ACCOUNT = "com.android.contacts.extra.ACCOUNT";
Dave Santoro1d55c332011-07-25 16:44:45 -07008862
8863 /**
8864 * Used to specify the data set within the account in which to create the
8865 * new contact.
8866 * <p>
8867 * This value is optional - if it is not specified, the contact will be
8868 * created in the base account, with no data set.
8869 * <p>
8870 * Type: String
8871 *
8872 * @hide
8873 */
8874 public static final String DATA_SET = "com.android.contacts.extra.DATA_SET";
Evan Millardc2da5f2009-06-18 16:07:13 -07008875 }
8876 }
Evan Millar088b2912009-05-28 15:24:37 -07008877}