blob: 18a9eb1d0e8b2794bcd3283b98afe744cb0ca546 [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 Lee78814622014-09-04 16:07:50 -07001128 * .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "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 */
Yorke Lee78814622014-09-04 16:07:50 -07001143 public static final String EXTRA_ADDRESS_BOOK_INDEX =
1144 "android.provider.extra.ADDRESS_BOOK_INDEX";
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001145
1146 /**
1147 * The array of address book index titles, which are returned in the
1148 * same order as the data in the cursor.
1149 * <p>TYPE: String[]</p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001150 */
Yorke Lee78814622014-09-04 16:07:50 -07001151 public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES =
1152 "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001153
1154 /**
1155 * The array of group counts for the corresponding group. Contains the same number
1156 * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
1157 * <p>TYPE: int[]</p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001158 */
Yorke Lee78814622014-09-04 16:07:50 -07001159 public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS =
1160 "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001161 }
1162
1163 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001164 * Constants for the contacts table, which contains a record per aggregate
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001165 * of raw contacts representing the same person.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001166 * <h3>Operations</h3>
1167 * <dl>
1168 * <dt><b>Insert</b></dt>
1169 * <dd>A Contact cannot be created explicitly. When a raw contact is
1170 * inserted, the provider will first try to find a Contact representing the
1171 * same person. If one is found, the raw contact's
1172 * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
1173 * Contact. If no match is found, the provider automatically inserts a new
1174 * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
1175 * of the newly inserted raw contact.</dd>
1176 * <dt><b>Update</b></dt>
1177 * <dd>Only certain columns of Contact are modifiable:
1178 * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
1179 * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
1180 * these columns on the Contact also changes them on all constituent raw
1181 * contacts.</dd>
1182 * <dt><b>Delete</b></dt>
1183 * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
1184 * deletes all constituent raw contacts. The corresponding sync adapters
1185 * will notice the deletions of their respective raw contacts and remove
1186 * them from their back end storage.</dd>
1187 * <dt><b>Query</b></dt>
1188 * <dd>
1189 * <ul>
1190 * <li>If you need to read an individual contact, consider using
1191 * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
1192 * <li>If you need to look up a contact by the phone number, use
1193 * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
1194 * which is optimized for this purpose.</li>
1195 * <li>If you need to look up a contact by partial name, e.g. to produce
1196 * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
1197 * <li>If you need to look up a contact by some data element like email
1198 * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
1199 * The result will contain contact ID, name etc.
1200 * </ul>
1201 * </dd>
1202 * </dl>
1203 * <h2>Columns</h2>
1204 * <table class="jd-sumtable">
1205 * <tr>
1206 * <th colspan='4'>Contacts</th>
1207 * </tr>
1208 * <tr>
1209 * <td>long</td>
1210 * <td>{@link #_ID}</td>
1211 * <td>read-only</td>
1212 * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
1213 * </tr>
1214 * <tr>
1215 * <td>String</td>
1216 * <td>{@link #LOOKUP_KEY}</td>
1217 * <td>read-only</td>
1218 * <td>An opaque value that contains hints on how to find the contact if its
1219 * row id changed as a result of a sync or aggregation.</td>
1220 * </tr>
1221 * <tr>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001222 * <td>long</td>
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001223 * <td>NAME_RAW_CONTACT_ID</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001224 * <td>read-only</td>
1225 * <td>The ID of the raw contact that contributes the display name
1226 * to the aggregate contact. During aggregation one of the constituent
1227 * raw contacts is chosen using a heuristic: a longer name or a name
1228 * with more diacritic marks or more upper case characters is chosen.</td>
1229 * </tr>
1230 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001231 * <td>String</td>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001232 * <td>DISPLAY_NAME_PRIMARY</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001233 * <td>read-only</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001234 * <td>The display name for the contact. It is the display name
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001235 * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001236 * column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001237 * </tr>
1238 * <tr>
1239 * <td>long</td>
1240 * <td>{@link #PHOTO_ID}</td>
1241 * <td>read-only</td>
1242 * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
1243 * That row has the mime type
1244 * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
1245 * is computed automatically based on the
1246 * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
1247 * that mime type.</td>
1248 * </tr>
1249 * <tr>
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -07001250 * <td>long</td>
1251 * <td>{@link #PHOTO_URI}</td>
1252 * <td>read-only</td>
1253 * <td>A URI that can be used to retrieve the contact's full-size photo. This
1254 * column is the preferred method of retrieving the contact photo.</td>
1255 * </tr>
1256 * <tr>
1257 * <td>long</td>
1258 * <td>{@link #PHOTO_THUMBNAIL_URI}</td>
1259 * <td>read-only</td>
1260 * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This
1261 * column is the preferred method of retrieving the contact photo.</td>
1262 * </tr>
1263 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001264 * <td>int</td>
1265 * <td>{@link #IN_VISIBLE_GROUP}</td>
1266 * <td>read-only</td>
1267 * <td>An indicator of whether this contact is supposed to be visible in the
1268 * UI. "1" if the contact has at least one raw contact that belongs to a
1269 * visible group; "0" otherwise.</td>
1270 * </tr>
1271 * <tr>
1272 * <td>int</td>
1273 * <td>{@link #HAS_PHONE_NUMBER}</td>
1274 * <td>read-only</td>
1275 * <td>An indicator of whether this contact has at least one phone number.
1276 * "1" if there is at least one phone number, "0" otherwise.</td>
1277 * </tr>
1278 * <tr>
1279 * <td>int</td>
1280 * <td>{@link #TIMES_CONTACTED}</td>
1281 * <td>read/write</td>
1282 * <td>The number of times the contact has been contacted. See
1283 * {@link #markAsContacted}. When raw contacts are aggregated, this field is
1284 * computed automatically as the maximum number of times contacted among all
1285 * constituent raw contacts. Setting this field automatically changes the
1286 * corresponding field on all constituent raw contacts.</td>
1287 * </tr>
1288 * <tr>
1289 * <td>long</td>
1290 * <td>{@link #LAST_TIME_CONTACTED}</td>
1291 * <td>read/write</td>
1292 * <td>The timestamp of the last time the contact was contacted. See
1293 * {@link #markAsContacted}. Setting this field also automatically
1294 * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
1295 * this field is computed automatically as the latest time contacted of all
1296 * constituent raw contacts. Setting this field automatically changes the
1297 * corresponding field on all constituent raw contacts.</td>
1298 * </tr>
1299 * <tr>
1300 * <td>int</td>
1301 * <td>{@link #STARRED}</td>
1302 * <td>read/write</td>
1303 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
1304 * When raw contacts are aggregated, this field is automatically computed:
1305 * if any constituent raw contacts are starred, then this field is set to
1306 * '1'. Setting this field automatically changes the corresponding field on
1307 * all constituent raw contacts.</td>
1308 * </tr>
1309 * <tr>
1310 * <td>String</td>
1311 * <td>{@link #CUSTOM_RINGTONE}</td>
1312 * <td>read/write</td>
1313 * <td>A custom ringtone associated with a contact. Typically this is the
1314 * URI returned by an activity launched with the
1315 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
1316 * </tr>
1317 * <tr>
1318 * <td>int</td>
1319 * <td>{@link #SEND_TO_VOICEMAIL}</td>
1320 * <td>read/write</td>
1321 * <td>An indicator of whether calls from this contact should be forwarded
1322 * directly to voice mail ('1') or not ('0'). When raw contacts are
1323 * aggregated, this field is automatically computed: if <i>all</i>
1324 * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
1325 * to '1'. Setting this field automatically changes the corresponding field
1326 * on all constituent raw contacts.</td>
1327 * </tr>
1328 * <tr>
1329 * <td>int</td>
1330 * <td>{@link #CONTACT_PRESENCE}</td>
1331 * <td>read-only</td>
1332 * <td>Contact IM presence status. See {@link StatusUpdates} for individual
1333 * status definitions. Automatically computed as the highest presence of all
1334 * constituent raw contacts. The provider may choose not to store this value
1335 * in persistent storage. The expectation is that presence status will be
kmccormick50e27c82013-03-28 16:33:11 -07001336 * updated on a regular basis.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001337 * </tr>
1338 * <tr>
1339 * <td>String</td>
1340 * <td>{@link #CONTACT_STATUS}</td>
1341 * <td>read-only</td>
1342 * <td>Contact's latest status update. Automatically computed as the latest
1343 * of all constituent raw contacts' status updates.</td>
1344 * </tr>
1345 * <tr>
1346 * <td>long</td>
1347 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
1348 * <td>read-only</td>
1349 * <td>The absolute time in milliseconds when the latest status was
1350 * inserted/updated.</td>
1351 * </tr>
1352 * <tr>
1353 * <td>String</td>
1354 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
1355 * <td>read-only</td>
1356 * <td> The package containing resources for this status: label and icon.</td>
1357 * </tr>
1358 * <tr>
1359 * <td>long</td>
1360 * <td>{@link #CONTACT_STATUS_LABEL}</td>
1361 * <td>read-only</td>
1362 * <td>The resource ID of the label describing the source of contact status,
1363 * e.g. "Google Talk". This resource is scoped by the
1364 * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1365 * </tr>
1366 * <tr>
1367 * <td>long</td>
1368 * <td>{@link #CONTACT_STATUS_ICON}</td>
1369 * <td>read-only</td>
1370 * <td>The resource ID of the icon for the source of contact status. This
1371 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1372 * </tr>
1373 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07001374 */
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07001375 public static class Contacts implements BaseColumns, ContactsColumns,
Yorke Lee94c87612014-07-18 18:57:17 -07001376 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts {
Evan Millar088b2912009-05-28 15:24:37 -07001377 /**
1378 * This utility class cannot be instantiated
1379 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001380 private Contacts() {}
Evan Millar088b2912009-05-28 15:24:37 -07001381
1382 /**
1383 * The content:// style URI for this table
1384 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001385 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
Evan Millar088b2912009-05-28 15:24:37 -07001386
1387 /**
Makoto Onuki31cd6f72014-07-08 15:20:39 -07001388 * Special contacts URI to refer to contacts on the corp profile from the personal
1389 * profile.
1390 *
1391 * It's supported only by a few specific places for referring to contact pictures that
1392 * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from
1393 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI.
1394 *
1395 * @hide
1396 */
1397 public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
1398 "contacts_corp");
1399
1400 /**
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001401 * A content:// style URI for this table that should be used to create
1402 * shortcuts or otherwise create long-term links to contacts. This URI
1403 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
1404 * It can optionally also have a "/" and last known contact ID appended after
1405 * that. This "complete" format is an important optimization and is highly recommended.
1406 * <p>
1407 * As long as the contact's row ID remains the same, this URI is
1408 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
1409 * as a result of a sync or aggregation, this URI will look up the
1410 * contact using indirect information (sync IDs or constituent raw
1411 * contacts).
1412 * <p>
1413 * Lookup key should be appended unencoded - it is stored in the encoded
1414 * form, ready for use in a URI.
1415 */
1416 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1417 "lookup");
1418
1419 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001420 * Base {@link Uri} for referencing a single {@link Contacts} entry,
Jeff Sharkey8f767342009-09-28 18:22:46 -07001421 * created by appending {@link #LOOKUP_KEY} using
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001422 * {@link Uri#withAppendedPath(Uri, String)}. Provides
1423 * {@link OpenableColumns} columns when queried, or returns the
1424 * referenced contact formatted as a vCard when opened through
1425 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1426 */
1427 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1428 "as_vcard");
1429
Martijn Coenen037d3ff2011-06-15 16:01:45 +02001430 /**
1431 * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI}
1432 * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned
1433 * vcard should not contain a photo.
1434 *
1435 * @hide
1436 */
1437 public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "nophoto";
1438
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001439 /**
Daniel Lehmann63e91402010-03-12 13:44:31 -08001440 * Base {@link Uri} for referencing multiple {@link Contacts} entry,
1441 * created by appending {@link #LOOKUP_KEY} using
1442 * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
Yorke Lee217d8a72013-11-27 10:14:04 -08001443 * joined with the colon (":") separator, and the resulting string encoded.
1444 *
1445 * Provides {@link OpenableColumns} columns when queried, or returns the
Daniel Lehmann63e91402010-03-12 13:44:31 -08001446 * referenced contact formatted as a vCard when opened through
1447 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1448 *
Yorke Lee217d8a72013-11-27 10:14:04 -08001449 * <p>
1450 * Usage example:
1451 * <dl>
1452 * <dt>The following code snippet creates a multi-vcard URI that references all the
1453 * contacts in a user's database.</dt>
1454 * <dd>
Daniel Lehmann63e91402010-03-12 13:44:31 -08001455 *
Yorke Lee217d8a72013-11-27 10:14:04 -08001456 * <pre>
1457 * public Uri getAllContactsVcardUri() {
1458 * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI,
1459 * new String[] {Contacts.LOOKUP_KEY}, null, null, null);
1460 * if (cursor == null) {
1461 * return null;
1462 * }
1463 * try {
1464 * StringBuilder uriListBuilder = new StringBuilder();
1465 * int index = 0;
1466 * while (cursor.moveToNext()) {
1467 * if (index != 0) uriListBuilder.append(':');
1468 * uriListBuilder.append(cursor.getString(0));
1469 * index++;
1470 * }
1471 * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI,
1472 * Uri.encode(uriListBuilder.toString()));
1473 * } finally {
1474 * cursor.close();
1475 * }
1476 * }
1477 * </pre>
1478 *
1479 * </p>
Daniel Lehmann63e91402010-03-12 13:44:31 -08001480 */
1481 public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1482 "as_multi_vcard");
1483
1484 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001485 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
1486 * requested {@link Contacts} entry.
1487 *
1488 * @param contactUri A {@link #CONTENT_URI} row, or an existing
1489 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001490 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001491 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
1492 final Cursor c = resolver.query(contactUri, new String[] {
1493 Contacts.LOOKUP_KEY, Contacts._ID
1494 }, null, null, null);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001495 if (c == null) {
1496 return null;
1497 }
1498
1499 try {
1500 if (c.moveToFirst()) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001501 final String lookupKey = c.getString(0);
1502 final long contactId = c.getLong(1);
1503 return getLookupUri(contactId, lookupKey);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001504 }
1505 } finally {
1506 c.close();
1507 }
1508 return null;
1509 }
1510
1511 /**
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001512 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001513 * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001514 */
1515 public static Uri getLookupUri(long contactId, String lookupKey) {
1516 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
1517 lookupKey), contactId);
1518 }
1519
1520 /**
Dmitri Plotnikovb5759b52009-09-01 15:58:40 -07001521 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
1522 * <p>
1523 * Returns null if the contact cannot be found.
1524 */
1525 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
1526 if (lookupUri == null) {
1527 return null;
1528 }
1529
1530 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
1531 if (c == null) {
1532 return null;
1533 }
1534
1535 try {
1536 if (c.moveToFirst()) {
1537 long contactId = c.getLong(0);
1538 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1539 }
1540 } finally {
1541 c.close();
1542 }
1543 return null;
1544 }
1545
1546 /**
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001547 * Mark a contact as having been contacted. Updates two fields:
1548 * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The
1549 * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED
1550 * field is populated with the current system time.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001551 *
1552 * @param resolver the ContentResolver to use
1553 * @param contactId the person who was contacted
Daniel Lehmanna1620dc2012-04-13 13:29:49 -07001554 *
1555 * @deprecated The class DataUsageStatUpdater of the Android support library should
1556 * be used instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001557 */
Daniel Lehmanna1620dc2012-04-13 13:29:49 -07001558 @Deprecated
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001559 public static void markAsContacted(ContentResolver resolver, long contactId) {
1560 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
1561 ContentValues values = new ContentValues();
1562 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
1563 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
1564 resolver.update(uri, values, null, null);
1565 }
1566
1567 /**
Evan Millar161dd862009-06-12 16:02:43 -07001568 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001569 * {@link #CONTENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001570 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -07001571 * as an additional path segment after this URI.
1572 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001573 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
1574 CONTENT_URI, "filter");
1575
Evan Millardc2da5f2009-06-18 16:07:13 -07001576 /**
1577 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001578 * {@link ContactsContract.Data}, filtered to include only starred contacts
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001579 * and the most frequently contacted contacts.
Evan Millardc2da5f2009-06-18 16:07:13 -07001580 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001581 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
1582 CONTENT_URI, "strequent");
1583
Evan Millardc2da5f2009-06-18 16:07:13 -07001584 /**
Yorke Lee8d370092014-06-26 10:32:17 -07001585 * The content:// style URI for showing a list of frequently contacted people.
Daisuke Miyakawa3604bc52011-07-21 10:14:32 -07001586 */
1587 public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath(
1588 CONTENT_URI, "frequent");
1589
1590 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07001591 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001592 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001593 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -07001594 * as an additional path segment after this URI.
1595 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001596 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
1597 CONTENT_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001598
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001599 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
1600 CONTENT_URI, "group");
1601
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001602 /**
Evan Millar088b2912009-05-28 15:24:37 -07001603 * The MIME type of {@link #CONTENT_URI} providing a directory of
1604 * people.
1605 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001606 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001607
1608 /**
1609 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1610 * person.
1611 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001612 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001613
1614 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001615 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1616 * person.
1617 */
1618 public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
1619
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001620
1621 /**
1622 * Mimimal ID for corp contacts returned from
1623 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
1624 *
1625 * @hide
1626 */
Makoto Onuki0e917332014-08-26 14:06:30 -07001627 public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001628
1629 /**
Makoto Onuki0e917332014-08-26 14:06:30 -07001630 * Return TRUE if a contact ID is from the contacts provider on the enterprise profile.
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001631 *
1632 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact.
1633 */
Makoto Onuki0e917332014-08-26 14:06:30 -07001634 public static boolean isEnterpriseContactId(long contactId) {
1635 return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001636 }
1637
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001638 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001639 * A sub-directory of a single contact that contains all of the constituent raw contact
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001640 * {@link ContactsContract.Data} rows. This directory can be used either
1641 * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07001642 */
Fred Quintana8851e162009-08-05 21:06:45 -07001643 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07001644 /**
1645 * no public constructor since this is a utility class
1646 */
1647 private Data() {}
1648
1649 /**
1650 * The directory twig for this sub-table
1651 */
1652 public static final String CONTENT_DIRECTORY = "data";
1653 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001654
1655 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001656 * <p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001657 * A sub-directory of a contact that contains all of its
1658 * {@link ContactsContract.RawContacts} as well as
1659 * {@link ContactsContract.Data} rows. To access this directory append
1660 * {@link #CONTENT_DIRECTORY} to the contact URI.
1661 * </p>
1662 * <p>
1663 * Entity has three ID fields: {@link #CONTACT_ID} for the contact,
1664 * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for
1665 * the data rows. Entity always contains at least one row per
1666 * constituent raw contact, even if there are no actual data rows. In
1667 * this case the {@link #DATA_ID} field will be null.
1668 * </p>
1669 * <p>
1670 * Entity reads all data for the entire contact in one transaction, to
1671 * guarantee consistency. There is significant data duplication
1672 * in the Entity (each row repeats all Contact columns and all RawContact
1673 * columns), so the benefits of transactional consistency should be weighed
1674 * against the cost of transferring large amounts of denormalized data
1675 * from the Provider.
1676 * </p>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07001677 * <p>
1678 * To reduce the amount of data duplication the contacts provider and directory
1679 * providers implementing this protocol are allowed to provide common Contacts
1680 * and RawContacts fields in the first row returned for each raw contact only and
1681 * leave them as null in subsequent rows.
1682 * </p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001683 */
1684 public static final class Entity implements BaseColumns, ContactsColumns,
1685 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns,
Paul Soulos42cdda82014-06-19 16:13:38 -07001686 StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns {
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001687 /**
1688 * no public constructor since this is a utility class
1689 */
1690 private Entity() {
1691 }
1692
1693 /**
1694 * The directory twig for this sub-table
1695 */
1696 public static final String CONTENT_DIRECTORY = "entities";
1697
1698 /**
1699 * The ID of the raw contact row.
1700 * <P>Type: INTEGER</P>
1701 */
1702 public static final String RAW_CONTACT_ID = "raw_contact_id";
1703
1704 /**
1705 * The ID of the data row. The value will be null if this raw contact has no
1706 * data rows.
1707 * <P>Type: INTEGER</P>
1708 */
1709 public static final String DATA_ID = "data_id";
1710 }
1711
1712 /**
Dave Santoro0b61f592011-10-03 18:25:26 -07001713 * <p>
Dave Santorod414f102011-06-20 14:35:06 -07001714 * A sub-directory of a single contact that contains all of the constituent raw contact
1715 * {@link ContactsContract.StreamItems} rows. This directory can be used either
1716 * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
Dave Santoro0b61f592011-10-03 18:25:26 -07001717 * </p>
1718 * <p>
1719 * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM
1720 * permission.
1721 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07001722 *
1723 * @deprecated - Do not use. This will not be supported in the future. In the future,
1724 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001725 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001726 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001727 public static final class StreamItems implements StreamItemsColumns {
1728 /**
1729 * no public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07001730 *
1731 * @deprecated - Do not use. This will not be supported in the future. In the future,
1732 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001733 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001734 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001735 private StreamItems() {}
1736
1737 /**
1738 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07001739 *
1740 * @deprecated - Do not use. This will not be supported in the future. In the future,
1741 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001742 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001743 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001744 public static final String CONTENT_DIRECTORY = "stream_items";
1745 }
1746
1747 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001748 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001749 * A <i>read-only</i> sub-directory of a single contact aggregate that
1750 * contains all aggregation suggestions (other contacts). The
1751 * aggregation suggestions are computed based on approximate data
1752 * matches with this contact.
1753 * </p>
1754 * <p>
1755 * <i>Note: this query may be expensive! If you need to use it in bulk,
1756 * make sure the user experience is acceptable when the query runs for a
1757 * long time.</i>
1758 * <p>
1759 * Usage example:
1760 *
1761 * <pre>
1762 * Uri uri = Contacts.CONTENT_URI.buildUpon()
1763 * .appendEncodedPath(String.valueOf(contactId))
1764 * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
1765 * .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
1766 * .build()
1767 * Cursor cursor = getContentResolver().query(suggestionsUri,
1768 * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
1769 * null, null, null);
1770 * </pre>
1771 *
1772 * </p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001773 * <p>
1774 * This directory can be used either with a {@link #CONTENT_URI} or
1775 * {@link #CONTENT_LOOKUP_URI}.
1776 * </p>
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001777 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001778 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns,
1779 ContactOptionsColumns, ContactStatusColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001780 /**
1781 * No public constructor since this is a utility class
1782 */
1783 private AggregationSuggestions() {}
1784
1785 /**
Dmitri Plotnikov0fc02442009-09-21 13:26:28 -07001786 * The directory twig for this sub-table. The URI can be followed by an optional
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001787 * type-to-filter, similar to
1788 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001789 */
1790 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001791
1792 /**
1793 * Used with {@link Builder#addParameter} to specify what kind of data is
1794 * supplied for the suggestion query.
1795 *
1796 * @hide
1797 */
1798 public static final String PARAMETER_MATCH_NAME = "name";
1799
1800 /**
1801 * Used with {@link Builder#addParameter} to specify what kind of data is
1802 * supplied for the suggestion query.
1803 *
1804 * @hide
1805 */
1806 public static final String PARAMETER_MATCH_EMAIL = "email";
1807
1808 /**
1809 * Used with {@link Builder#addParameter} to specify what kind of data is
1810 * supplied for the suggestion query.
1811 *
1812 * @hide
1813 */
1814 public static final String PARAMETER_MATCH_PHONE = "phone";
1815
1816 /**
1817 * Used with {@link Builder#addParameter} to specify what kind of data is
1818 * supplied for the suggestion query.
1819 *
1820 * @hide
1821 */
1822 public static final String PARAMETER_MATCH_NICKNAME = "nickname";
1823
1824 /**
1825 * A convenience builder for aggregation suggestion content URIs.
1826 *
1827 * TODO: change documentation for this class to use the builder.
1828 * @hide
1829 */
1830 public static final class Builder {
1831 private long mContactId;
1832 private ArrayList<String> mKinds = new ArrayList<String>();
1833 private ArrayList<String> mValues = new ArrayList<String>();
1834 private int mLimit;
1835
1836 /**
1837 * Optional existing contact ID. If it is not provided, the search
1838 * will be based exclusively on the values supplied with {@link #addParameter}.
1839 */
1840 public Builder setContactId(long contactId) {
1841 this.mContactId = contactId;
1842 return this;
1843 }
1844
1845 /**
1846 * A value that can be used when searching for an aggregation
1847 * suggestion.
1848 *
1849 * @param kind can be one of
1850 * {@link AggregationSuggestions#PARAMETER_MATCH_NAME},
1851 * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL},
1852 * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME},
1853 * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE}
1854 */
1855 public Builder addParameter(String kind, String value) {
1856 if (!TextUtils.isEmpty(value)) {
1857 mKinds.add(kind);
1858 mValues.add(value);
1859 }
1860 return this;
1861 }
1862
1863 public Builder setLimit(int limit) {
1864 mLimit = limit;
1865 return this;
1866 }
1867
1868 public Uri build() {
1869 android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon();
1870 builder.appendEncodedPath(String.valueOf(mContactId));
1871 builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY);
1872 if (mLimit != 0) {
1873 builder.appendQueryParameter("limit", String.valueOf(mLimit));
1874 }
1875
1876 int count = mKinds.size();
1877 for (int i = 0; i < count; i++) {
1878 builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i));
1879 }
1880
1881 return builder.build();
1882 }
1883 }
1884
1885 /**
1886 * @hide
1887 */
1888 public static final Builder builder() {
1889 return new Builder();
1890 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001891 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001892
1893 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001894 * A <i>read-only</i> sub-directory of a single contact that contains
Dave Santoroa5282372011-06-29 00:25:16 -07001895 * the contact's primary photo. The photo may be stored in up to two ways -
1896 * the default "photo" is a thumbnail-sized image stored directly in the data
1897 * row, while the "display photo", if present, is a larger version stored as
1898 * a file.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001899 * <p>
1900 * Usage example:
Dave Santoroa5282372011-06-29 00:25:16 -07001901 * <dl>
1902 * <dt>Retrieving the thumbnail-sized photo</dt>
1903 * <dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001904 * <pre>
1905 * public InputStream openPhoto(long contactId) {
1906 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1907 * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
1908 * Cursor cursor = getContentResolver().query(photoUri,
1909 * new String[] {Contacts.Photo.PHOTO}, null, null, null);
1910 * if (cursor == null) {
1911 * return null;
1912 * }
1913 * try {
1914 * if (cursor.moveToFirst()) {
1915 * byte[] data = cursor.getBlob(0);
1916 * if (data != null) {
1917 * return new ByteArrayInputStream(data);
1918 * }
1919 * }
1920 * } finally {
1921 * cursor.close();
1922 * }
1923 * return null;
1924 * }
1925 * </pre>
Dave Santoroa5282372011-06-29 00:25:16 -07001926 * </dd>
1927 * <dt>Retrieving the larger photo version</dt>
1928 * <dd>
1929 * <pre>
1930 * public InputStream openDisplayPhoto(long contactId) {
1931 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1932 * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
1933 * try {
1934 * AssetFileDescriptor fd =
Dave Santoro040e6b32011-07-15 15:14:08 -07001935 * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
Dave Santoroa5282372011-06-29 00:25:16 -07001936 * return fd.createInputStream();
Dave Santoro040e6b32011-07-15 15:14:08 -07001937 * } catch (IOException e) {
Dave Santoroa5282372011-06-29 00:25:16 -07001938 * return null;
1939 * }
1940 * }
1941 * </pre>
1942 * </dd>
1943 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001944 *
1945 * </p>
Dave Santoroa5282372011-06-29 00:25:16 -07001946 * <p>You may also consider using the convenience method
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001947 * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)}
1948 * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001949 * </p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001950 * <p>
1951 * This directory can be used either with a {@link #CONTENT_URI} or
1952 * {@link #CONTENT_LOOKUP_URI}.
1953 * </p>
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001954 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001955 public static final class Photo implements BaseColumns, DataColumnsWithJoins {
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001956 /**
1957 * no public constructor since this is a utility class
1958 */
1959 private Photo() {}
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07001960
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001961 /**
1962 * The directory twig for this sub-table
1963 */
1964 public static final String CONTENT_DIRECTORY = "photo";
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001965
1966 /**
Dave Santoroa5282372011-06-29 00:25:16 -07001967 * The directory twig for retrieving the full-size display photo.
1968 */
1969 public static final String DISPLAY_PHOTO = "display_photo";
1970
1971 /**
1972 * Full-size photo file ID of the raw contact.
1973 * See {@link ContactsContract.DisplayPhoto}.
1974 * <p>
1975 * Type: NUMBER
1976 */
1977 public static final String PHOTO_FILE_ID = DATA14;
1978
1979 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001980 * Thumbnail photo of the raw contact. This is the raw bytes of an image
1981 * that could be inflated using {@link android.graphics.BitmapFactory}.
1982 * <p>
1983 * Type: BLOB
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001984 */
1985 public static final String PHOTO = DATA15;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001986 }
1987
1988 /**
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001989 * Opens an InputStream for the contacts's photo and returns the
1990 * photo as a byte stream.
1991 * @param cr The content resolver to use for querying
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001992 * @param contactUri the contact whose photo should be used. This can be used with
1993 * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001994 * @param preferHighres If this is true and the contact has a higher resolution photo
1995 * available, it is returned. If false, this function always tries to get the thumbnail
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001996 * @return an InputStream of the photo, or null if no photo is present
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001997 */
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001998 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri,
1999 boolean preferHighres) {
2000 if (preferHighres) {
2001 final Uri displayPhotoUri = Uri.withAppendedPath(contactUri,
2002 Contacts.Photo.DISPLAY_PHOTO);
2003 InputStream inputStream;
2004 try {
2005 AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r");
2006 return fd.createInputStream();
2007 } catch (IOException e) {
2008 // fallback to the thumbnail code
2009 }
2010 }
2011
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07002012 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07002013 if (photoUri == null) {
2014 return null;
2015 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002016 Cursor cursor = cr.query(photoUri,
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002017 new String[] {
2018 ContactsContract.CommonDataKinds.Photo.PHOTO
2019 }, null, null, null);
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002020 try {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07002021 if (cursor == null || !cursor.moveToNext()) {
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002022 return null;
2023 }
2024 byte[] data = cursor.getBlob(0);
2025 if (data == null) {
2026 return null;
2027 }
2028 return new ByteArrayInputStream(data);
2029 } finally {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07002030 if (cursor != null) {
2031 cursor.close();
2032 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002033 }
2034 }
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002035
2036 /**
2037 * Opens an InputStream for the contacts's thumbnail photo and returns the
2038 * photo as a byte stream.
2039 * @param cr The content resolver to use for querying
2040 * @param contactUri the contact whose photo should be used. This can be used with
2041 * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
2042 * @return an InputStream of the photo, or null if no photo is present
2043 * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead
2044 * of the thumbnail the high-res picture is preferred
2045 */
2046 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
2047 return openContactPhotoInputStream(cr, contactUri, false);
2048 }
Evan Millar088b2912009-05-28 15:24:37 -07002049 }
2050
Dave Santoro43251332011-05-11 11:39:54 -07002051 /**
2052 * <p>
2053 * Constants for the user's profile data, which is represented as a single contact on
2054 * the device that represents the user. The profile contact is not aggregated
2055 * together automatically in the same way that normal contacts are; instead, each
Dave Santoro063084e2011-08-23 15:42:49 -07002056 * account (including data set, if applicable) on the device may contribute a single
2057 * raw contact representing the user's personal profile data from that source.
Dave Santoro43251332011-05-11 11:39:54 -07002058 * </p>
2059 * <p>
2060 * Access to the profile entry through these URIs (or incidental access to parts of
2061 * the profile if retrieved directly via ID) requires additional permissions beyond
2062 * the read/write contact permissions required by the provider. Querying for profile
2063 * data requires android.permission.READ_PROFILE permission, and inserting or
2064 * updating profile data requires android.permission.WRITE_PROFILE permission.
2065 * </p>
2066 * <h3>Operations</h3>
2067 * <dl>
2068 * <dt><b>Insert</b></dt>
2069 * <dd>The user's profile entry cannot be created explicitly (attempting to do so
2070 * will throw an exception). When a raw contact is inserted into the profile, the
2071 * provider will check for the existence of a profile on the device. If one is
2072 * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of
2073 * the profile Contact. If no match is found, the profile Contact is created and
2074 * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly
2075 * inserted raw contact.</dd>
2076 * <dt><b>Update</b></dt>
2077 * <dd>The profile Contact has the same update restrictions as Contacts in general,
2078 * but requires the android.permission.WRITE_PROFILE permission.</dd>
2079 * <dt><b>Delete</b></dt>
2080 * <dd>The profile Contact cannot be explicitly deleted. It will be removed
2081 * automatically if all of its constituent raw contact entries are deleted.</dd>
2082 * <dt><b>Query</b></dt>
2083 * <dd>
2084 * <ul>
2085 * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as
2086 * retrieving a contact by ID, except that it will only ever return the user's
2087 * profile contact.
2088 * </li>
2089 * <li>
2090 * The profile contact supports all of the same sub-paths as an individual contact
2091 * does - the content of the profile contact can be retrieved as entities or
2092 * data rows. Similarly, specific raw contact entries can be retrieved by appending
2093 * the desired raw contact ID within the profile.
2094 * </li>
2095 * </ul>
2096 * </dd>
2097 * </dl>
2098 */
2099 public static final class Profile implements BaseColumns, ContactsColumns,
2100 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
2101 /**
2102 * This utility class cannot be instantiated
2103 */
2104 private Profile() {
2105 }
2106
2107 /**
2108 * The content:// style URI for this table, which requests the contact entry
2109 * representing the user's personal profile data.
2110 */
2111 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile");
2112
2113 /**
2114 * {@link Uri} for referencing the user's profile {@link Contacts} entry,
2115 * Provides {@link OpenableColumns} columns when queried, or returns the
2116 * user's profile contact formatted as a vCard when opened through
2117 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
2118 */
2119 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
2120 "as_vcard");
2121
2122 /**
2123 * {@link Uri} for referencing the raw contacts that make up the user's profile
2124 * {@link Contacts} entry. An individual raw contact entry within the profile
2125 * can be addressed by appending the raw contact ID. The entities or data within
2126 * that specific raw contact can be requested by appending the entity or data
2127 * path as well.
2128 */
2129 public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI,
2130 "raw_contacts");
Dave Santoro063084e2011-08-23 15:42:49 -07002131
2132 /**
2133 * The minimum ID for any entity that belongs to the profile. This essentially
2134 * defines an ID-space in which profile data is stored, and is used by the provider
2135 * to determine whether a request via a non-profile-specific URI should be directed
2136 * to the profile data rather than general contacts data, along with all the special
2137 * permission checks that entails.
2138 *
2139 * Callers may use {@link #isProfileId} to check whether a specific ID falls into
2140 * the set of data intended for the profile.
2141 */
2142 public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE;
2143 }
2144
2145 /**
2146 * This method can be used to identify whether the given ID is associated with profile
2147 * data. It does not necessarily indicate that the ID is tied to valid data, merely
2148 * that accessing data using this ID will result in profile access checks and will only
2149 * return data from the profile.
2150 *
2151 * @param id The ID to check.
2152 * @return Whether the ID is associated with profile data.
2153 */
2154 public static boolean isProfileId(long id) {
2155 return id >= Profile.MIN_ID;
Dave Santoro43251332011-05-11 11:39:54 -07002156 }
2157
Chiao Cheng2355d132013-03-20 16:54:06 -07002158 protected interface DeletedContactsColumns {
2159
2160 /**
2161 * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted.
2162 * <P>Type: INTEGER</P>
2163 */
2164 public static final String CONTACT_ID = "contact_id";
2165
2166 /**
2167 * Time (milliseconds since epoch) that the contact was deleted.
2168 */
2169 public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp";
2170 }
2171
2172 /**
2173 * Constants for the deleted contact table. This table holds a log of deleted contacts.
2174 * <p>
2175 * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted.
2176 */
2177 public static final class DeletedContacts implements DeletedContactsColumns {
2178
2179 /**
2180 * This utility class cannot be instantiated
2181 */
2182 private DeletedContacts() {
2183 }
2184
2185 /**
2186 * The content:// style URI for this table, which requests a directory of raw contact rows
2187 * matching the selection criteria.
2188 */
2189 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
2190 "deleted_contacts");
2191
2192 /**
2193 * Number of days that the delete log will be kept. After this time, delete records may be
2194 * deleted.
2195 *
2196 * @hide
2197 */
2198 private static final int DAYS_KEPT = 30;
2199
2200 /**
2201 * Milliseconds that the delete log will be kept. After this time, delete records may be
2202 * deleted.
2203 */
2204 public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT;
2205 }
2206
2207
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07002208 protected interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002209 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002210 * A reference to the {@link ContactsContract.Contacts#_ID} that this
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002211 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002212 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -07002213 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002214 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -07002215
2216 /**
Dave Santorod7bdc182011-06-24 15:39:39 -07002217 * The data set within the account that this row belongs to. This allows
2218 * multiple sync adapters for the same account type to distinguish between
2219 * each others' data.
2220 *
2221 * This is empty by default, and is completely optional. It only needs to
2222 * be populated if multiple sync adapters are entering distinct data for
2223 * the same account type and account name.
2224 * <P>Type: TEXT</P>
2225 */
2226 public static final String DATA_SET = "data_set";
2227
2228 /**
Dave Santoro1d55c332011-07-25 16:44:45 -07002229 * A concatenation of the account type and data set (delimited by a forward
2230 * slash) - if the data set is empty, this will be the same as the account
2231 * type. For applications that need to be aware of the data set, this can
2232 * be used instead of account type to distinguish sets of data. This is
2233 * never intended to be used for specifying accounts.
Makoto Onuki0e917332014-08-26 14:06:30 -07002234 * <p>
2235 * This column does *not* escape forward slashes in the account type or the data set.
2236 * If this is an issue, consider using
2237 * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and
2238 * {@link ContactsContract.RawContacts#DATA_SET} directly.
Dave Santoro1d55c332011-07-25 16:44:45 -07002239 */
2240 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
2241
2242 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002243 * The aggregation mode for this contact.
2244 * <P>Type: INTEGER</P>
2245 */
2246 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002247
2248 /**
2249 * The "deleted" flag: "0" by default, "1" if the row has been marked
2250 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002251 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002252 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002253 * then calls ContactResolver.delete once more, this time passing the
Fred Quintana33f889a2009-09-14 17:31:26 -07002254 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2255 * the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002256 * <P>Type: INTEGER</P>
2257 */
2258 public static final String DELETED = "deleted";
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002259
2260 /**
2261 * The "name_verified" flag: "1" means that the name fields on this raw
2262 * contact can be trusted and therefore should be used for the entire
2263 * aggregated contact.
2264 * <p>
2265 * If an aggregated contact contains more than one raw contact with a
2266 * verified name, one of those verified names is chosen at random.
2267 * If an aggregated contact contains no verified names, the
2268 * name is chosen randomly from the constituent raw contacts.
2269 * </p>
2270 * <p>
2271 * Updating this flag from "0" to "1" automatically resets it to "0" on
2272 * all other raw contacts in the same aggregated contact.
2273 * </p>
2274 * <p>
2275 * Sync adapters should only specify a value for this column when
2276 * inserting a raw contact and leave it out when doing an update.
2277 * </p>
2278 * <p>
2279 * The default value is "0"
2280 * </p>
2281 * <p>Type: INTEGER</p>
Yorke Leeb31c8ab2014-08-26 17:13:02 -07002282 *
2283 * @hide
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002284 */
2285 public static final String NAME_VERIFIED = "name_verified";
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07002286
2287 /**
2288 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
2289 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
2290 * <P>Type: INTEGER</P>
2291 */
Dmitri Plotnikov86fe8392010-07-16 11:19:46 -07002292 public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
Dave Santoro43251332011-05-11 11:39:54 -07002293
2294 /**
2295 * Flag that reflects whether this raw contact belongs to the user's
2296 * personal profile entry.
2297 */
2298 public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002299 }
2300
2301 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002302 * Constants for the raw contacts table, which contains one row of contact
2303 * information for each person in each synced account. Sync adapters and
2304 * contact management apps
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002305 * are the primary consumers of this API.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002306 *
2307 * <h3>Aggregation</h3>
2308 * <p>
2309 * As soon as a raw contact is inserted or whenever its constituent data
2310 * changes, the provider will check if the raw contact matches other
2311 * existing raw contacts and if so will aggregate it with those. The
2312 * aggregation is reflected in the {@link RawContacts} table by the change of the
2313 * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
2314 * </p>
2315 * <p>
2316 * Changes to the structured name, organization, phone number, email address,
2317 * or nickname trigger a re-aggregation.
2318 * </p>
2319 * <p>
2320 * See also {@link AggregationExceptions} for a mechanism to control
2321 * aggregation programmatically.
2322 * </p>
2323 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002324 * <h3>Operations</h3>
2325 * <dl>
2326 * <dt><b>Insert</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002327 * <dd>
2328 * <p>
2329 * Raw contacts can be inserted incrementally or in a batch.
2330 * The incremental method is more traditional but less efficient.
2331 * It should be used
2332 * only if no {@link Data} values are available at the time the raw contact is created:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002333 * <pre>
2334 * ContentValues values = new ContentValues();
2335 * values.put(RawContacts.ACCOUNT_TYPE, accountType);
2336 * values.put(RawContacts.ACCOUNT_NAME, accountName);
2337 * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
2338 * long rawContactId = ContentUris.parseId(rawContactUri);
2339 * </pre>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002340 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002341 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002342 * Once {@link Data} values become available, insert those.
2343 * For example, here's how you would insert a name:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002344 *
2345 * <pre>
2346 * values.clear();
2347 * values.put(Data.RAW_CONTACT_ID, rawContactId);
2348 * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
2349 * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
2350 * getContentResolver().insert(Data.CONTENT_URI, values);
2351 * </pre>
2352 * </p>
2353 * <p>
2354 * The batch method is by far preferred. It inserts the raw contact and its
2355 * constituent data rows in a single database transaction
2356 * and causes at most one aggregation pass.
2357 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07002358 * ArrayList&lt;ContentProviderOperation&gt; ops =
2359 * new ArrayList&lt;ContentProviderOperation&gt;();
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002360 * ...
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002361 * int rawContactInsertIndex = ops.size();
2362 * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
2363 * .withValue(RawContacts.ACCOUNT_TYPE, accountType)
2364 * .withValue(RawContacts.ACCOUNT_NAME, accountName)
2365 * .build());
2366 *
2367 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
2368 * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
2369 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
2370 * .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
2371 * .build());
2372 *
2373 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2374 * </pre>
2375 * </p>
2376 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002377 * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
2378 * to refer to the as-yet-unknown index value of the raw contact inserted in the
2379 * first operation.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002380 * </p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002381 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002382 * <dt><b>Update</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002383 * <dd><p>
2384 * Raw contacts can be updated incrementally or in a batch.
2385 * Batch mode should be used whenever possible.
2386 * The procedures and considerations are analogous to those documented above for inserts.
2387 * </p></dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002388 * <dt><b>Delete</b></dt>
2389 * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
2390 * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002391 * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
2392 * itself is also deleted automatically.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002393 * </p>
2394 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002395 * The invocation of {@code resolver.delete(...)}, does not immediately delete
2396 * a raw contacts row.
2397 * Instead, it sets the {@link #DELETED} flag on the raw contact and
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002398 * removes the raw contact from its aggregate contact.
2399 * The sync adapter then deletes the raw contact from the server and
2400 * finalizes phone-side deletion by calling {@code resolver.delete(...)}
Fred Quintana328c0e72009-12-07 14:52:28 -08002401 * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002402 * <p>Some sync adapters are read-only, meaning that they only sync server-side
2403 * changes to the phone, but not the reverse. If one of those raw contacts
2404 * is marked for deletion, it will remain on the phone. However it will be
2405 * effectively invisible, because it will not be part of any aggregate contact.
2406 * </dd>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002407 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002408 * <dt><b>Query</b></dt>
2409 * <dd>
2410 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002411 * It is easy to find all raw contacts in a Contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002412 * <pre>
2413 * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
2414 * new String[]{RawContacts._ID},
2415 * RawContacts.CONTACT_ID + "=?",
2416 * new String[]{String.valueOf(contactId)}, null);
2417 * </pre>
2418 * </p>
2419 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002420 * To find raw contacts within a specific account,
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002421 * you can either put the account name and type in the selection or pass them as query
2422 * parameters. The latter approach is preferable, especially when you can reuse the
2423 * URI:
2424 * <pre>
Adam Koch95e5a072013-05-21 09:47:55 -04002425 * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002426 * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
2427 * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
2428 * .build();
2429 * Cursor c1 = getContentResolver().query(rawContactUri,
2430 * RawContacts.STARRED + "&lt;&gt;0", null, null, null);
2431 * ...
2432 * Cursor c2 = getContentResolver().query(rawContactUri,
2433 * RawContacts.DELETED + "&lt;&gt;0", null, null, null);
2434 * </pre>
2435 * </p>
2436 * <p>The best way to read a raw contact along with all the data associated with it is
2437 * by using the {@link Entity} directory. If the raw contact has data rows,
2438 * the Entity cursor will contain a row for each data row. If the raw contact has no
2439 * data rows, the cursor will still contain one row with the raw contact-level information.
2440 * <pre>
2441 * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
2442 * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
2443 * Cursor c = getContentResolver().query(entityUri,
2444 * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
2445 * null, null, null);
2446 * try {
2447 * while (c.moveToNext()) {
2448 * String sourceId = c.getString(0);
2449 * if (!c.isNull(1)) {
2450 * String mimeType = c.getString(2);
2451 * String data = c.getString(3);
2452 * ...
2453 * }
2454 * }
2455 * } finally {
2456 * c.close();
2457 * }
2458 * </pre>
2459 * </p>
2460 * </dd>
2461 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002462 * <h2>Columns</h2>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002463 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002464 * <table class="jd-sumtable">
2465 * <tr>
2466 * <th colspan='4'>RawContacts</th>
2467 * </tr>
2468 * <tr>
2469 * <td>long</td>
2470 * <td>{@link #_ID}</td>
2471 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002472 * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
2473 * it is much better for a sync adapter to update a raw contact rather than to delete and
2474 * re-insert it.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002475 * </tr>
2476 * <tr>
2477 * <td>long</td>
2478 * <td>{@link #CONTACT_ID}</td>
2479 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002480 * <td>The ID of the row in the {@link ContactsContract.Contacts} table
2481 * that this raw contact belongs
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002482 * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
2483 * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
2484 * </tr>
2485 * <tr>
2486 * <td>int</td>
2487 * <td>{@link #AGGREGATION_MODE}</td>
2488 * <td>read/write</td>
2489 * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
2490 * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
2491 * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
2492 * </tr>
2493 * <tr>
2494 * <td>int</td>
2495 * <td>{@link #DELETED}</td>
2496 * <td>read/write</td>
2497 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
2498 * for deletion. When {@link android.content.ContentResolver#delete} is
2499 * called on a raw contact, it is marked for deletion and removed from its
2500 * aggregate contact. The sync adaptor deletes the raw contact on the server and
2501 * then calls ContactResolver.delete once more, this time passing the
2502 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2503 * the data removal.</td>
2504 * </tr>
2505 * <tr>
2506 * <td>int</td>
2507 * <td>{@link #TIMES_CONTACTED}</td>
2508 * <td>read/write</td>
2509 * <td>The number of times the contact has been contacted. To have an effect
2510 * on the corresponding value of the aggregate contact, this field
2511 * should be set at the time the raw contact is inserted.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002512 * After that, this value is typically updated via
2513 * {@link ContactsContract.Contacts#markAsContacted}.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002514 * </tr>
2515 * <tr>
2516 * <td>long</td>
2517 * <td>{@link #LAST_TIME_CONTACTED}</td>
2518 * <td>read/write</td>
2519 * <td>The timestamp of the last time the contact was contacted. To have an effect
2520 * on the corresponding value of the aggregate contact, this field
2521 * should be set at the time the raw contact is inserted.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002522 * After that, this value is typically updated via
2523 * {@link ContactsContract.Contacts#markAsContacted}.
2524 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002525 * </tr>
2526 * <tr>
2527 * <td>int</td>
2528 * <td>{@link #STARRED}</td>
2529 * <td>read/write</td>
2530 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002531 * Changing this field immediately affects the corresponding aggregate contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002532 * if any raw contacts in that aggregate contact are starred, then the contact
2533 * itself is marked as starred.</td>
2534 * </tr>
2535 * <tr>
2536 * <td>String</td>
2537 * <td>{@link #CUSTOM_RINGTONE}</td>
2538 * <td>read/write</td>
2539 * <td>A custom ringtone associated with a raw contact. Typically this is the
2540 * URI returned by an activity launched with the
2541 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
2542 * To have an effect on the corresponding value of the aggregate contact, this field
2543 * should be set at the time the raw contact is inserted. To set a custom
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002544 * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
2545 * Contacts.CUSTOM_RINGTONE}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002546 * instead.</td>
2547 * </tr>
2548 * <tr>
2549 * <td>int</td>
2550 * <td>{@link #SEND_TO_VOICEMAIL}</td>
2551 * <td>read/write</td>
2552 * <td>An indicator of whether calls from this raw contact should be forwarded
2553 * directly to voice mail ('1') or not ('0'). To have an effect
2554 * on the corresponding value of the aggregate contact, this field
2555 * should be set at the time the raw contact is inserted.</td>
2556 * </tr>
2557 * <tr>
2558 * <td>String</td>
2559 * <td>{@link #ACCOUNT_NAME}</td>
2560 * <td>read/write-once</td>
2561 * <td>The name of the account instance to which this row belongs, which when paired with
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002562 * {@link #ACCOUNT_TYPE} identifies a specific account.
2563 * For example, this will be the Gmail address if it is a Google account.
Dave Santorod7bdc182011-06-24 15:39:39 -07002564 * It should be set at the time the raw contact is inserted and never
2565 * changed afterwards.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002566 * </tr>
2567 * <tr>
2568 * <td>String</td>
2569 * <td>{@link #ACCOUNT_TYPE}</td>
2570 * <td>read/write-once</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002571 * <td>
2572 * <p>
2573 * The type of account to which this row belongs, which when paired with
2574 * {@link #ACCOUNT_NAME} identifies a specific account.
Dave Santorod7bdc182011-06-24 15:39:39 -07002575 * It should be set at the time the raw contact is inserted and never
2576 * changed afterwards.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002577 * </p>
2578 * <p>
2579 * To ensure uniqueness, new account types should be chosen according to the
2580 * Java package naming convention. Thus a Google account is of type "com.google".
2581 * </p>
2582 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002583 * </tr>
2584 * <tr>
2585 * <td>String</td>
Dave Santorod7bdc182011-06-24 15:39:39 -07002586 * <td>{@link #DATA_SET}</td>
2587 * <td>read/write-once</td>
2588 * <td>
2589 * <p>
2590 * The data set within the account that this row belongs to. This allows
2591 * multiple sync adapters for the same account type to distinguish between
2592 * each others' data. The combination of {@link #ACCOUNT_TYPE},
2593 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
2594 * that is associated with a single sync adapter.
2595 * </p>
2596 * <p>
2597 * This is empty by default, and is completely optional. It only needs to
2598 * be populated if multiple sync adapters are entering distinct data for
2599 * the same account type and account name.
2600 * </p>
2601 * <p>
2602 * It should be set at the time the raw contact is inserted and never
2603 * changed afterwards.
2604 * </p>
2605 * </td>
2606 * </tr>
2607 * <tr>
2608 * <td>String</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002609 * <td>{@link #SOURCE_ID}</td>
2610 * <td>read/write</td>
2611 * <td>String that uniquely identifies this row to its source account.
2612 * Typically it is set at the time the raw contact is inserted and never
2613 * changed afterwards. The one notable exception is a new raw contact: it
Dave Santorod7bdc182011-06-24 15:39:39 -07002614 * will have an account name and type (and possibly a data set), but no
2615 * source id. This indicates to the sync adapter that a new contact needs
2616 * to be created server-side and its ID stored in the corresponding
2617 * SOURCE_ID field on the phone.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002618 * </td>
2619 * </tr>
2620 * <tr>
2621 * <td>int</td>
2622 * <td>{@link #VERSION}</td>
2623 * <td>read-only</td>
2624 * <td>Version number that is updated whenever this row or its related data
2625 * changes. This field can be used for optimistic locking of a raw contact.
2626 * </td>
2627 * </tr>
2628 * <tr>
2629 * <td>int</td>
2630 * <td>{@link #DIRTY}</td>
2631 * <td>read/write</td>
2632 * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
2633 * to be synchronized by its owning account. The value is set to "1" automatically
2634 * whenever the raw contact changes, unless the URI has the
2635 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
2636 * The sync adapter should always supply this query parameter to prevent
2637 * unnecessary synchronization: user changes some data on the server,
2638 * the sync adapter updates the contact on the phone (without the
2639 * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
2640 * which triggers a sync to bring the changes to the server.
2641 * </td>
2642 * </tr>
2643 * <tr>
2644 * <td>String</td>
2645 * <td>{@link #SYNC1}</td>
2646 * <td>read/write</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002647 * <td>Generic column provided for arbitrary use by sync adapters.
2648 * The content provider
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002649 * stores this information on behalf of the sync adapter but does not
2650 * interpret it in any way.
2651 * </td>
2652 * </tr>
2653 * <tr>
2654 * <td>String</td>
2655 * <td>{@link #SYNC2}</td>
2656 * <td>read/write</td>
2657 * <td>Generic column for use by sync adapters.
2658 * </td>
2659 * </tr>
2660 * <tr>
2661 * <td>String</td>
2662 * <td>{@link #SYNC3}</td>
2663 * <td>read/write</td>
2664 * <td>Generic column for use by sync adapters.
2665 * </td>
2666 * </tr>
2667 * <tr>
2668 * <td>String</td>
2669 * <td>{@link #SYNC4}</td>
2670 * <td>read/write</td>
2671 * <td>Generic column for use by sync adapters.
2672 * </td>
2673 * </tr>
2674 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002675 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002676 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08002677 ContactOptionsColumns, ContactNameColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002678 /**
2679 * This utility class cannot be instantiated
2680 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002681 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002682 }
2683
2684 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002685 * The content:// style URI for this table, which requests a directory of
2686 * raw contact rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07002687 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002688 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -07002689
2690 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002691 * The MIME type of the results from {@link #CONTENT_URI} when a specific
2692 * ID value is not provided, and multiple raw contacts may be returned.
Evan Millar088b2912009-05-28 15:24:37 -07002693 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002694 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002695
2696 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002697 * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
2698 * yielding a subdirectory of a single person.
Evan Millar088b2912009-05-28 15:24:37 -07002699 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002700 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002701
2702 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002703 * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002704 */
2705 public static final int AGGREGATION_MODE_DEFAULT = 0;
2706
2707 /**
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002708 * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
2709 * @deprecated Aggregation is synchronous, this historic value is a no-op
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002710 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002711 @Deprecated
Omari Stephensbc9aa772009-09-08 19:10:53 -07002712 public static final int AGGREGATION_MODE_IMMEDIATE = 1;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002713
2714 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002715 * <p>
2716 * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
2717 * Changes to the raw contact will update the associated aggregate contact but will not
2718 * result in any change in how the contact is aggregated. Similar to
2719 * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
2720 * {@link Contacts} aggregate.
2721 * </p>
2722 * <p>
2723 * This can be used to postpone aggregation until after a series of updates, for better
2724 * performance and/or user experience.
2725 * </p>
2726 * <p>
2727 * Note that changing
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002728 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002729 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
2730 * subsequent
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002731 * change to the raw contact's data will.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002732 * </p>
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002733 */
2734 public static final int AGGREGATION_MODE_SUSPENDED = 2;
2735
2736 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002737 * <p>
2738 * Aggregation mode: never aggregate this raw contact. The raw contact will not
2739 * have a corresponding {@link Contacts} aggregate and therefore will not be included in
2740 * {@link Contacts} query results.
2741 * </p>
2742 * <p>
2743 * For example, this mode can be used for a raw contact that is marked for deletion while
2744 * waiting for the deletion to occur on the server side.
2745 * </p>
2746 *
2747 * @see #AGGREGATION_MODE_SUSPENDED
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002748 */
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002749 public static final int AGGREGATION_MODE_DISABLED = 3;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002750
2751 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -05002752 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
2753 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
2754 * entry of the given {@link RawContacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002755 */
2756 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
2757 // TODO: use a lighter query by joining rawcontacts with contacts in provider
2758 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
2759 final Cursor cursor = resolver.query(dataUri, new String[] {
2760 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
2761 }, null, null, null);
2762
2763 Uri lookupUri = null;
2764 try {
2765 if (cursor != null && cursor.moveToFirst()) {
2766 final long contactId = cursor.getLong(0);
2767 final String lookupKey = cursor.getString(1);
2768 return Contacts.getLookupUri(contactId, lookupKey);
2769 }
2770 } finally {
2771 if (cursor != null) cursor.close();
2772 }
2773 return lookupUri;
2774 }
2775
2776 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002777 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002778 * {@link ContactsContract.Data} rows. To access this directory
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002779 * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI.
Evan Millar088b2912009-05-28 15:24:37 -07002780 */
2781 public static final class Data implements BaseColumns, DataColumns {
2782 /**
2783 * no public constructor since this is a utility class
2784 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002785 private Data() {
2786 }
Evan Millar088b2912009-05-28 15:24:37 -07002787
2788 /**
2789 * The directory twig for this sub-table
2790 */
2791 public static final String CONTENT_DIRECTORY = "data";
2792 }
Fred Quintana5bba6322009-10-05 14:21:12 -07002793
2794 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002795 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002796 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002797 * {@link ContactsContract.Data} rows. To access this directory append
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002798 * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002799 * {@link RawContactsEntity} for a stand-alone table containing the same
2800 * data.
2801 * </p>
2802 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002803 * Entity has two ID fields: {@link #_ID} for the raw contact
2804 * and {@link #DATA_ID} for the data rows.
2805 * Entity always contains at least one row, even if there are no
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002806 * actual data rows. In this case the {@link #DATA_ID} field will be
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002807 * null.
2808 * </p>
2809 * <p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002810 * Using Entity should be preferred to using two separate queries:
2811 * RawContacts followed by Data. The reason is that Entity reads all
2812 * data for a raw contact in one transaction, so there is no possibility
2813 * of the data changing between the two queries.
Fred Quintana5bba6322009-10-05 14:21:12 -07002814 */
2815 public static final class Entity implements BaseColumns, DataColumns {
2816 /**
2817 * no public constructor since this is a utility class
2818 */
2819 private Entity() {
2820 }
2821
2822 /**
2823 * The directory twig for this sub-table
2824 */
2825 public static final String CONTENT_DIRECTORY = "entity";
2826
2827 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07002828 * The ID of the data row. The value will be null if this raw contact has no
Fred Quintana5bba6322009-10-05 14:21:12 -07002829 * data rows.
2830 * <P>Type: INTEGER</P>
2831 */
2832 public static final String DATA_ID = "data_id";
2833 }
Fred Quintana328c0e72009-12-07 14:52:28 -08002834
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002835 /**
Dave Santorod414f102011-06-20 14:35:06 -07002836 * <p>
2837 * A sub-directory of a single raw contact that contains all of its
2838 * {@link ContactsContract.StreamItems} rows. To access this directory append
2839 * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See
2840 * {@link ContactsContract.StreamItems} for a stand-alone table containing the
2841 * same data.
2842 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07002843 * <p>
2844 * Access to the social stream through this sub-directory requires additional permissions
2845 * beyond the read/write contact permissions required by the provider. Querying for
2846 * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and
2847 * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM
2848 * permission.
2849 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07002850 *
2851 * @deprecated - Do not use. This will not be supported in the future. In the future,
2852 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002853 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002854 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002855 public static final class StreamItems implements BaseColumns, StreamItemsColumns {
2856 /**
2857 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07002858 *
2859 * @deprecated - Do not use. This will not be supported in the future. In the future,
2860 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002861 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002862 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002863 private StreamItems() {
2864 }
2865
2866 /**
2867 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07002868 *
2869 * @deprecated - Do not use. This will not be supported in the future. In the future,
2870 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002871 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002872 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002873 public static final String CONTENT_DIRECTORY = "stream_items";
2874 }
2875
2876 /**
Dave Santoroa5282372011-06-29 00:25:16 -07002877 * <p>
2878 * A sub-directory of a single raw contact that represents its primary
2879 * display photo. To access this directory append
2880 * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI.
2881 * The resulting URI represents an image file, and should be interacted with
Dave Santoro040e6b32011-07-15 15:14:08 -07002882 * using ContentResolver.openAssetFileDescriptor.
Dave Santoroa5282372011-06-29 00:25:16 -07002883 * <p>
2884 * <p>
2885 * Note that this sub-directory also supports opening the photo as an asset file
2886 * in write mode. Callers can create or replace the primary photo associated
2887 * with this raw contact by opening the asset file and writing the full-size
2888 * photo contents into it. When the file is closed, the image will be parsed,
2889 * sized down if necessary for the full-size display photo and thumbnail
2890 * dimensions, and stored.
2891 * </p>
2892 * <p>
2893 * Usage example:
2894 * <pre>
2895 * public void writeDisplayPhoto(long rawContactId, byte[] photo) {
2896 * Uri rawContactPhotoUri = Uri.withAppendedPath(
2897 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
2898 * RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
2899 * try {
2900 * AssetFileDescriptor fd =
Dave Santoro040e6b32011-07-15 15:14:08 -07002901 * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw");
Dave Santoroa5282372011-06-29 00:25:16 -07002902 * OutputStream os = fd.createOutputStream();
2903 * os.write(photo);
2904 * os.close();
2905 * fd.close();
2906 * } catch (IOException e) {
2907 * // Handle error cases.
2908 * }
2909 * }
2910 * </pre>
2911 * </p>
2912 */
2913 public static final class DisplayPhoto {
2914 /**
2915 * No public constructor since this is a utility class
2916 */
2917 private DisplayPhoto() {
2918 }
2919
2920 /**
2921 * The directory twig for this sub-table
2922 */
2923 public static final String CONTENT_DIRECTORY = "display_photo";
2924 }
2925
2926 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002927 * TODO: javadoc
2928 * @param cursor
2929 * @return
2930 */
Fred Quintana328c0e72009-12-07 14:52:28 -08002931 public static EntityIterator newEntityIterator(Cursor cursor) {
2932 return new EntityIteratorImpl(cursor);
2933 }
2934
2935 private static class EntityIteratorImpl extends CursorEntityIterator {
2936 private static final String[] DATA_KEYS = new String[]{
2937 Data.DATA1,
2938 Data.DATA2,
2939 Data.DATA3,
2940 Data.DATA4,
2941 Data.DATA5,
2942 Data.DATA6,
2943 Data.DATA7,
2944 Data.DATA8,
2945 Data.DATA9,
2946 Data.DATA10,
2947 Data.DATA11,
2948 Data.DATA12,
2949 Data.DATA13,
2950 Data.DATA14,
2951 Data.DATA15,
2952 Data.SYNC1,
2953 Data.SYNC2,
2954 Data.SYNC3,
2955 Data.SYNC4};
2956
2957 public EntityIteratorImpl(Cursor cursor) {
2958 super(cursor);
2959 }
2960
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08002961 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08002962 public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
2963 throws RemoteException {
2964 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
2965 final long rawContactId = cursor.getLong(columnRawContactId);
2966
2967 // we expect the cursor is already at the row we need to read from
2968 ContentValues cv = new ContentValues();
2969 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
2970 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
Katherine Kuan1d837232011-08-24 16:06:06 -07002971 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET);
Fred Quintana328c0e72009-12-07 14:52:28 -08002972 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
2973 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
2974 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
2975 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
2976 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
2977 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
2978 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
2979 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
2980 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
2981 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
2982 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002983 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED);
Fred Quintana328c0e72009-12-07 14:52:28 -08002984 android.content.Entity contact = new android.content.Entity(cv);
2985
2986 // read data rows until the contact id changes
2987 do {
2988 if (rawContactId != cursor.getLong(columnRawContactId)) {
2989 break;
2990 }
2991 // add the data to to the contact
2992 cv = new ContentValues();
2993 cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
2994 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2995 Data.RES_PACKAGE);
2996 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
2997 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
2998 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
2999 Data.IS_SUPER_PRIMARY);
3000 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
3001 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3002 CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
3003 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3004 Data.DATA_VERSION);
3005 for (String key : DATA_KEYS) {
3006 final int columnIndex = cursor.getColumnIndexOrThrow(key);
Daniel Lehmann156add92010-07-19 18:01:10 -07003007 switch (cursor.getType(columnIndex)) {
3008 case Cursor.FIELD_TYPE_NULL:
3009 // don't put anything
3010 break;
3011 case Cursor.FIELD_TYPE_INTEGER:
3012 case Cursor.FIELD_TYPE_FLOAT:
3013 case Cursor.FIELD_TYPE_STRING:
Fred Quintana274dc9d2009-12-11 13:17:08 -08003014 cv.put(key, cursor.getString(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07003015 break;
3016 case Cursor.FIELD_TYPE_BLOB:
Fred Quintana274dc9d2009-12-11 13:17:08 -08003017 cv.put(key, cursor.getBlob(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07003018 break;
3019 default:
3020 throw new IllegalStateException("Invalid or unhandled data type");
Fred Quintana328c0e72009-12-07 14:52:28 -08003021 }
Fred Quintana328c0e72009-12-07 14:52:28 -08003022 }
3023 contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
3024 } while (cursor.moveToNext());
3025
3026 return contact;
3027 }
3028
3029 }
Evan Millar088b2912009-05-28 15:24:37 -07003030 }
3031
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003032 /**
3033 * Social status update columns.
3034 *
3035 * @see StatusUpdates
3036 * @see ContactsContract.Data
3037 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003038 protected interface StatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003039 /**
Dmitri Plotnikova60479d2009-09-27 20:16:31 -07003040 * Contact's latest presence level.
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003041 * <P>Type: INTEGER (one of the values below)</P>
3042 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003043 public static final String PRESENCE = "mode";
3044
3045 /**
3046 * @deprecated use {@link #PRESENCE}
3047 */
3048 @Deprecated
3049 public static final String PRESENCE_STATUS = PRESENCE;
3050
Tom O'Neill244327e2010-01-08 11:11:15 -08003051 /**
3052 * An allowed value of {@link #PRESENCE}.
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003053 */
3054 int OFFLINE = 0;
Tom O'Neill244327e2010-01-08 11:11:15 -08003055
3056 /**
3057 * An allowed value of {@link #PRESENCE}.
3058 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003059 int INVISIBLE = 1;
Tom O'Neill244327e2010-01-08 11:11:15 -08003060
3061 /**
3062 * An allowed value of {@link #PRESENCE}.
3063 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003064 int AWAY = 2;
Tom O'Neill244327e2010-01-08 11:11:15 -08003065
3066 /**
3067 * An allowed value of {@link #PRESENCE}.
3068 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003069 int IDLE = 3;
Tom O'Neill244327e2010-01-08 11:11:15 -08003070
3071 /**
3072 * An allowed value of {@link #PRESENCE}.
3073 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003074 int DO_NOT_DISTURB = 4;
Tom O'Neill244327e2010-01-08 11:11:15 -08003075
3076 /**
3077 * An allowed value of {@link #PRESENCE}.
3078 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003079 int AVAILABLE = 5;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003080
3081 /**
3082 * Contact latest status update.
3083 * <p>Type: TEXT</p>
3084 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003085 public static final String STATUS = "status";
3086
3087 /**
3088 * @deprecated use {@link #STATUS}
3089 */
Tom O'Neill244327e2010-01-08 11:11:15 -08003090 @Deprecated
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003091 public static final String PRESENCE_CUSTOM_STATUS = STATUS;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003092
3093 /**
3094 * The absolute time in milliseconds when the latest status was inserted/updated.
3095 * <p>Type: NUMBER</p>
3096 */
3097 public static final String STATUS_TIMESTAMP = "status_ts";
3098
3099 /**
3100 * The package containing resources for this status: label and icon.
Dave Santoro040e6b32011-07-15 15:14:08 -07003101 * <p>Type: TEXT</p>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003102 */
3103 public static final String STATUS_RES_PACKAGE = "status_res_package";
3104
3105 /**
3106 * The resource ID of the label describing the source of the status update, e.g. "Google
3107 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3108 * <p>Type: NUMBER</p>
3109 */
3110 public static final String STATUS_LABEL = "status_label";
3111
3112 /**
3113 * The resource ID of the icon for the source of the status update.
3114 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3115 * <p>Type: NUMBER</p>
3116 */
3117 public static final String STATUS_ICON = "status_icon";
Vasu Nori5b314982010-07-12 15:13:37 -07003118
3119 /**
3120 * Contact's audio/video chat capability level.
3121 * <P>Type: INTEGER (one of the values below)</P>
3122 */
3123 public static final String CHAT_CAPABILITY = "chat_capability";
3124
3125 /**
Daniel Lehmannb3327472010-08-13 15:16:11 -07003126 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone
3127 * and speaker)
3128 */
3129 public static final int CAPABILITY_HAS_VOICE = 1;
3130
3131 /**
3132 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
Vasu Nori5b314982010-07-12 15:13:37 -07003133 * display a video feed.
3134 */
Daniel Lehmannb3327472010-08-13 15:16:11 -07003135 public static final int CAPABILITY_HAS_VIDEO = 2;
Vasu Nori5b314982010-07-12 15:13:37 -07003136
3137 /**
Daniel Lehmannb3327472010-08-13 15:16:11 -07003138 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
Vasu Nori5b314982010-07-12 15:13:37 -07003139 * camera that can be used for video chat (e.g. a front-facing camera on a phone).
3140 */
3141 public static final int CAPABILITY_HAS_CAMERA = 4;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003142 }
3143
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003144 /**
Dave Santorod414f102011-06-20 14:35:06 -07003145 * <p>
3146 * Constants for the stream_items table, which contains social stream updates from
3147 * the user's contact list.
3148 * </p>
3149 * <p>
3150 * Only a certain number of stream items will ever be stored under a given raw contact.
3151 * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to
3152 * determine this limit, and should restrict the number of items inserted in any given
3153 * transaction correspondingly. Insertion of more items beyond the limit will
3154 * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}.
3155 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003156 * <p>
3157 * Access to the social stream through these URIs requires additional permissions beyond the
3158 * read/write contact permissions required by the provider. Querying for social stream data
3159 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social
3160 * stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
3161 * </p>
Makoto Onuki46891a82012-04-26 12:46:47 -07003162 * <h3>Account check</h3>
3163 * <p>
3164 * The content URIs to the insert, update and delete operations are required to have the account
3165 * information matching that of the owning raw contact as query parameters, namely
3166 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3167 * {@link RawContacts#DATA_SET} isn't required.
3168 * </p>
Dave Santorod414f102011-06-20 14:35:06 -07003169 * <h3>Operations</h3>
3170 * <dl>
3171 * <dt><b>Insert</b></dt>
3172 * <dd>
3173 * <p>Social stream updates are always associated with a raw contact. There are a couple
3174 * of ways to insert these entries.
3175 * <dl>
3176 * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt>
3177 * <dd>
3178 * <pre>
3179 * ContentValues values = new ContentValues();
3180 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3181 * values.put(StreamItems.TIMESTAMP, timestamp);
Dave Santoro040e6b32011-07-15 15:14:08 -07003182 * values.put(StreamItems.COMMENTS, "3 people reshared this");
Makoto Onuki46891a82012-04-26 12:46:47 -07003183 * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
3184 * ContentUris.appendId(builder, rawContactId);
3185 * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY);
3186 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3187 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3188 * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003189 * long streamItemId = ContentUris.parseId(streamItemUri);
3190 * </pre>
3191 * </dd>
Scott Main45107052011-09-26 21:52:05 -07003192 * <dt>Via {@link StreamItems#CONTENT_URI}:</dt>
Dave Santorod414f102011-06-20 14:35:06 -07003193 * <dd>
Scott Main45107052011-09-26 21:52:05 -07003194 *<pre>
Dave Santorod414f102011-06-20 14:35:06 -07003195 * ContentValues values = new ContentValues();
3196 * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
3197 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3198 * values.put(StreamItems.TIMESTAMP, timestamp);
Dave Santoro040e6b32011-07-15 15:14:08 -07003199 * values.put(StreamItems.COMMENTS, "3 people reshared this");
Makoto Onuki46891a82012-04-26 12:46:47 -07003200 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3201 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3202 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3203 * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003204 * long streamItemId = ContentUris.parseId(streamItemUri);
Scott Main45107052011-09-26 21:52:05 -07003205 *</pre>
Dave Santorod414f102011-06-20 14:35:06 -07003206 * </dd>
3207 * </dl>
3208 * </dd>
3209 * </p>
3210 * <p>
3211 * Once a {@link StreamItems} entry has been inserted, photos associated with that
3212 * social update can be inserted. For example, after one of the insertions above,
3213 * photos could be added to the stream item in one of the following ways:
3214 * <dl>
3215 * <dt>Via a URI including the stream item ID:</dt>
3216 * <dd>
3217 * <pre>
3218 * values.clear();
3219 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003220 * values.put(StreamItemPhotos.PHOTO, photoData);
Dave Santorod414f102011-06-20 14:35:06 -07003221 * getContentResolver().insert(Uri.withAppendedPath(
3222 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId),
3223 * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
3224 * </pre>
3225 * </dd>
Scott Main45107052011-09-26 21:52:05 -07003226 * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt>
Dave Santorod414f102011-06-20 14:35:06 -07003227 * <dd>
3228 * <pre>
3229 * values.clear();
3230 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3231 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003232 * values.put(StreamItemPhotos.PHOTO, photoData);
Dave Santorod414f102011-06-20 14:35:06 -07003233 * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
3234 * </pre>
Scott Main45107052011-09-26 21:52:05 -07003235 * <p>Note that this latter form allows the insertion of a stream item and its
Dave Santorod414f102011-06-20 14:35:06 -07003236 * photos in a single transaction, by using {@link ContentProviderOperation} with
3237 * back references to populate the stream item ID in the {@link ContentValues}.
3238 * </dd>
3239 * </dl>
3240 * </p>
3241 * </dd>
3242 * <dt><b>Update</b></dt>
3243 * <dd>Updates can be performed by appending the stream item ID to the
3244 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
3245 * created by the calling package can be updated.</dd>
3246 * <dt><b>Delete</b></dt>
3247 * <dd>Deletes can be performed by appending the stream item ID to the
3248 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
3249 * created by the calling package can be deleted.</dd>
3250 * <dt><b>Query</b></dt>
3251 * <dl>
3252 * <dt>Finding all social stream updates for a given contact</dt>
3253 * <dd>By Contact ID:
3254 * <pre>
3255 * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3256 * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
3257 * Contacts.StreamItems.CONTENT_DIRECTORY),
3258 * null, null, null, null);
3259 * </pre>
3260 * </dd>
3261 * <dd>By lookup key:
3262 * <pre>
3263 * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
3264 * .appendPath(lookupKey)
3265 * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
3266 * null, null, null, null);
3267 * </pre>
3268 * </dd>
3269 * <dt>Finding all social stream updates for a given raw contact</dt>
3270 * <dd>
3271 * <pre>
3272 * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3273 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
3274 * RawContacts.StreamItems.CONTENT_DIRECTORY)),
3275 * null, null, null, null);
3276 * </pre>
3277 * </dd>
3278 * <dt>Querying for a specific stream item by ID</dt>
3279 * <dd>
3280 * <pre>
3281 * Cursor c = getContentResolver().query(ContentUris.withAppendedId(
3282 * StreamItems.CONTENT_URI, streamItemId),
3283 * null, null, null, null);
3284 * </pre>
3285 * </dd>
3286 * </dl>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003287 *
3288 * @deprecated - Do not use. This will not be supported in the future. In the future,
3289 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003290 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003291 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003292 public static final class StreamItems implements BaseColumns, StreamItemsColumns {
3293 /**
3294 * This utility class cannot be instantiated
Brian Attwellbdb13c82014-07-16 21:43:54 -07003295 *
3296 * @deprecated - Do not use. This will not be supported in the future. In the future,
3297 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003298 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003299 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003300 private StreamItems() {
3301 }
3302
3303 /**
3304 * The content:// style URI for this table, which handles social network stream
3305 * updates for the user's contacts.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003306 *
3307 * @deprecated - Do not use. This will not be supported in the future. In the future,
3308 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003309 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003310 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003311 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items");
3312
3313 /**
3314 * <p>
3315 * A content:// style URI for the photos stored in a sub-table underneath
3316 * stream items. This is only used for inserts, and updates - queries and deletes
3317 * for photos should be performed by appending
3318 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a
3319 * specific stream item.
3320 * </p>
3321 * <p>
3322 * When using this URI, the stream item ID for the photo(s) must be identified
3323 * in the {@link ContentValues} passed in.
3324 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003325 *
3326 * @deprecated - Do not use. This will not be supported in the future. In the future,
3327 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003328 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003329 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003330 public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo");
3331
3332 /**
3333 * This URI allows the caller to query for the maximum number of stream items
Dave Santoro040e6b32011-07-15 15:14:08 -07003334 * that will be stored under any single raw contact.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003335 *
3336 * @deprecated - Do not use. This will not be supported in the future. In the future,
3337 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003338 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003339 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003340 public static final Uri CONTENT_LIMIT_URI =
3341 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
3342
3343 /**
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003344 * The MIME type of a directory of stream items.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003345 *
3346 * @deprecated - Do not use. This will not be supported in the future. In the future,
3347 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003348 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003349 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003350 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item";
3351
3352 /**
3353 * The MIME type of a single stream item.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003354 *
3355 * @deprecated - Do not use. This will not be supported in the future. In the future,
3356 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003357 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003358 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003359 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item";
3360
3361 /**
Dave Santorod414f102011-06-20 14:35:06 -07003362 * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
3363 * contain this column, with the value indicating the maximum number of
3364 * stream items that will be stored under any single raw contact.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003365 *
3366 * @deprecated - Do not use. This will not be supported in the future. In the future,
3367 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003368 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003369 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003370 public static final String MAX_ITEMS = "max_items";
3371
3372 /**
Dave Santorod414f102011-06-20 14:35:06 -07003373 * <p>
3374 * A sub-directory of a single stream item entry that contains all of its
3375 * photo rows. To access this
3376 * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to
3377 * an individual stream item URI.
3378 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003379 * <p>
3380 * Access to social stream photos requires additional permissions beyond the read/write
3381 * contact permissions required by the provider. Querying for social stream photos
3382 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3383 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3384 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003385 *
3386 * @deprecated - Do not use. This will not be supported in the future. In the future,
3387 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003388 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003389 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003390 public static final class StreamItemPhotos
3391 implements BaseColumns, StreamItemPhotosColumns {
3392 /**
3393 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07003394 *
3395 * @deprecated - Do not use. This will not be supported in the future. In the future,
3396 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003397 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003398 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003399 private StreamItemPhotos() {
3400 }
3401
3402 /**
3403 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07003404 *
3405 * @deprecated - Do not use. This will not be supported in the future. In the future,
3406 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003407 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003408 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003409 public static final String CONTENT_DIRECTORY = "photo";
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003410
3411 /**
3412 * The MIME type of a directory of stream item photos.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003413 *
3414 * @deprecated - Do not use. This will not be supported in the future. In the future,
3415 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003416 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003417 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003418 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo";
3419
3420 /**
3421 * The MIME type of a single stream item photo.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003422 *
3423 * @deprecated - Do not use. This will not be supported in the future. In the future,
3424 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003425 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003426 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003427 public static final String CONTENT_ITEM_TYPE
3428 = "vnd.android.cursor.item/stream_item_photo";
Dave Santorod414f102011-06-20 14:35:06 -07003429 }
3430 }
3431
3432 /**
3433 * Columns in the StreamItems table.
3434 *
3435 * @see ContactsContract.StreamItems
Brian Attwellbdb13c82014-07-16 21:43:54 -07003436 * @deprecated - Do not use. This will not be supported in the future. In the future,
3437 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003438 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003439 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003440 protected interface StreamItemsColumns {
3441 /**
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003442 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID}
3443 * that this stream item belongs to.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003444 *
3445 * <p>Type: INTEGER</p>
3446 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003447 *
3448 * @deprecated - Do not use. This will not be supported in the future. In the future,
3449 * cursors returned from related queries will be empty.
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003450 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003451 @Deprecated
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003452 public static final String CONTACT_ID = "contact_id";
3453
3454 /**
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003455 * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY}
3456 * that this stream item belongs to.
3457 *
3458 * <p>Type: TEXT</p>
3459 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003460 *
3461 * @deprecated - Do not use. This will not be supported in the future. In the future,
3462 * cursors returned from related queries will be empty.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003463 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003464 @Deprecated
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003465 public static final String CONTACT_LOOKUP_KEY = "contact_lookup";
3466
3467 /**
Dave Santorod414f102011-06-20 14:35:06 -07003468 * A reference to the {@link RawContacts#_ID}
3469 * that this stream item belongs to.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003470 * <p>Type: INTEGER</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003471 *
3472 * @deprecated - Do not use. This will not be supported in the future. In the future,
3473 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003474 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003475 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003476 public static final String RAW_CONTACT_ID = "raw_contact_id";
3477
3478 /**
3479 * The package name to use when creating {@link Resources} objects for
3480 * this stream item. This value is only designed for use when building
3481 * user interfaces, and should not be used to infer the owner.
Dave Santoro040e6b32011-07-15 15:14:08 -07003482 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003483 *
3484 * @deprecated - Do not use. This will not be supported in the future. In the future,
3485 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003486 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003487 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003488 public static final String RES_PACKAGE = "res_package";
3489
3490 /**
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003491 * The account type to which the raw_contact of this item is associated. See
3492 * {@link RawContacts#ACCOUNT_TYPE}
3493 *
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003494 * <p>Type: TEXT</p>
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003495 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003496 *
3497 * @deprecated - Do not use. This will not be supported in the future. In the future,
3498 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003499 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003500 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003501 public static final String ACCOUNT_TYPE = "account_type";
3502
3503 /**
3504 * The account name to which the raw_contact of this item is associated. See
3505 * {@link RawContacts#ACCOUNT_NAME}
3506 *
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003507 * <p>Type: TEXT</p>
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003508 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003509 *
3510 * @deprecated - Do not use. This will not be supported in the future. In the future,
3511 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003512 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003513 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003514 public static final String ACCOUNT_NAME = "account_name";
3515
3516 /**
3517 * The data set within the account that the raw_contact of this row belongs to. This allows
3518 * multiple sync adapters for the same account type to distinguish between
3519 * each others' data.
3520 * {@link RawContacts#DATA_SET}
3521 *
3522 * <P>Type: TEXT</P>
3523 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003524 *
3525 * @deprecated - Do not use. This will not be supported in the future. In the future,
3526 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003527 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003528 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003529 public static final String DATA_SET = "data_set";
3530
3531 /**
3532 * The source_id of the raw_contact that this row belongs to.
3533 * {@link RawContacts#SOURCE_ID}
3534 *
3535 * <P>Type: TEXT</P>
3536 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003537 *
3538 * @deprecated - Do not use. This will not be supported in the future. In the future,
3539 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003540 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003541 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003542 public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id";
3543
3544 /**
3545 * The resource name of the icon for the source of the stream item.
3546 * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference
3547 * drawables, the "@drawable/" prefix must be omitted.
3548 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003549 *
3550 * @deprecated - Do not use. This will not be supported in the future. In the future,
3551 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003552 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003553 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003554 public static final String RES_ICON = "icon";
3555
3556 /**
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003557 * The resource name of the label describing the source of the status update, e.g. "Google
3558 * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only
3559 * reference strings, the "@string/" prefix must be omitted.
3560 * <p>Type: TEXT</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003561 *
3562 * @deprecated - Do not use. This will not be supported in the future. In the future,
3563 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003564 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003565 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003566 public static final String RES_LABEL = "label";
3567
3568 /**
3569 * <P>
3570 * The main textual contents of the item. Typically this is content
3571 * that was posted by the source of this stream item, but it can also
3572 * be a textual representation of an action (e.g. ”Checked in at Joe's”).
3573 * This text is displayed to the user and allows formatting and embedded
3574 * resource images via HTML (as parseable via
3575 * {@link android.text.Html#fromHtml}).
3576 * </P>
3577 * <P>
3578 * Long content may be truncated and/or ellipsized - the exact behavior
3579 * is unspecified, but it should not break tags.
3580 * </P>
3581 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003582 *
3583 * @deprecated - Do not use. This will not be supported in the future. In the future,
3584 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003585 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003586 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003587 public static final String TEXT = "text";
3588
3589 /**
3590 * The absolute time (milliseconds since epoch) when this stream item was
3591 * inserted/updated.
3592 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003593 *
3594 * @deprecated - Do not use. This will not be supported in the future. In the future,
3595 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003596 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003597 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003598 public static final String TIMESTAMP = "timestamp";
3599
3600 /**
3601 * <P>
3602 * Summary information about the stream item, for example to indicate how
3603 * many people have reshared it, how many have liked it, how many thumbs
3604 * up and/or thumbs down it has, what the original source was, etc.
3605 * </P>
3606 * <P>
3607 * This text is displayed to the user and allows simple formatting via
3608 * HTML, in the same manner as {@link #TEXT} allows.
3609 * </P>
3610 * <P>
3611 * Long content may be truncated and/or ellipsized - the exact behavior
3612 * is unspecified, but it should not break tags.
3613 * </P>
3614 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003615 *
3616 * @deprecated - Do not use. This will not be supported in the future. In the future,
3617 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003618 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003619 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003620 public static final String COMMENTS = "comments";
3621
Brian Attwellbdb13c82014-07-16 21:43:54 -07003622 /**
3623 * Generic column for use by sync adapters.
3624 *
3625 * @deprecated - Do not use. This will not be supported in the future. In the future,
3626 * cursors returned from related queries will be empty.
3627 */
3628 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003629 public static final String SYNC1 = "stream_item_sync1";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003630 /**
3631 * Generic column for use by sync adapters.
3632 *
3633 * @deprecated - Do not use. This will not be supported in the future. In the future,
3634 * cursors returned from related queries will be empty.
3635 */
3636 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003637 public static final String SYNC2 = "stream_item_sync2";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003638 /**
3639 * Generic column for use by sync adapters.
3640 *
3641 * @deprecated - Do not use. This will not be supported in the future. In the future,
3642 * cursors returned from related queries will be empty.
3643 */
3644 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003645 public static final String SYNC3 = "stream_item_sync3";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003646 /**
3647 * Generic column for use by sync adapters.
3648 *
3649 * @deprecated - Do not use. This will not be supported in the future. In the future,
3650 * cursors returned from related queries will be empty.
3651 */
3652 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003653 public static final String SYNC4 = "stream_item_sync4";
Dave Santorod414f102011-06-20 14:35:06 -07003654 }
3655
3656 /**
3657 * <p>
3658 * Constants for the stream_item_photos table, which contains photos associated with
3659 * social stream updates.
3660 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003661 * <p>
3662 * Access to social stream photos requires additional permissions beyond the read/write
3663 * contact permissions required by the provider. Querying for social stream photos
3664 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3665 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3666 * </p>
Makoto Onuki46891a82012-04-26 12:46:47 -07003667 * <h3>Account check</h3>
3668 * <p>
3669 * The content URIs to the insert, update and delete operations are required to have the account
3670 * information matching that of the owning raw contact as query parameters, namely
3671 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3672 * {@link RawContacts#DATA_SET} isn't required.
3673 * </p>
Dave Santorod414f102011-06-20 14:35:06 -07003674 * <h3>Operations</h3>
3675 * <dl>
3676 * <dt><b>Insert</b></dt>
3677 * <dd>
3678 * <p>Social stream photo entries are associated with a social stream item. Photos
3679 * can be inserted into a social stream item in a couple of ways:
3680 * <dl>
3681 * <dt>
3682 * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3683 * stream item:
3684 * </dt>
3685 * <dd>
3686 * <pre>
3687 * ContentValues values = new ContentValues();
3688 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003689 * values.put(StreamItemPhotos.PHOTO, photoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003690 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3691 * ContentUris.appendId(builder, streamItemId);
3692 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3693 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3694 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3695 * Uri photoUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003696 * long photoId = ContentUris.parseId(photoUri);
3697 * </pre>
3698 * </dd>
3699 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3700 * <dd>
3701 * <pre>
3702 * ContentValues values = new ContentValues();
3703 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3704 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003705 * values.put(StreamItemPhotos.PHOTO, photoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003706 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3707 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3708 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3709 * Uri photoUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003710 * long photoId = ContentUris.parseId(photoUri);
3711 * </pre>
3712 * </dd>
3713 * </dl>
3714 * </p>
3715 * </dd>
3716 * <dt><b>Update</b></dt>
3717 * <dd>
3718 * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry,
3719 * identified by both the stream item ID it belongs to and the stream item photo ID.
3720 * This can be specified in two ways.
3721 * <dl>
3722 * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3723 * stream item:
3724 * </dt>
3725 * <dd>
3726 * <pre>
3727 * ContentValues values = new ContentValues();
Dave Santoro040e6b32011-07-15 15:14:08 -07003728 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003729 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3730 * ContentUris.appendId(builder, streamItemId);
3731 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3732 * ContentUris.appendId(builder, streamItemPhotoId);
3733 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3734 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3735 * getContentResolver().update(builder.build(), values, null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003736 * </pre>
3737 * </dd>
3738 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3739 * <dd>
3740 * <pre>
3741 * ContentValues values = new ContentValues();
3742 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
Dave Santoro040e6b32011-07-15 15:14:08 -07003743 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003744 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3745 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3746 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3747 * getContentResolver().update(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003748 * </pre>
3749 * </dd>
3750 * </dl>
3751 * </p>
3752 * </dd>
3753 * <dt><b>Delete</b></dt>
3754 * <dd>Deletes can be made against either a specific photo item in a stream item, or
3755 * against all or a selected subset of photo items under a stream item.
3756 * For example:
3757 * <dl>
3758 * <dt>Deleting a single photo via the
3759 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item:
3760 * </dt>
3761 * <dd>
3762 * <pre>
Makoto Onuki46891a82012-04-26 12:46:47 -07003763 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3764 * ContentUris.appendId(builder, streamItemId);
3765 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3766 * ContentUris.appendId(builder, streamItemPhotoId);
3767 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3768 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3769 * getContentResolver().delete(builder.build(), null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003770 * </pre>
3771 * </dd>
3772 * <dt>Deleting all photos under a stream item</dt>
3773 * <dd>
3774 * <pre>
Makoto Onuki46891a82012-04-26 12:46:47 -07003775 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3776 * ContentUris.appendId(builder, streamItemId);
3777 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3778 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3779 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3780 * getContentResolver().delete(builder.build(), null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003781 * </pre>
3782 * </dd>
3783 * </dl>
3784 * </dd>
3785 * <dt><b>Query</b></dt>
3786 * <dl>
3787 * <dt>Querying for a specific photo in a stream item</dt>
3788 * <dd>
3789 * <pre>
3790 * Cursor c = getContentResolver().query(
3791 * ContentUris.withAppendedId(
3792 * Uri.withAppendedPath(
3793 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3794 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3795 * streamItemPhotoId), null, null, null, null);
3796 * </pre>
3797 * </dd>
3798 * <dt>Querying for all photos in a stream item</dt>
3799 * <dd>
3800 * <pre>
3801 * Cursor c = getContentResolver().query(
3802 * Uri.withAppendedPath(
3803 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3804 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3805 * null, null, null, StreamItemPhotos.SORT_INDEX);
3806 * </pre>
3807 * </dl>
Dave Santoro040e6b32011-07-15 15:14:08 -07003808 * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a
3809 * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID}
3810 * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to
3811 * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as
3812 * an asset file, as follows:
3813 * <pre>
3814 * public InputStream openDisplayPhoto(String photoUri) {
3815 * try {
3816 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
3817 * return fd.createInputStream();
3818 * } catch (IOException e) {
3819 * return null;
3820 * }
3821 * }
3822 * <pre>
Dave Santorod414f102011-06-20 14:35:06 -07003823 * </dd>
3824 * </dl>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003825 *
3826 * @deprecated - Do not use. This will not be supported in the future. In the future,
3827 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003828 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003829 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003830 public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns {
3831 /**
3832 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07003833 *
3834 * @deprecated - Do not use. This will not be supported in the future. In the future,
3835 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003836 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003837 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003838 private StreamItemPhotos() {
3839 }
Dave Santoro040e6b32011-07-15 15:14:08 -07003840
3841 /**
3842 * <p>
3843 * The binary representation of the photo. Any size photo can be inserted;
3844 * the provider will resize it appropriately for storage and display.
3845 * </p>
3846 * <p>
3847 * This is only intended for use when inserting or updating a stream item photo.
3848 * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI}
3849 * as an asset file.
3850 * </p>
3851 * <P>Type: BLOB</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003852 *
3853 * @deprecated - Do not use. This will not be supported in the future. In the future,
3854 * cursors returned from related queries will be empty.
Dave Santoro040e6b32011-07-15 15:14:08 -07003855 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003856 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003857 public static final String PHOTO = "photo";
Dave Santorod414f102011-06-20 14:35:06 -07003858 }
3859
3860 /**
3861 * Columns in the StreamItemPhotos table.
3862 *
3863 * @see ContactsContract.StreamItemPhotos
Brian Attwellbdb13c82014-07-16 21:43:54 -07003864 * @deprecated - Do not use. This will not be supported in the future. In the future,
3865 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003866 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003867 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003868 protected interface StreamItemPhotosColumns {
3869 /**
3870 * A reference to the {@link StreamItems#_ID} this photo is associated with.
3871 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003872 *
3873 * @deprecated - Do not use. This will not be supported in the future. In the future,
3874 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003875 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003876 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003877 public static final String STREAM_ITEM_ID = "stream_item_id";
3878
3879 /**
3880 * An integer to use for sort order for photos in the stream item. If not
3881 * specified, the {@link StreamItemPhotos#_ID} will be used for sorting.
3882 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003883 *
3884 * @deprecated - Do not use. This will not be supported in the future. In the future,
3885 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003886 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003887 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003888 public static final String SORT_INDEX = "sort_index";
3889
3890 /**
Dave Santoro040e6b32011-07-15 15:14:08 -07003891 * Photo file ID for the photo.
3892 * See {@link ContactsContract.DisplayPhoto}.
3893 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003894 *
3895 * @deprecated - Do not use. This will not be supported in the future. In the future,
3896 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003897 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003898 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003899 public static final String PHOTO_FILE_ID = "photo_file_id";
3900
3901 /**
3902 * URI for retrieving the photo content, automatically populated. Callers
3903 * may retrieve the photo content by opening this URI as an asset file.
3904 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003905 *
3906 * @deprecated - Do not use. This will not be supported in the future. In the future,
3907 * cursors returned from related queries will be empty.
Dave Santoro040e6b32011-07-15 15:14:08 -07003908 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003909 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003910 public static final String PHOTO_URI = "photo_uri";
Dave Santorod414f102011-06-20 14:35:06 -07003911
Brian Attwellbdb13c82014-07-16 21:43:54 -07003912 /**
3913 * Generic column for use by sync adapters.
3914 *
3915 * @deprecated - Do not use. This will not be supported in the future. In the future,
3916 * cursors returned from related queries will be empty.
3917 */
3918 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003919 public static final String SYNC1 = "stream_item_photo_sync1";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003920 /**
3921 * Generic column for use by sync adapters.
3922 *
3923 * @deprecated - Do not use. This will not be supported in the future. In the future,
3924 * cursors returned from related queries will be empty.
3925 */
3926 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003927 public static final String SYNC2 = "stream_item_photo_sync2";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003928 /**
3929 * Generic column for use by sync adapters.
3930 *
3931 * @deprecated - Do not use. This will not be supported in the future. In the future,
3932 * cursors returned from related queries will be empty.
3933 */
3934 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003935 public static final String SYNC3 = "stream_item_photo_sync3";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003936 /**
3937 * Generic column for use by sync adapters.
3938 *
3939 * @deprecated - Do not use. This will not be supported in the future. In the future,
3940 * cursors returned from related queries will be empty.
3941 */
3942 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003943 public static final String SYNC4 = "stream_item_photo_sync4";
Dave Santorod414f102011-06-20 14:35:06 -07003944 }
3945
3946 /**
Dave Santoroa5282372011-06-29 00:25:16 -07003947 * <p>
3948 * Constants for the photo files table, which tracks metadata for hi-res photos
3949 * stored in the file system.
3950 * </p>
3951 *
3952 * @hide
3953 */
3954 public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns {
3955 /**
3956 * No public constructor since this is a utility class
3957 */
3958 private PhotoFiles() {
3959 }
3960 }
3961
3962 /**
3963 * Columns in the PhotoFiles table.
3964 *
3965 * @see ContactsContract.PhotoFiles
3966 *
3967 * @hide
3968 */
3969 protected interface PhotoFilesColumns {
3970
3971 /**
3972 * The height, in pixels, of the photo this entry is associated with.
3973 * <P>Type: NUMBER</P>
3974 */
3975 public static final String HEIGHT = "height";
3976
3977 /**
3978 * The width, in pixels, of the photo this entry is associated with.
3979 * <P>Type: NUMBER</P>
3980 */
3981 public static final String WIDTH = "width";
3982
3983 /**
3984 * The size, in bytes, of the photo stored on disk.
3985 * <P>Type: NUMBER</P>
3986 */
3987 public static final String FILESIZE = "filesize";
3988 }
3989
3990 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003991 * Columns in the Data table.
3992 *
3993 * @see ContactsContract.Data
3994 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07003995 protected interface DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07003996 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003997 * The package name to use when creating {@link Resources} objects for
3998 * this data row. This value is only designed for use when building user
3999 * interfaces, and should not be used to infer the owner.
4000 */
4001 public static final String RES_PACKAGE = "res_package";
4002
4003 /**
4004 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -07004005 */
4006 public static final String MIMETYPE = "mimetype";
4007
4008 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004009 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -07004010 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -07004011 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07004012 public static final String RAW_CONTACT_ID = "raw_contact_id";
4013
Evan Millarab5742d2009-06-02 16:21:45 -07004014 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08004015 * Whether this is the primary entry of its kind for the raw contact it belongs to.
Evan Millarab5742d2009-06-02 16:21:45 -07004016 * <P>Type: INTEGER (if set, non-0 means true)</P>
4017 */
4018 public static final String IS_PRIMARY = "is_primary";
4019
4020 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004021 * Whether this is the primary entry of its kind for the aggregate
4022 * contact it belongs to. Any data record that is "super primary" must
4023 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -07004024 * <P>Type: INTEGER (if set, non-0 means true)</P>
4025 */
4026 public static final String IS_SUPER_PRIMARY = "is_super_primary";
4027
Jeff Sharkey28b68e52009-06-10 15:26:58 -07004028 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07004029 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
4030 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
4031 * <P>Type: INTEGER</P>
4032 */
4033 public static final String IS_READ_ONLY = "is_read_only";
4034
4035 /**
Fred Quintanac933fb62009-06-11 12:14:40 -07004036 * The version of this data record. This is a read-only value. The data column is
4037 * guaranteed to not change without the version going up. This value is monotonically
4038 * increasing.
4039 * <P>Type: INTEGER</P>
4040 */
4041 public static final String DATA_VERSION = "data_version";
4042
Evan Millar088b2912009-05-28 15:24:37 -07004043 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4044 public static final String DATA1 = "data1";
4045 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4046 public static final String DATA2 = "data2";
4047 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4048 public static final String DATA3 = "data3";
4049 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4050 public static final String DATA4 = "data4";
4051 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4052 public static final String DATA5 = "data5";
4053 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4054 public static final String DATA6 = "data6";
4055 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4056 public static final String DATA7 = "data7";
4057 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4058 public static final String DATA8 = "data8";
4059 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4060 public static final String DATA9 = "data9";
4061 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4062 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004063 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4064 public static final String DATA11 = "data11";
4065 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4066 public static final String DATA12 = "data12";
4067 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4068 public static final String DATA13 = "data13";
4069 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4070 public static final String DATA14 = "data14";
Tom O'Neill244327e2010-01-08 11:11:15 -08004071 /**
4072 * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
4073 * this field is used to store BLOBs (binary data).
4074 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004075 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07004076
Fred Quintana8851e162009-08-05 21:06:45 -07004077 /** Generic column for use by sync adapters. */
4078 public static final String SYNC1 = "data_sync1";
4079 /** Generic column for use by sync adapters. */
4080 public static final String SYNC2 = "data_sync2";
4081 /** Generic column for use by sync adapters. */
4082 public static final String SYNC3 = "data_sync3";
4083 /** Generic column for use by sync adapters. */
4084 public static final String SYNC4 = "data_sync4";
Evan Millar088b2912009-05-28 15:24:37 -07004085 }
4086
4087 /**
Yorke Lee0dc523f2013-03-12 12:48:06 -07004088 * Columns in the Data_Usage_Stat table
4089 */
4090 protected interface DataUsageStatColumns {
Yorke Lee0dc523f2013-03-12 12:48:06 -07004091 /** The last time (in milliseconds) this {@link Data} was used. */
4092 public static final String LAST_TIME_USED = "last_time_used";
4093
Yorke Lee5a53d702013-03-29 18:08:47 -07004094 /** The number of times the referenced {@link Data} has been used. */
Yorke Lee0dc523f2013-03-12 12:48:06 -07004095 public static final String TIMES_USED = "times_used";
Yorke Lee0dc523f2013-03-12 12:48:06 -07004096 }
4097
4098 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004099 * Combines all columns returned by {@link ContactsContract.Data} table queries.
4100 *
4101 * @see ContactsContract.Data
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004102 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07004103 protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08004104 RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
Yorke Lee0dc523f2013-03-12 12:48:06 -07004105 ContactStatusColumns, DataUsageStatColumns {
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004106 }
4107
4108 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004109 * <p>
4110 * Constants for the data table, which contains data points tied to a raw
Tom O'Neill244327e2010-01-08 11:11:15 -08004111 * contact. Each row of the data table is typically used to store a single
4112 * piece of contact
4113 * information (such as a phone number) and its
4114 * associated metadata (such as whether it is a work or home number).
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004115 * </p>
4116 * <h3>Data kinds</h3>
4117 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004118 * Data is a generic table that can hold any kind of contact data.
4119 * The kind of data stored in a given row is specified by the row's
4120 * {@link #MIMETYPE} value, which determines the meaning of the
4121 * generic columns {@link #DATA1} through
4122 * {@link #DATA15}.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004123 * For example, if the data kind is
Tom O'Neill244327e2010-01-08 11:11:15 -08004124 * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
4125 * {@link #DATA1} stores the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004126 * phone number, but if the data kind is
Tom O'Neill244327e2010-01-08 11:11:15 -08004127 * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
4128 * stores the email address.
4129 * Sync adapters and applications can introduce their own data kinds.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004130 * </p>
4131 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004132 * ContactsContract defines a small number of pre-defined data kinds, e.g.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004133 * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
4134 * convenience, these classes define data kind specific aliases for DATA1 etc.
4135 * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
4136 * {@link ContactsContract.Data Data.DATA1}.
4137 * </p>
4138 * <p>
4139 * {@link #DATA1} is an indexed column and should be used for the data element that is
4140 * expected to be most frequently used in query selections. For example, in the
4141 * case of a row representing email addresses {@link #DATA1} should probably
4142 * be used for the email address itself, while {@link #DATA2} etc can be
4143 * used for auxiliary information like type of email address.
4144 * <p>
4145 * <p>
4146 * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
4147 * </p>
4148 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08004149 * The sync adapter for a given account type must correctly handle every data type
4150 * used in the corresponding raw contacts. Otherwise it could result in lost or
4151 * corrupted data.
4152 * </p>
4153 * <p>
4154 * Similarly, you should refrain from introducing new kinds of data for an other
Tom O'Neill244327e2010-01-08 11:11:15 -08004155 * party's account types. For example, if you add a data row for
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004156 * "favorite song" to a raw contact owned by a Google account, it will not
4157 * get synced to the server, because the Google sync adapter does not know
4158 * how to handle this data kind. Thus new data kinds are typically
4159 * introduced along with new account types, i.e. new sync adapters.
4160 * </p>
4161 * <h3>Batch operations</h3>
4162 * <p>
4163 * Data rows can be inserted/updated/deleted using the traditional
4164 * {@link ContentResolver#insert}, {@link ContentResolver#update} and
4165 * {@link ContentResolver#delete} methods, however the newer mechanism based
4166 * on a batch of {@link ContentProviderOperation} will prove to be a better
4167 * choice in almost all cases. All operations in a batch are executed in a
4168 * single transaction, which ensures that the phone-side and server-side
4169 * state of a raw contact are always consistent. Also, the batch-based
4170 * approach is far more efficient: not only are the database operations
4171 * faster when executed in a single transaction, but also sending a batch of
4172 * commands to the content provider saves a lot of time on context switching
4173 * between your process and the process in which the content provider runs.
4174 * </p>
4175 * <p>
4176 * The flip side of using batched operations is that a large batch may lock
4177 * up the database for a long time preventing other applications from
4178 * accessing data and potentially causing ANRs ("Application Not Responding"
4179 * dialogs.)
4180 * </p>
4181 * <p>
4182 * To avoid such lockups of the database, make sure to insert "yield points"
4183 * in the batch. A yield point indicates to the content provider that before
4184 * executing the next operation it can commit the changes that have already
4185 * been made, yield to other requests, open another transaction and continue
4186 * processing operations. A yield point will not automatically commit the
4187 * transaction, but only if there is another request waiting on the
4188 * database. Normally a sync adapter should insert a yield point at the
4189 * beginning of each raw contact operation sequence in the batch. See
4190 * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
4191 * </p>
4192 * <h3>Operations</h3>
4193 * <dl>
4194 * <dt><b>Insert</b></dt>
4195 * <dd>
4196 * <p>
4197 * An individual data row can be inserted using the traditional
4198 * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
4199 * should always be inserted as a batch.
4200 * </p>
4201 * <p>
4202 * An example of a traditional insert:
4203 * <pre>
4204 * ContentValues values = new ContentValues();
4205 * values.put(Data.RAW_CONTACT_ID, rawContactId);
4206 * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
4207 * values.put(Phone.NUMBER, "1-800-GOOG-411");
4208 * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
4209 * values.put(Phone.LABEL, "free directory assistance");
4210 * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
4211 * </pre>
4212 * <p>
4213 * The same done using ContentProviderOperations:
4214 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004215 * ArrayList&lt;ContentProviderOperation&gt; ops =
4216 * new ArrayList&lt;ContentProviderOperation&gt;();
4217 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004218 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
4219 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
4220 * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
4221 * .withValue(Phone.NUMBER, "1-800-GOOG-411")
4222 * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
4223 * .withValue(Phone.LABEL, "free directory assistance")
4224 * .build());
4225 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4226 * </pre>
4227 * </p>
4228 * <dt><b>Update</b></dt>
4229 * <dd>
4230 * <p>
4231 * Just as with insert, update can be done incrementally or as a batch,
4232 * the batch mode being the preferred method:
4233 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004234 * ArrayList&lt;ContentProviderOperation&gt; ops =
4235 * new ArrayList&lt;ContentProviderOperation&gt;();
4236 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004237 * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
4238 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4239 * .withValue(Email.DATA, "somebody@android.com")
4240 * .build());
4241 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4242 * </pre>
4243 * </p>
4244 * </dd>
4245 * <dt><b>Delete</b></dt>
4246 * <dd>
4247 * <p>
4248 * Just as with insert and update, deletion can be done either using the
4249 * {@link ContentResolver#delete} method or using a ContentProviderOperation:
4250 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004251 * ArrayList&lt;ContentProviderOperation&gt; ops =
4252 * new ArrayList&lt;ContentProviderOperation&gt;();
4253 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004254 * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
4255 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4256 * .build());
4257 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4258 * </pre>
4259 * </p>
4260 * </dd>
4261 * <dt><b>Query</b></dt>
4262 * <dd>
4263 * <p>
4264 * <dl>
4265 * <dt>Finding all Data of a given type for a given contact</dt>
4266 * <dd>
4267 * <pre>
4268 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4269 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4270 * Data.CONTACT_ID + &quot;=?&quot; + " AND "
4271 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4272 * new String[] {String.valueOf(contactId)}, null);
4273 * </pre>
4274 * </p>
4275 * <p>
4276 * </dd>
4277 * <dt>Finding all Data of a given type for a given raw contact</dt>
4278 * <dd>
4279 * <pre>
4280 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4281 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4282 * Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
4283 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4284 * new String[] {String.valueOf(rawContactId)}, null);
4285 * </pre>
4286 * </dd>
4287 * <dt>Finding all Data for a given raw contact</dt>
4288 * <dd>
4289 * Most sync adapters will want to read all data rows for a raw contact
4290 * along with the raw contact itself. For that you should use the
4291 * {@link RawContactsEntity}. See also {@link RawContacts}.
4292 * </dd>
4293 * </dl>
4294 * </p>
4295 * </dd>
4296 * </dl>
4297 * <h2>Columns</h2>
Tom O'Neill244327e2010-01-08 11:11:15 -08004298 * <p>
4299 * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you
4300 * should explicitly specify a projection to only those columns that you need.
4301 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004302 * <table class="jd-sumtable">
4303 * <tr>
4304 * <th colspan='4'>Data</th>
4305 * </tr>
4306 * <tr>
4307 * <td style="width: 7em;">long</td>
4308 * <td style="width: 20em;">{@link #_ID}</td>
4309 * <td style="width: 5em;">read-only</td>
4310 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
Tom O'Neill244327e2010-01-08 11:11:15 -08004311 * it would be a bad idea to delete and reinsert a data row. A sync adapter should
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004312 * always do an update instead.</td>
4313 * </tr>
4314 * <tr>
4315 * <td>String</td>
4316 * <td>{@link #MIMETYPE}</td>
4317 * <td>read/write-once</td>
4318 * <td>
4319 * <p>The MIME type of the item represented by this row. Examples of common
4320 * MIME types are:
4321 * <ul>
4322 * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
4323 * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
4324 * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
4325 * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
4326 * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
4327 * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
4328 * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
4329 * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
4330 * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
4331 * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
4332 * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
4333 * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
4334 * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
David Brown846eb302010-08-23 17:40:51 -07004335 * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004336 * </ul>
4337 * </p>
4338 * </td>
4339 * </tr>
4340 * <tr>
4341 * <td>long</td>
4342 * <td>{@link #RAW_CONTACT_ID}</td>
4343 * <td>read/write-once</td>
Tom O'Neill244327e2010-01-08 11:11:15 -08004344 * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004345 * </tr>
4346 * <tr>
4347 * <td>int</td>
4348 * <td>{@link #IS_PRIMARY}</td>
4349 * <td>read/write</td>
4350 * <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 -08004351 * "1" if true, "0" if false.
4352 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004353 * </tr>
4354 * <tr>
4355 * <td>int</td>
4356 * <td>{@link #IS_SUPER_PRIMARY}</td>
4357 * <td>read/write</td>
4358 * <td>Whether this is the primary entry of its kind for the aggregate
4359 * contact it belongs to. Any data record that is "super primary" must
Tom O'Neill244327e2010-01-08 11:11:15 -08004360 * also be "primary". For example, the super-primary entry may be
4361 * interpreted as the default contact value of its kind (for example,
4362 * the default phone number to use for the contact).</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004363 * </tr>
4364 * <tr>
4365 * <td>int</td>
4366 * <td>{@link #DATA_VERSION}</td>
4367 * <td>read-only</td>
4368 * <td>The version of this data record. Whenever the data row changes
4369 * the version goes up. This value is monotonically increasing.</td>
4370 * </tr>
4371 * <tr>
4372 * <td>Any type</td>
4373 * <td>
4374 * {@link #DATA1}<br>
4375 * {@link #DATA2}<br>
4376 * {@link #DATA3}<br>
4377 * {@link #DATA4}<br>
4378 * {@link #DATA5}<br>
4379 * {@link #DATA6}<br>
4380 * {@link #DATA7}<br>
4381 * {@link #DATA8}<br>
4382 * {@link #DATA9}<br>
4383 * {@link #DATA10}<br>
4384 * {@link #DATA11}<br>
4385 * {@link #DATA12}<br>
4386 * {@link #DATA13}<br>
4387 * {@link #DATA14}<br>
4388 * {@link #DATA15}
4389 * </td>
4390 * <td>read/write</td>
Tom O'Neill244327e2010-01-08 11:11:15 -08004391 * <td>
4392 * <p>
4393 * Generic data columns. The meaning of each column is determined by the
4394 * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing
4395 * BLOBs (binary data).
4396 * </p>
4397 * <p>
4398 * Data columns whose meaning is not explicitly defined for a given MIMETYPE
4399 * should not be used. There is no guarantee that any sync adapter will
4400 * preserve them. Sync adapters themselves should not use such columns either,
4401 * but should instead use {@link #SYNC1}-{@link #SYNC4}.
4402 * </p>
4403 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004404 * </tr>
4405 * <tr>
4406 * <td>Any type</td>
4407 * <td>
4408 * {@link #SYNC1}<br>
4409 * {@link #SYNC2}<br>
4410 * {@link #SYNC3}<br>
4411 * {@link #SYNC4}
4412 * </td>
4413 * <td>read/write</td>
4414 * <td>Generic columns for use by sync adapters. For example, a Photo row
4415 * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
4416 * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
4417 * </tr>
4418 * </table>
4419 *
Tom O'Neill244327e2010-01-08 11:11:15 -08004420 * <p>
4421 * Some columns from the most recent associated status update are also available
4422 * through an implicit join.
4423 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004424 * <table class="jd-sumtable">
4425 * <tr>
4426 * <th colspan='4'>Join with {@link StatusUpdates}</th>
4427 * </tr>
4428 * <tr>
4429 * <td style="width: 7em;">int</td>
4430 * <td style="width: 20em;">{@link #PRESENCE}</td>
4431 * <td style="width: 5em;">read-only</td>
4432 * <td>IM presence status linked to this data row. Compare with
4433 * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
4434 * all IM rows. See {@link StatusUpdates} for individual status definitions.
4435 * The provider may choose not to store this value
4436 * in persistent storage. The expectation is that presence status will be
kmccormick50e27c82013-03-28 16:33:11 -07004437 * updated on a regular basis.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004438 * </td>
4439 * </tr>
4440 * <tr>
4441 * <td>String</td>
4442 * <td>{@link #STATUS}</td>
4443 * <td>read-only</td>
4444 * <td>Latest status update linked with this data row.</td>
4445 * </tr>
4446 * <tr>
4447 * <td>long</td>
4448 * <td>{@link #STATUS_TIMESTAMP}</td>
4449 * <td>read-only</td>
4450 * <td>The absolute time in milliseconds when the latest status was
4451 * inserted/updated for this data row.</td>
4452 * </tr>
4453 * <tr>
4454 * <td>String</td>
4455 * <td>{@link #STATUS_RES_PACKAGE}</td>
4456 * <td>read-only</td>
4457 * <td>The package containing resources for this status: label and icon.</td>
4458 * </tr>
4459 * <tr>
4460 * <td>long</td>
4461 * <td>{@link #STATUS_LABEL}</td>
4462 * <td>read-only</td>
4463 * <td>The resource ID of the label describing the source of status update linked
4464 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4465 * </tr>
4466 * <tr>
4467 * <td>long</td>
4468 * <td>{@link #STATUS_ICON}</td>
4469 * <td>read-only</td>
4470 * <td>The resource ID of the icon for the source of the status update linked
4471 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4472 * </tr>
4473 * </table>
4474 *
4475 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004476 * Some columns from the associated raw contact are also available through an
4477 * implicit join. The other columns are excluded as uninteresting in this
4478 * context.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004479 * </p>
4480 *
4481 * <table class="jd-sumtable">
4482 * <tr>
Tom O'Neill244327e2010-01-08 11:11:15 -08004483 * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004484 * </tr>
4485 * <tr>
Tom O'Neill244327e2010-01-08 11:11:15 -08004486 * <td style="width: 7em;">long</td>
4487 * <td style="width: 20em;">{@link #CONTACT_ID}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004488 * <td style="width: 5em;">read-only</td>
Tom O'Neill244327e2010-01-08 11:11:15 -08004489 * <td>The id of the row in the {@link Contacts} table that this data belongs
4490 * to.</td>
4491 * </tr>
4492 * <tr>
4493 * <td>int</td>
4494 * <td>{@link #AGGREGATION_MODE}</td>
4495 * <td>read-only</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004496 * <td>See {@link RawContacts}.</td>
4497 * </tr>
4498 * <tr>
4499 * <td>int</td>
4500 * <td>{@link #DELETED}</td>
4501 * <td>read-only</td>
4502 * <td>See {@link RawContacts}.</td>
4503 * </tr>
4504 * </table>
4505 *
4506 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004507 * The ID column for the associated aggregated contact table
4508 * {@link ContactsContract.Contacts} is available
4509 * via the implicit join to the {@link RawContacts} table, see above.
4510 * The remaining columns from this table are also
4511 * available, through an implicit join. This
4512 * facilitates lookup by
4513 * the value of a single data element, such as the email address.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004514 * </p>
4515 *
4516 * <table class="jd-sumtable">
4517 * <tr>
Tom O'Neill244327e2010-01-08 11:11:15 -08004518 * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004519 * </tr>
4520 * <tr>
4521 * <td style="width: 7em;">String</td>
4522 * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
4523 * <td style="width: 5em;">read-only</td>
4524 * <td>See {@link ContactsContract.Contacts}</td>
4525 * </tr>
4526 * <tr>
4527 * <td>String</td>
4528 * <td>{@link #DISPLAY_NAME}</td>
4529 * <td>read-only</td>
4530 * <td>See {@link ContactsContract.Contacts}</td>
4531 * </tr>
4532 * <tr>
4533 * <td>long</td>
4534 * <td>{@link #PHOTO_ID}</td>
4535 * <td>read-only</td>
4536 * <td>See {@link ContactsContract.Contacts}.</td>
4537 * </tr>
4538 * <tr>
4539 * <td>int</td>
4540 * <td>{@link #IN_VISIBLE_GROUP}</td>
4541 * <td>read-only</td>
4542 * <td>See {@link ContactsContract.Contacts}.</td>
4543 * </tr>
4544 * <tr>
4545 * <td>int</td>
4546 * <td>{@link #HAS_PHONE_NUMBER}</td>
4547 * <td>read-only</td>
4548 * <td>See {@link ContactsContract.Contacts}.</td>
4549 * </tr>
4550 * <tr>
4551 * <td>int</td>
4552 * <td>{@link #TIMES_CONTACTED}</td>
4553 * <td>read-only</td>
4554 * <td>See {@link ContactsContract.Contacts}.</td>
4555 * </tr>
4556 * <tr>
4557 * <td>long</td>
4558 * <td>{@link #LAST_TIME_CONTACTED}</td>
4559 * <td>read-only</td>
4560 * <td>See {@link ContactsContract.Contacts}.</td>
4561 * </tr>
4562 * <tr>
4563 * <td>int</td>
4564 * <td>{@link #STARRED}</td>
4565 * <td>read-only</td>
4566 * <td>See {@link ContactsContract.Contacts}.</td>
4567 * </tr>
4568 * <tr>
4569 * <td>String</td>
4570 * <td>{@link #CUSTOM_RINGTONE}</td>
4571 * <td>read-only</td>
4572 * <td>See {@link ContactsContract.Contacts}.</td>
4573 * </tr>
4574 * <tr>
4575 * <td>int</td>
4576 * <td>{@link #SEND_TO_VOICEMAIL}</td>
4577 * <td>read-only</td>
4578 * <td>See {@link ContactsContract.Contacts}.</td>
4579 * </tr>
4580 * <tr>
4581 * <td>int</td>
4582 * <td>{@link #CONTACT_PRESENCE}</td>
4583 * <td>read-only</td>
4584 * <td>See {@link ContactsContract.Contacts}.</td>
4585 * </tr>
4586 * <tr>
4587 * <td>String</td>
4588 * <td>{@link #CONTACT_STATUS}</td>
4589 * <td>read-only</td>
4590 * <td>See {@link ContactsContract.Contacts}.</td>
4591 * </tr>
4592 * <tr>
4593 * <td>long</td>
4594 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
4595 * <td>read-only</td>
4596 * <td>See {@link ContactsContract.Contacts}.</td>
4597 * </tr>
4598 * <tr>
4599 * <td>String</td>
4600 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
4601 * <td>read-only</td>
4602 * <td>See {@link ContactsContract.Contacts}.</td>
4603 * </tr>
4604 * <tr>
4605 * <td>long</td>
4606 * <td>{@link #CONTACT_STATUS_LABEL}</td>
4607 * <td>read-only</td>
4608 * <td>See {@link ContactsContract.Contacts}.</td>
4609 * </tr>
4610 * <tr>
4611 * <td>long</td>
4612 * <td>{@link #CONTACT_STATUS_ICON}</td>
4613 * <td>read-only</td>
4614 * <td>See {@link ContactsContract.Contacts}.</td>
4615 * </tr>
4616 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004617 */
Yorke Lee94c87612014-07-18 18:57:17 -07004618 public final static class Data implements DataColumnsWithJoins, ContactCounts {
Evan Millar088b2912009-05-28 15:24:37 -07004619 /**
4620 * This utility class cannot be instantiated
4621 */
4622 private Data() {}
4623
4624 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08004625 * The content:// style URI for this table, which requests a directory
4626 * of data rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07004627 */
4628 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
4629
4630 /**
Yorke Lee4f401eb2013-03-06 17:17:17 -08004631 * A boolean parameter for {@link Data#CONTENT_URI}.
4632 * This specifies whether or not the returned data items should be filtered to show
4633 * data items belonging to visible contacts only.
4634 */
4635 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
4636
4637 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08004638 * The MIME type of the results from {@link #CONTENT_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07004639 */
4640 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07004641
4642 /**
Tom O'Neill244327e2010-01-08 11:11:15 -08004643 * <p>
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004644 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
4645 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004646 * entry of the given {@link ContactsContract.Data} entry.
Tom O'Neill244327e2010-01-08 11:11:15 -08004647 * </p>
4648 * <p>
4649 * Returns the Uri for the contact in the first entry returned by
4650 * {@link ContentResolver#query(Uri, String[], String, String[], String)}
4651 * for the provided {@code dataUri}. If the query returns null or empty
4652 * results, silently returns null.
4653 * </p>
Jeff Sharkey6449eb02009-09-16 21:41:51 -07004654 */
4655 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
4656 final Cursor cursor = resolver.query(dataUri, new String[] {
4657 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
4658 }, null, null, null);
4659
4660 Uri lookupUri = null;
4661 try {
4662 if (cursor != null && cursor.moveToFirst()) {
4663 final long contactId = cursor.getLong(0);
4664 final String lookupKey = cursor.getString(1);
4665 return Contacts.getLookupUri(contactId, lookupKey);
4666 }
4667 } finally {
4668 if (cursor != null) cursor.close();
4669 }
4670 return lookupUri;
4671 }
Evan Millar088b2912009-05-28 15:24:37 -07004672 }
4673
Fred Quintana5bba6322009-10-05 14:21:12 -07004674 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004675 * <p>
Tom O'Neill244327e2010-01-08 11:11:15 -08004676 * Constants for the raw contacts entities table, which can be thought of as
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004677 * an outer join of the raw_contacts table with the data table. It is a strictly
4678 * read-only table.
4679 * </p>
4680 * <p>
4681 * If a raw contact has data rows, the RawContactsEntity cursor will contain
4682 * a one row for each data row. If the raw contact has no data rows, the
4683 * cursor will still contain one row with the raw contact-level information
4684 * and nulls for data columns.
4685 *
4686 * <pre>
4687 * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
4688 * Cursor c = getContentResolver().query(entityUri,
4689 * new String[]{
4690 * RawContactsEntity.SOURCE_ID,
4691 * RawContactsEntity.DATA_ID,
4692 * RawContactsEntity.MIMETYPE,
4693 * RawContactsEntity.DATA1
4694 * }, null, null, null);
4695 * try {
4696 * while (c.moveToNext()) {
4697 * String sourceId = c.getString(0);
4698 * if (!c.isNull(1)) {
4699 * String mimeType = c.getString(2);
4700 * String data = c.getString(3);
4701 * ...
4702 * }
4703 * }
4704 * } finally {
4705 * c.close();
4706 * }
4707 * </pre>
4708 *
4709 * <h3>Columns</h3>
4710 * RawContactsEntity has a combination of RawContact and Data columns.
4711 *
4712 * <table class="jd-sumtable">
4713 * <tr>
4714 * <th colspan='4'>RawContacts</th>
4715 * </tr>
4716 * <tr>
4717 * <td style="width: 7em;">long</td>
4718 * <td style="width: 20em;">{@link #_ID}</td>
4719 * <td style="width: 5em;">read-only</td>
4720 * <td>Raw contact row ID. See {@link RawContacts}.</td>
4721 * </tr>
4722 * <tr>
4723 * <td>long</td>
4724 * <td>{@link #CONTACT_ID}</td>
4725 * <td>read-only</td>
4726 * <td>See {@link RawContacts}.</td>
4727 * </tr>
4728 * <tr>
4729 * <td>int</td>
4730 * <td>{@link #AGGREGATION_MODE}</td>
4731 * <td>read-only</td>
4732 * <td>See {@link RawContacts}.</td>
4733 * </tr>
4734 * <tr>
4735 * <td>int</td>
4736 * <td>{@link #DELETED}</td>
4737 * <td>read-only</td>
4738 * <td>See {@link RawContacts}.</td>
4739 * </tr>
4740 * </table>
4741 *
4742 * <table class="jd-sumtable">
4743 * <tr>
4744 * <th colspan='4'>Data</th>
4745 * </tr>
4746 * <tr>
4747 * <td style="width: 7em;">long</td>
4748 * <td style="width: 20em;">{@link #DATA_ID}</td>
4749 * <td style="width: 5em;">read-only</td>
4750 * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
4751 * </tr>
4752 * <tr>
4753 * <td>String</td>
4754 * <td>{@link #MIMETYPE}</td>
4755 * <td>read-only</td>
4756 * <td>See {@link ContactsContract.Data}.</td>
4757 * </tr>
4758 * <tr>
4759 * <td>int</td>
4760 * <td>{@link #IS_PRIMARY}</td>
4761 * <td>read-only</td>
4762 * <td>See {@link ContactsContract.Data}.</td>
4763 * </tr>
4764 * <tr>
4765 * <td>int</td>
4766 * <td>{@link #IS_SUPER_PRIMARY}</td>
4767 * <td>read-only</td>
4768 * <td>See {@link ContactsContract.Data}.</td>
4769 * </tr>
4770 * <tr>
4771 * <td>int</td>
4772 * <td>{@link #DATA_VERSION}</td>
4773 * <td>read-only</td>
4774 * <td>See {@link ContactsContract.Data}.</td>
4775 * </tr>
4776 * <tr>
4777 * <td>Any type</td>
4778 * <td>
4779 * {@link #DATA1}<br>
4780 * {@link #DATA2}<br>
4781 * {@link #DATA3}<br>
4782 * {@link #DATA4}<br>
4783 * {@link #DATA5}<br>
4784 * {@link #DATA6}<br>
4785 * {@link #DATA7}<br>
4786 * {@link #DATA8}<br>
4787 * {@link #DATA9}<br>
4788 * {@link #DATA10}<br>
4789 * {@link #DATA11}<br>
4790 * {@link #DATA12}<br>
4791 * {@link #DATA13}<br>
4792 * {@link #DATA14}<br>
4793 * {@link #DATA15}
4794 * </td>
4795 * <td>read-only</td>
4796 * <td>See {@link ContactsContract.Data}.</td>
4797 * </tr>
4798 * <tr>
4799 * <td>Any type</td>
4800 * <td>
4801 * {@link #SYNC1}<br>
4802 * {@link #SYNC2}<br>
4803 * {@link #SYNC3}<br>
4804 * {@link #SYNC4}
4805 * </td>
4806 * <td>read-only</td>
4807 * <td>See {@link ContactsContract.Data}.</td>
4808 * </tr>
4809 * </table>
Fred Quintana5bba6322009-10-05 14:21:12 -07004810 */
4811 public final static class RawContactsEntity
4812 implements BaseColumns, DataColumns, RawContactsColumns {
4813 /**
4814 * This utility class cannot be instantiated
4815 */
4816 private RawContactsEntity() {}
4817
4818 /**
4819 * The content:// style URI for this table
4820 */
4821 public static final Uri CONTENT_URI =
4822 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
4823
4824 /**
Dave Santoro2b4d0752011-09-07 17:37:33 -07004825 * The content:// style URI for this table, specific to the user's profile.
4826 */
4827 public static final Uri PROFILE_CONTENT_URI =
4828 Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities");
4829
4830 /**
Fred Quintana5bba6322009-10-05 14:21:12 -07004831 * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
4832 */
4833 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
4834
4835 /**
4836 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
4837 * Data.CONTENT_URI contains only exportable data.
4838 *
4839 * This flag is useful (currently) only for vCard exporter in Contacts app, which
4840 * needs to exclude "un-exportable" data from available data to export, while
4841 * Contacts app itself has priviledge to access all data including "un-expotable"
4842 * ones and providers return all of them regardless of the callers' intention.
4843 * <P>Type: INTEGER</p>
4844 *
4845 * @hide Maybe available only in Eclair and not really ready for public use.
4846 * TODO: remove, or implement this feature completely. As of now (Eclair),
4847 * we only use this flag in queryEntities(), not query().
4848 */
4849 public static final String FOR_EXPORT_ONLY = "for_export_only";
4850
4851 /**
4852 * The ID of the data column. The value will be null if this raw contact has no data rows.
4853 * <P>Type: INTEGER</P>
4854 */
4855 public static final String DATA_ID = "data_id";
4856 }
4857
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004858 /**
4859 * @see PhoneLookup
4860 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07004861 protected interface PhoneLookupColumns {
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004862 /**
4863 * The phone number as the user entered it.
4864 * <P>Type: TEXT</P>
4865 */
4866 public static final String NUMBER = "number";
4867
4868 /**
4869 * The type of phone number, for example Home or Work.
4870 * <P>Type: INTEGER</P>
4871 */
4872 public static final String TYPE = "type";
4873
4874 /**
4875 * The user defined label for the phone number.
4876 * <P>Type: TEXT</P>
4877 */
4878 public static final String LABEL = "label";
Bai Tao224744c2010-08-31 09:59:13 +08004879
4880 /**
4881 * The phone number's E164 representation.
4882 * <P>Type: TEXT</P>
Bai Tao224744c2010-08-31 09:59:13 +08004883 */
4884 public static final String NORMALIZED_NUMBER = "normalized_number";
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004885 }
4886
Evan Millar088b2912009-05-28 15:24:37 -07004887 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004888 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004889 * example for caller ID. To perform a lookup you must append the number you
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004890 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly
4891 * optimized.
4892 * <pre>
4893 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
4894 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
4895 * </pre>
4896 *
4897 * <h3>Columns</h3>
4898 *
4899 * <table class="jd-sumtable">
4900 * <tr>
4901 * <th colspan='4'>PhoneLookup</th>
4902 * </tr>
4903 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004904 * <td>String</td>
4905 * <td>{@link #NUMBER}</td>
4906 * <td>read-only</td>
4907 * <td>Phone number.</td>
4908 * </tr>
4909 * <tr>
4910 * <td>String</td>
4911 * <td>{@link #TYPE}</td>
4912 * <td>read-only</td>
4913 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
4914 * </tr>
4915 * <tr>
4916 * <td>String</td>
4917 * <td>{@link #LABEL}</td>
4918 * <td>read-only</td>
4919 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
4920 * </tr>
4921 * </table>
4922 * <p>
4923 * Columns from the Contacts table are also available through a join.
4924 * </p>
4925 * <table class="jd-sumtable">
4926 * <tr>
4927 * <th colspan='4'>Join with {@link Contacts}</th>
4928 * </tr>
4929 * <tr>
Dmitri Plotnikov817b3f92011-01-09 17:07:13 -08004930 * <td>long</td>
4931 * <td>{@link #_ID}</td>
4932 * <td>read-only</td>
4933 * <td>Contact ID.</td>
4934 * </tr>
4935 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004936 * <td>String</td>
4937 * <td>{@link #LOOKUP_KEY}</td>
4938 * <td>read-only</td>
4939 * <td>See {@link ContactsContract.Contacts}</td>
4940 * </tr>
4941 * <tr>
4942 * <td>String</td>
4943 * <td>{@link #DISPLAY_NAME}</td>
4944 * <td>read-only</td>
4945 * <td>See {@link ContactsContract.Contacts}</td>
4946 * </tr>
4947 * <tr>
4948 * <td>long</td>
4949 * <td>{@link #PHOTO_ID}</td>
4950 * <td>read-only</td>
4951 * <td>See {@link ContactsContract.Contacts}.</td>
4952 * </tr>
4953 * <tr>
4954 * <td>int</td>
4955 * <td>{@link #IN_VISIBLE_GROUP}</td>
4956 * <td>read-only</td>
4957 * <td>See {@link ContactsContract.Contacts}.</td>
4958 * </tr>
4959 * <tr>
4960 * <td>int</td>
4961 * <td>{@link #HAS_PHONE_NUMBER}</td>
4962 * <td>read-only</td>
4963 * <td>See {@link ContactsContract.Contacts}.</td>
4964 * </tr>
4965 * <tr>
4966 * <td>int</td>
4967 * <td>{@link #TIMES_CONTACTED}</td>
4968 * <td>read-only</td>
4969 * <td>See {@link ContactsContract.Contacts}.</td>
4970 * </tr>
4971 * <tr>
4972 * <td>long</td>
4973 * <td>{@link #LAST_TIME_CONTACTED}</td>
4974 * <td>read-only</td>
4975 * <td>See {@link ContactsContract.Contacts}.</td>
4976 * </tr>
4977 * <tr>
4978 * <td>int</td>
4979 * <td>{@link #STARRED}</td>
4980 * <td>read-only</td>
4981 * <td>See {@link ContactsContract.Contacts}.</td>
4982 * </tr>
4983 * <tr>
4984 * <td>String</td>
4985 * <td>{@link #CUSTOM_RINGTONE}</td>
4986 * <td>read-only</td>
4987 * <td>See {@link ContactsContract.Contacts}.</td>
4988 * </tr>
4989 * <tr>
4990 * <td>int</td>
4991 * <td>{@link #SEND_TO_VOICEMAIL}</td>
4992 * <td>read-only</td>
4993 * <td>See {@link ContactsContract.Contacts}.</td>
4994 * </tr>
4995 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004996 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004997 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
4998 ContactsColumns, ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -07004999 /**
5000 * This utility class cannot be instantiated
5001 */
5002 private PhoneLookup() {}
5003
5004 /**
5005 * The content:// style URI for this table. Append the phone number you want to lookup
5006 * to this URI and query it to perform a lookup. For example:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005007 * <pre>
Scott Kennedy7ed189e2013-01-11 22:31:43 -08005008 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
5009 * Uri.encode(phoneNumber));
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005010 * </pre>
Evan Millar088b2912009-05-28 15:24:37 -07005011 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005012 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5013 "phone_lookup");
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08005014
5015 /**
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005016 * URI used for the "enterprise caller-id".
5017 *
5018 * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same
5019 * columns. If the device has no corp profile that is linked to the current profile, it
5020 * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile
5021 * linked to the current profile, it first queries against the personal contact database,
5022 * and if no matching contacts are found there, then queries against the
5023 * corp contacts database.
5024 * <p>
5025 * If a result is from the corp profile, it makes the following changes to the data:
5026 * <ul>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005027 * <li>
5028 * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
5029 * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
5030 * load pictures from them.
Makoto Onuki80b3ab62014-07-10 11:24:21 -07005031 * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them.
5032 * </li>
5033 * <li>
5034 * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact
Makoto Onuki0e917332014-08-26 14:06:30 -07005035 * is from the corp profile, use
5036 * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005037 * </li>
5038 * </ul>
Makoto Onuki95a9cfb2014-07-08 17:11:54 -07005039 * <p>
5040 * This URI does NOT support selection nor order-by.
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005041 *
5042 * <pre>
5043 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
5044 * Uri.encode(phoneNumber));
5045 * </pre>
5046 */
5047 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5048 "phone_lookup_enterprise");
5049
5050 /**
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08005051 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows.
5052 *
5053 * @hide
5054 */
5055 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup";
Flavio Lerda52c01c22011-11-02 22:16:23 +00005056
Yorke Lee217d8a72013-11-27 10:14:04 -08005057 /**
5058 * If this boolean parameter is set to true, then the appended query is treated as a
5059 * SIP address and the lookup will be performed against SIP addresses in the user's
5060 * contacts.
5061 */
Flavio Lerda52c01c22011-11-02 22:16:23 +00005062 public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005063 }
5064
5065 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005066 * Additional data mixed in with {@link StatusColumns} to link
5067 * back to specific {@link ContactsContract.Data#_ID} entries.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005068 *
5069 * @see StatusUpdates
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005070 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005071 protected interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -07005072
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005073 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005074 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005075 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005076 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005077 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005078
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005079 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005080 * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07005081 * <p>Type: NUMBER</p>
5082 */
5083 public static final String PROTOCOL = "protocol";
5084
5085 /**
5086 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
5087 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
5088 * omitted if {@link #PROTOCOL} value is not
5089 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
5090 *
5091 * <p>Type: NUMBER</p>
5092 */
5093 public static final String CUSTOM_PROTOCOL = "custom_protocol";
5094
5095 /**
5096 * The IM handle the presence item is for. The handle is scoped to
5097 * {@link #PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005098 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005099 */
5100 public static final String IM_HANDLE = "im_handle";
5101
5102 /**
5103 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005104 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005105 */
5106 public static final String IM_ACCOUNT = "im_account";
5107 }
5108
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005109 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005110 * <p>
5111 * A status update is linked to a {@link ContactsContract.Data} row and captures
5112 * the user's latest status update via the corresponding source, e.g.
5113 * "Having lunch" via "Google Talk".
5114 * </p>
5115 * <p>
5116 * There are two ways a status update can be inserted: by explicitly linking
5117 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
5118 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5119 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use
5120 * either.
5121 * </p>
5122 * <p>
Dave Santoro063084e2011-08-23 15:42:49 -07005123 * Inserting or updating a status update for the user's profile requires either using
5124 * the {@link #DATA_ID} to identify the data row to attach the update to, or
5125 * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the
5126 * profile.
5127 * </p>
5128 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005129 * You cannot use {@link ContentResolver#update} to change a status, but
5130 * {@link ContentResolver#insert} will replace the latests status if it already
5131 * exists.
5132 * </p>
5133 * <p>
5134 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
5135 * for multiple contacts at once.
5136 * </p>
5137 *
5138 * <h3>Columns</h3>
5139 * <table class="jd-sumtable">
5140 * <tr>
5141 * <th colspan='4'>StatusUpdates</th>
5142 * </tr>
5143 * <tr>
5144 * <td>long</td>
5145 * <td>{@link #DATA_ID}</td>
5146 * <td>read/write</td>
5147 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
5148 * field is <i>not</i> specified, the provider will attempt to find a data row
5149 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5150 * {@link #IM_HANDLE} columns.
5151 * </td>
5152 * </tr>
5153 * <tr>
5154 * <td>long</td>
5155 * <td>{@link #PROTOCOL}</td>
5156 * <td>read/write</td>
5157 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
5158 * </tr>
5159 * <tr>
5160 * <td>String</td>
5161 * <td>{@link #CUSTOM_PROTOCOL}</td>
5162 * <td>read/write</td>
5163 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
5164 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
5165 * omitted if {@link #PROTOCOL} value is not
5166 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
5167 * </tr>
5168 * <tr>
5169 * <td>String</td>
5170 * <td>{@link #IM_HANDLE}</td>
5171 * <td>read/write</td>
5172 * <td> The IM handle the presence item is for. The handle is scoped to
5173 * {@link #PROTOCOL}.</td>
5174 * </tr>
5175 * <tr>
5176 * <td>String</td>
5177 * <td>{@link #IM_ACCOUNT}</td>
5178 * <td>read/write</td>
5179 * <td>The IM account for the local user that the presence data came from.</td>
5180 * </tr>
5181 * <tr>
5182 * <td>int</td>
5183 * <td>{@link #PRESENCE}</td>
5184 * <td>read/write</td>
5185 * <td>Contact IM presence status. The allowed values are:
5186 * <p>
5187 * <ul>
5188 * <li>{@link #OFFLINE}</li>
5189 * <li>{@link #INVISIBLE}</li>
5190 * <li>{@link #AWAY}</li>
5191 * <li>{@link #IDLE}</li>
5192 * <li>{@link #DO_NOT_DISTURB}</li>
5193 * <li>{@link #AVAILABLE}</li>
5194 * </ul>
5195 * </p>
5196 * <p>
5197 * Since presence status is inherently volatile, the content provider
5198 * may choose not to store this field in long-term storage.
5199 * </p>
5200 * </td>
5201 * </tr>
5202 * <tr>
Vasu Nori5b314982010-07-12 15:13:37 -07005203 * <td>int</td>
5204 * <td>{@link #CHAT_CAPABILITY}</td>
5205 * <td>read/write</td>
Daniel Lehmannb3327472010-08-13 15:16:11 -07005206 * <td>Contact IM chat compatibility value. The allowed values combinations of the following
5207 * flags. If None of these flags is set, the device can only do text messaging.
Vasu Nori5b314982010-07-12 15:13:37 -07005208 * <p>
5209 * <ul>
Daniel Lehmannb3327472010-08-13 15:16:11 -07005210 * <li>{@link #CAPABILITY_HAS_VIDEO}</li>
Vasu Nori5b314982010-07-12 15:13:37 -07005211 * <li>{@link #CAPABILITY_HAS_VOICE}</li>
5212 * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
5213 * </ul>
5214 * </p>
5215 * <p>
5216 * Since chat compatibility is inherently volatile as the contact's availability moves from
5217 * one device to another, the content provider may choose not to store this field in long-term
5218 * storage.
5219 * </p>
5220 * </td>
5221 * </tr>
5222 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005223 * <td>String</td>
5224 * <td>{@link #STATUS}</td>
5225 * <td>read/write</td>
5226 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
5227 * </tr>
5228 * <tr>
5229 * <td>long</td>
5230 * <td>{@link #STATUS_TIMESTAMP}</td>
5231 * <td>read/write</td>
5232 * <td>The absolute time in milliseconds when the status was
5233 * entered by the user. If this value is not provided, the provider will follow
5234 * this logic: if there was no prior status update, the value will be left as null.
5235 * If there was a prior status update, the provider will default this field
5236 * to the current time.</td>
5237 * </tr>
5238 * <tr>
5239 * <td>String</td>
5240 * <td>{@link #STATUS_RES_PACKAGE}</td>
5241 * <td>read/write</td>
5242 * <td> The package containing resources for this status: label and icon.</td>
5243 * </tr>
5244 * <tr>
5245 * <td>long</td>
5246 * <td>{@link #STATUS_LABEL}</td>
5247 * <td>read/write</td>
5248 * <td>The resource ID of the label describing the source of contact status,
5249 * e.g. "Google Talk". This resource is scoped by the
5250 * {@link #STATUS_RES_PACKAGE}.</td>
5251 * </tr>
5252 * <tr>
5253 * <td>long</td>
5254 * <td>{@link #STATUS_ICON}</td>
5255 * <td>read/write</td>
5256 * <td>The resource ID of the icon for the source of contact status. This
5257 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
5258 * </tr>
5259 * </table>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005260 */
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005261 public static class StatusUpdates implements StatusColumns, PresenceColumns {
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005262
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005263 /**
5264 * This utility class cannot be instantiated
5265 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005266 private StatusUpdates() {}
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005267
5268 /**
5269 * The content:// style URI for this table
5270 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005271 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005272
5273 /**
Dave Santoro063084e2011-08-23 15:42:49 -07005274 * The content:// style URI for this table, specific to the user's profile.
5275 */
5276 public static final Uri PROFILE_CONTENT_URI =
5277 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates");
5278
5279 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005280 * Gets the resource ID for the proper presence icon.
5281 *
5282 * @param status the status to get the icon for
5283 * @return the resource ID for the proper presence icon
5284 */
5285 public static final int getPresenceIconResourceId(int status) {
5286 switch (status) {
5287 case AVAILABLE:
5288 return android.R.drawable.presence_online;
5289 case IDLE:
5290 case AWAY:
5291 return android.R.drawable.presence_away;
5292 case DO_NOT_DISTURB:
5293 return android.R.drawable.presence_busy;
5294 case INVISIBLE:
5295 return android.R.drawable.presence_invisible;
5296 case OFFLINE:
5297 default:
5298 return android.R.drawable.presence_offline;
5299 }
5300 }
5301
5302 /**
Evan Millarc0437522009-06-23 17:31:05 -07005303 * Returns the precedence of the status code the higher number being the higher precedence.
5304 *
5305 * @param status The status code.
5306 * @return An integer representing the precedence, 0 being the lowest.
5307 */
5308 public static final int getPresencePrecedence(int status) {
5309 // Keep this function here incase we want to enforce a different precedence than the
5310 // natural order of the status constants.
5311 return status;
5312 }
5313
5314 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005315 * The MIME type of {@link #CONTENT_URI} providing a directory of
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005316 * status update details.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005317 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005318 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005319
5320 /**
5321 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005322 * status update detail.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005323 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005324 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
5325 }
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005326
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005327 /**
5328 * @deprecated This old name was never meant to be made public. Do not use.
5329 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005330 @Deprecated
5331 public static final class Presence extends StatusUpdates {
5332
Evan Millar088b2912009-05-28 15:24:37 -07005333 }
5334
5335 /**
Yorke Lee8d370092014-06-26 10:32:17 -07005336 * Additional column returned by
5337 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining
Yorke Leeeaf09492014-07-01 10:28:56 -07005338 * why the filter matched the contact. This column will contain extracts from the contact's
5339 * constituent {@link Data Data} items, formatted in a way that indicates the section of the
5340 * snippet that matched the filter.
5341 *
5342 * <p>
5343 * The following example searches for all contacts that match the query "presi" and requests
5344 * the snippet column as well.
5345 * <pre>
5346 * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
5347 * builder.appendPath("presi");
5348 * // Defer snippeting to the client side if possible, for performance reasons.
5349 * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");
5350 *
5351 * Cursor cursor = getContentResolver().query(builder.build());
5352 *
5353 * Bundle extras = cursor.getExtras();
5354 * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
5355 * // Do our own snippet formatting.
5356 * // For a contact with the email address (president@organization.com), the snippet
5357 * // column will contain the string "president@organization.com".
5358 * } else {
5359 * // The snippet has already been pre-formatted, we can display it as is.
5360 * // For a contact with the email address (president@organization.com), the snippet
5361 * // column will contain the string "[presi]dent@organization.com".
5362 * }
5363 * </pre>
5364 * </p>
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005365 */
Yorke Leeeaf09492014-07-01 10:28:56 -07005366 public static class SearchSnippets {
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005367
5368 /**
Yorke Leeeaf09492014-07-01 10:28:56 -07005369 * The search snippet constructed by SQLite snippeting functionality.
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005370 * <p>
Yorke Leeeaf09492014-07-01 10:28:56 -07005371 * The snippet may contain (parts of) several data elements belonging to the contact,
5372 * with the matching parts optionally surrounded by special characters that indicate the
5373 * start and end of matching text.
5374 *
5375 * For example, if a contact has an address "123 Main Street", using a filter "mai" would
5376 * return the formatted snippet "123 [Mai]n street".
5377 *
5378 * @see <a href="http://www.sqlite.org/fts3.html#snippet">
5379 * http://www.sqlite.org/fts3.html#snippet</a>
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005380 */
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005381 public static final String SNIPPET = "snippet";
5382
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005383 /**
5384 * Comma-separated parameters for the generation of the snippet:
5385 * <ul>
Yorke Leeeaf09492014-07-01 10:28:56 -07005386 * <li>The "start match" text. Default is '['</li>
5387 * <li>The "end match" text. Default is ']'</li>
5388 * <li>The "ellipsis" text. Default is "..."</li>
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005389 * <li>Maximum number of tokens to include in the snippet. Can be either
5390 * a positive or a negative number: A positive number indicates how many
5391 * tokens can be returned in total. A negative number indicates how many
5392 * tokens can be returned per occurrence of the search terms.</li>
5393 * </ul>
Yorke Leeeaf09492014-07-01 10:28:56 -07005394 *
5395 * @hide
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005396 */
5397 public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args";
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005398
5399 /**
Yorke Leeeaf09492014-07-01 10:28:56 -07005400 * The key to ask the provider to defer the formatting of the snippet to the client if
5401 * possible, for performance reasons.
5402 * A value of 1 indicates true, 0 indicates false. False is the default.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005403 * When a cursor is returned to the client, it should check for an extra with the name
5404 * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client
Yorke Leeeaf09492014-07-01 10:28:56 -07005405 * should do its own formatting of the snippet. If it doesn't exist, the snippet column
5406 * in the cursor should already contain a formatted snippet.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005407 */
5408 public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting";
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005409 }
5410
5411 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005412 * Container for definitions of common data types stored in the {@link ContactsContract.Data}
5413 * table.
Evan Millar088b2912009-05-28 15:24:37 -07005414 */
5415 public static final class CommonDataKinds {
5416 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005417 * This utility class cannot be instantiated
5418 */
5419 private CommonDataKinds() {}
5420
5421 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005422 * The {@link Data#RES_PACKAGE} value for common data that should be
5423 * shown using a default style.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005424 *
5425 * @hide RES_PACKAGE is hidden
Evan Millar088b2912009-05-28 15:24:37 -07005426 */
5427 public static final String PACKAGE_COMMON = "common";
5428
5429 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005430 * The base types that all "Typed" data kinds support.
5431 */
5432 public interface BaseTypes {
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005433 /**
5434 * A custom type. The custom label should be supplied by user.
5435 */
5436 public static int TYPE_CUSTOM = 0;
5437 }
5438
5439 /**
Evan Millar088b2912009-05-28 15:24:37 -07005440 * Columns common across the specific types.
5441 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005442 protected interface CommonColumns extends BaseTypes {
Evan Millar088b2912009-05-28 15:24:37 -07005443 /**
Evan Millar088b2912009-05-28 15:24:37 -07005444 * The data for the contact method.
5445 * <P>Type: TEXT</P>
5446 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005447 public static final String DATA = DataColumns.DATA1;
5448
5449 /**
5450 * The type of data, for example Home or Work.
5451 * <P>Type: INTEGER</P>
5452 */
5453 public static final String TYPE = DataColumns.DATA2;
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005454
5455 /**
5456 * The user defined label for the the contact method.
5457 * <P>Type: TEXT</P>
5458 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005459 public static final String LABEL = DataColumns.DATA3;
Evan Millar088b2912009-05-28 15:24:37 -07005460 }
5461
5462 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005463 * A data kind representing the contact's proper name. You can use all
5464 * columns defined for {@link ContactsContract.Data} as well as the following aliases.
5465 *
5466 * <h2>Column aliases</h2>
5467 * <table class="jd-sumtable">
5468 * <tr>
5469 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5470 * </tr>
5471 * <tr>
5472 * <td>String</td>
5473 * <td>{@link #DISPLAY_NAME}</td>
5474 * <td>{@link #DATA1}</td>
5475 * <td></td>
5476 * </tr>
5477 * <tr>
5478 * <td>String</td>
5479 * <td>{@link #GIVEN_NAME}</td>
5480 * <td>{@link #DATA2}</td>
5481 * <td></td>
5482 * </tr>
5483 * <tr>
5484 * <td>String</td>
5485 * <td>{@link #FAMILY_NAME}</td>
5486 * <td>{@link #DATA3}</td>
5487 * <td></td>
5488 * </tr>
5489 * <tr>
5490 * <td>String</td>
5491 * <td>{@link #PREFIX}</td>
5492 * <td>{@link #DATA4}</td>
5493 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
5494 * </tr>
5495 * <tr>
5496 * <td>String</td>
5497 * <td>{@link #MIDDLE_NAME}</td>
5498 * <td>{@link #DATA5}</td>
5499 * <td></td>
5500 * </tr>
5501 * <tr>
5502 * <td>String</td>
5503 * <td>{@link #SUFFIX}</td>
5504 * <td>{@link #DATA6}</td>
5505 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
5506 * </tr>
5507 * <tr>
5508 * <td>String</td>
5509 * <td>{@link #PHONETIC_GIVEN_NAME}</td>
5510 * <td>{@link #DATA7}</td>
5511 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
5512 * </tr>
5513 * <tr>
5514 * <td>String</td>
5515 * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
5516 * <td>{@link #DATA8}</td>
5517 * <td></td>
5518 * </tr>
5519 * <tr>
5520 * <td>String</td>
5521 * <td>{@link #PHONETIC_FAMILY_NAME}</td>
5522 * <td>{@link #DATA9}</td>
5523 * <td></td>
5524 * </tr>
5525 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005526 */
Yorke Lee94c87612014-07-18 18:57:17 -07005527 public static final class StructuredName implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005528 /**
5529 * This utility class cannot be instantiated
5530 */
Evan Millar088b2912009-05-28 15:24:37 -07005531 private StructuredName() {}
5532
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005533 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005534 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
5535
5536 /**
Evan Millar088b2912009-05-28 15:24:37 -07005537 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -07005538 * <i>Unstructured component of the name should be consistent with
5539 * its structured representation.</i>
5540 * <p>
5541 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -07005542 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005543 public static final String DISPLAY_NAME = DATA1;
5544
5545 /**
5546 * The given name for the contact.
5547 * <P>Type: TEXT</P>
5548 */
5549 public static final String GIVEN_NAME = DATA2;
5550
5551 /**
5552 * The family name for the contact.
5553 * <P>Type: TEXT</P>
5554 */
5555 public static final String FAMILY_NAME = DATA3;
5556
5557 /**
5558 * The contact's honorific prefix, e.g. "Sir"
5559 * <P>Type: TEXT</P>
5560 */
5561 public static final String PREFIX = DATA4;
5562
5563 /**
5564 * The contact's middle name
5565 * <P>Type: TEXT</P>
5566 */
5567 public static final String MIDDLE_NAME = DATA5;
5568
5569 /**
5570 * The contact's honorific suffix, e.g. "Jr"
5571 */
5572 public static final String SUFFIX = DATA6;
5573
5574 /**
5575 * The phonetic version of the given name for the contact.
5576 * <P>Type: TEXT</P>
5577 */
5578 public static final String PHONETIC_GIVEN_NAME = DATA7;
5579
5580 /**
5581 * The phonetic version of the additional name for the contact.
5582 * <P>Type: TEXT</P>
5583 */
5584 public static final String PHONETIC_MIDDLE_NAME = DATA8;
5585
5586 /**
5587 * The phonetic version of the family name for the contact.
5588 * <P>Type: TEXT</P>
5589 */
5590 public static final String PHONETIC_FAMILY_NAME = DATA9;
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005591
5592 /**
5593 * The style used for combining given/middle/family name into a full name.
5594 * See {@link ContactsContract.FullNameStyle}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005595 */
5596 public static final String FULL_NAME_STYLE = DATA10;
5597
5598 /**
5599 * The alphabet used for capturing the phonetic name.
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08005600 * See ContactsContract.PhoneticNameStyle.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005601 * @hide
5602 */
5603 public static final String PHONETIC_NAME_STYLE = DATA11;
Evan Millar088b2912009-05-28 15:24:37 -07005604 }
5605
5606 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005607 * <p>A data kind representing the contact's nickname. For example, for
5608 * Bob Parr ("Mr. Incredible"):
5609 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07005610 * ArrayList&lt;ContentProviderOperation&gt; ops =
5611 * new ArrayList&lt;ContentProviderOperation&gt;();
5612 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005613 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5614 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
5615 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
5616 * .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
5617 * .build());
5618 *
5619 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5620 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
5621 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
5622 * .withValue(Nickname.NAME, "Mr. Incredible")
5623 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
5624 * .withValue(Nickname.LABEL, "Superhero")
5625 * .build());
5626 *
5627 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
5628 * </pre>
5629 * </p>
5630 * <p>
5631 * You can use all columns defined for {@link ContactsContract.Data} as well as the
5632 * following aliases.
5633 * </p>
5634 *
5635 * <h2>Column aliases</h2>
5636 * <table class="jd-sumtable">
5637 * <tr>
5638 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5639 * </tr>
5640 * <tr>
5641 * <td>String</td>
5642 * <td>{@link #NAME}</td>
5643 * <td>{@link #DATA1}</td>
5644 * <td></td>
5645 * </tr>
5646 * <tr>
5647 * <td>int</td>
5648 * <td>{@link #TYPE}</td>
5649 * <td>{@link #DATA2}</td>
5650 * <td>
5651 * Allowed values are:
5652 * <p>
5653 * <ul>
5654 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5655 * <li>{@link #TYPE_DEFAULT}</li>
5656 * <li>{@link #TYPE_OTHER_NAME}</li>
David Brown747c6152010-09-15 13:34:13 -07005657 * <li>{@link #TYPE_MAIDEN_NAME}</li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005658 * <li>{@link #TYPE_SHORT_NAME}</li>
5659 * <li>{@link #TYPE_INITIALS}</li>
5660 * </ul>
5661 * </p>
5662 * </td>
5663 * </tr>
5664 * <tr>
5665 * <td>String</td>
5666 * <td>{@link #LABEL}</td>
5667 * <td>{@link #DATA3}</td>
5668 * <td></td>
5669 * </tr>
5670 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005671 */
Yorke Lee94c87612014-07-18 18:57:17 -07005672 public static final class Nickname implements DataColumnsWithJoins, CommonColumns,
5673 ContactCounts{
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005674 /**
5675 * This utility class cannot be instantiated
5676 */
Evan Millar088b2912009-05-28 15:24:37 -07005677 private Nickname() {}
5678
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005679 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005680 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
5681
Evan Millar78e79ad2009-06-08 10:24:44 -07005682 public static final int TYPE_DEFAULT = 1;
5683 public static final int TYPE_OTHER_NAME = 2;
David Brown747c6152010-09-15 13:34:13 -07005684 public static final int TYPE_MAIDEN_NAME = 3;
5685 /** @deprecated Use TYPE_MAIDEN_NAME instead. */
5686 @Deprecated
Evan Millar78e79ad2009-06-08 10:24:44 -07005687 public static final int TYPE_MAINDEN_NAME = 3;
5688 public static final int TYPE_SHORT_NAME = 4;
5689 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -07005690
5691 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005692 * The name itself
5693 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005694 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07005695 }
5696
5697 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005698 * <p>
5699 * A data kind representing a telephone number.
5700 * </p>
5701 * <p>
5702 * You can use all columns defined for {@link ContactsContract.Data} as
5703 * well as the following aliases.
5704 * </p>
5705 * <h2>Column aliases</h2>
5706 * <table class="jd-sumtable">
5707 * <tr>
5708 * <th>Type</th>
5709 * <th>Alias</th><th colspan='2'>Data column</th>
5710 * </tr>
5711 * <tr>
5712 * <td>String</td>
5713 * <td>{@link #NUMBER}</td>
5714 * <td>{@link #DATA1}</td>
5715 * <td></td>
5716 * </tr>
5717 * <tr>
5718 * <td>int</td>
5719 * <td>{@link #TYPE}</td>
5720 * <td>{@link #DATA2}</td>
5721 * <td>Allowed values are:
5722 * <p>
5723 * <ul>
5724 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5725 * <li>{@link #TYPE_HOME}</li>
5726 * <li>{@link #TYPE_MOBILE}</li>
5727 * <li>{@link #TYPE_WORK}</li>
5728 * <li>{@link #TYPE_FAX_WORK}</li>
5729 * <li>{@link #TYPE_FAX_HOME}</li>
5730 * <li>{@link #TYPE_PAGER}</li>
5731 * <li>{@link #TYPE_OTHER}</li>
5732 * <li>{@link #TYPE_CALLBACK}</li>
5733 * <li>{@link #TYPE_CAR}</li>
5734 * <li>{@link #TYPE_COMPANY_MAIN}</li>
5735 * <li>{@link #TYPE_ISDN}</li>
5736 * <li>{@link #TYPE_MAIN}</li>
5737 * <li>{@link #TYPE_OTHER_FAX}</li>
5738 * <li>{@link #TYPE_RADIO}</li>
5739 * <li>{@link #TYPE_TELEX}</li>
5740 * <li>{@link #TYPE_TTY_TDD}</li>
5741 * <li>{@link #TYPE_WORK_MOBILE}</li>
5742 * <li>{@link #TYPE_WORK_PAGER}</li>
5743 * <li>{@link #TYPE_ASSISTANT}</li>
5744 * <li>{@link #TYPE_MMS}</li>
5745 * </ul>
5746 * </p>
5747 * </td>
5748 * </tr>
5749 * <tr>
5750 * <td>String</td>
5751 * <td>{@link #LABEL}</td>
5752 * <td>{@link #DATA3}</td>
5753 * <td></td>
5754 * </tr>
5755 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005756 */
Yorke Lee94c87612014-07-18 18:57:17 -07005757 public static final class Phone implements DataColumnsWithJoins, CommonColumns,
5758 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005759 /**
5760 * This utility class cannot be instantiated
5761 */
Evan Millar088b2912009-05-28 15:24:37 -07005762 private Phone() {}
5763
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005764 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07005765 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
Evan Millar088b2912009-05-28 15:24:37 -07005766
Evan Millar161dd862009-06-12 16:02:43 -07005767 /**
5768 * The MIME type of {@link #CONTENT_URI} providing a directory of
5769 * phones.
5770 */
Evan Millarb3c49982009-09-01 11:38:04 -07005771 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
Evan Millar161dd862009-06-12 16:02:43 -07005772
5773 /**
5774 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005775 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07005776 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -07005777 */
5778 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
5779 "phones");
5780
5781 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005782 * The content:// style URL for phone lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005783 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005784 * to display names as well as phone numbers. The filter argument should be passed
5785 * as an additional path segment after this URI.
Evan Millar161dd862009-06-12 16:02:43 -07005786 */
5787 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
5788 "filter");
5789
Daniel Lehmann1024de52012-06-15 20:32:33 -07005790 /**
5791 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
5792 * If "1" or "true", display names are searched. If "0" or "false", display names
5793 * are not searched. Default is "1".
5794 */
5795 public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name";
5796
5797 /**
5798 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
5799 * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers
5800 * are not searched. Default is "1".
5801 */
5802 public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number";
5803
Evan Millar088b2912009-05-28 15:24:37 -07005804 public static final int TYPE_HOME = 1;
5805 public static final int TYPE_MOBILE = 2;
5806 public static final int TYPE_WORK = 3;
5807 public static final int TYPE_FAX_WORK = 4;
5808 public static final int TYPE_FAX_HOME = 5;
5809 public static final int TYPE_PAGER = 6;
5810 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -07005811 public static final int TYPE_CALLBACK = 8;
5812 public static final int TYPE_CAR = 9;
5813 public static final int TYPE_COMPANY_MAIN = 10;
5814 public static final int TYPE_ISDN = 11;
5815 public static final int TYPE_MAIN = 12;
5816 public static final int TYPE_OTHER_FAX = 13;
5817 public static final int TYPE_RADIO = 14;
5818 public static final int TYPE_TELEX = 15;
5819 public static final int TYPE_TTY_TDD = 16;
5820 public static final int TYPE_WORK_MOBILE = 17;
5821 public static final int TYPE_WORK_PAGER = 18;
5822 public static final int TYPE_ASSISTANT = 19;
Jeff Sharkeyd5abd462009-09-16 19:54:29 -07005823 public static final int TYPE_MMS = 20;
Evan Millar088b2912009-05-28 15:24:37 -07005824
5825 /**
5826 * The phone number as the user entered it.
5827 * <P>Type: TEXT</P>
5828 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005829 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005830
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005831 /**
Daniel Lehmanndb919152012-03-09 14:30:50 -08005832 * The phone number's E164 representation. This value can be omitted in which
Makoto Onukie5420e92012-04-25 13:24:41 -07005833 * case the provider will try to automatically infer it. (It'll be left null if the
5834 * provider fails to infer.)
5835 * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise).
Bai Tao224744c2010-08-31 09:59:13 +08005836 * <P>Type: TEXT</P>
Bai Tao224744c2010-08-31 09:59:13 +08005837 */
5838 public static final String NORMALIZED_NUMBER = DATA4;
5839
5840 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005841 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005842 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005843 */
5844 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005845 public static final CharSequence getDisplayLabel(Context context, int type,
5846 CharSequence label, CharSequence[] labelArray) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005847 return getTypeLabel(context.getResources(), type, label);
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005848 }
5849
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005850 /**
5851 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005852 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005853 */
5854 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005855 public static final CharSequence getDisplayLabel(Context context, int type,
5856 CharSequence label) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005857 return getTypeLabel(context.getResources(), type, label);
5858 }
5859
5860 /**
5861 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005862 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005863 */
5864 public static final int getTypeLabelResource(int type) {
5865 switch (type) {
5866 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
5867 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
5868 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
5869 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
5870 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
5871 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
5872 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
5873 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
5874 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
5875 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
5876 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
5877 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
5878 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
5879 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
5880 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
5881 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
5882 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
5883 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
5884 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
5885 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
5886 default: return com.android.internal.R.string.phoneTypeCustom;
5887 }
5888 }
5889
5890 /**
5891 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005892 * possibly substituting the given {@link #LABEL} value
5893 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005894 */
5895 public static final CharSequence getTypeLabel(Resources res, int type,
5896 CharSequence label) {
5897 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
5898 return label;
5899 } else {
5900 final int labelRes = getTypeLabelResource(type);
5901 return res.getText(labelRes);
5902 }
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005903 }
Evan Millar088b2912009-05-28 15:24:37 -07005904 }
5905
5906 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005907 * <p>
5908 * A data kind representing an email address.
5909 * </p>
5910 * <p>
5911 * You can use all columns defined for {@link ContactsContract.Data} as
5912 * well as the following aliases.
5913 * </p>
5914 * <h2>Column aliases</h2>
5915 * <table class="jd-sumtable">
5916 * <tr>
5917 * <th>Type</th>
5918 * <th>Alias</th><th colspan='2'>Data column</th>
5919 * </tr>
5920 * <tr>
5921 * <td>String</td>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07005922 * <td>{@link #ADDRESS}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005923 * <td>{@link #DATA1}</td>
5924 * <td>Email address itself.</td>
5925 * </tr>
5926 * <tr>
5927 * <td>int</td>
5928 * <td>{@link #TYPE}</td>
5929 * <td>{@link #DATA2}</td>
5930 * <td>Allowed values are:
5931 * <p>
5932 * <ul>
5933 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5934 * <li>{@link #TYPE_HOME}</li>
5935 * <li>{@link #TYPE_WORK}</li>
5936 * <li>{@link #TYPE_OTHER}</li>
5937 * <li>{@link #TYPE_MOBILE}</li>
5938 * </ul>
5939 * </p>
5940 * </td>
5941 * </tr>
5942 * <tr>
5943 * <td>String</td>
5944 * <td>{@link #LABEL}</td>
5945 * <td>{@link #DATA3}</td>
5946 * <td></td>
5947 * </tr>
5948 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005949 */
Yorke Lee94c87612014-07-18 18:57:17 -07005950 public static final class Email implements DataColumnsWithJoins, CommonColumns,
5951 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005952 /**
5953 * This utility class cannot be instantiated
5954 */
Evan Millar088b2912009-05-28 15:24:37 -07005955 private Email() {}
5956
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005957 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07005958 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
Evan Millar088b2912009-05-28 15:24:37 -07005959
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005960 /**
Dmitri Plotnikovabf15c32009-09-18 20:29:11 -07005961 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
5962 */
5963 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
5964
5965 /**
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005966 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005967 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005968 * associated raw contact and aggregate contact data.
5969 */
5970 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
5971 "emails");
5972
5973 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005974 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005975 * The content:// style URL for looking up data rows by email address. The
5976 * lookup argument, an email address, should be passed as an additional path segment
5977 * after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005978 * </p>
5979 * <p>Example:
5980 * <pre>
5981 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
5982 * Cursor c = getContentResolver().query(uri,
5983 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
5984 * null, null, null);
5985 * </pre>
5986 * </p>
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005987 */
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005988 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
5989 "lookup");
5990
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005991 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005992 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005993 * The content:// style URL for email lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005994 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005995 * to display names as well as email addresses. The filter argument should be passed
5996 * as an additional path segment after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005997 * </p>
5998 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)"
5999 * as well as "Bob Parr (incredible@android.com)".
6000 * <pre>
6001 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
6002 * Cursor c = getContentResolver().query(uri,
6003 * new String[]{Email.DISPLAY_NAME, Email.DATA},
6004 * null, null, null);
6005 * </pre>
6006 * </p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07006007 */
6008 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006009 "filter");
6010
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006011 /**
6012 * The email address.
6013 * <P>Type: TEXT</P>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006014 */
6015 public static final String ADDRESS = DATA1;
6016
Evan Millar088b2912009-05-28 15:24:37 -07006017 public static final int TYPE_HOME = 1;
6018 public static final int TYPE_WORK = 2;
6019 public static final int TYPE_OTHER = 3;
Jeff Sharkey14fb1532009-08-29 15:54:26 -07006020 public static final int TYPE_MOBILE = 4;
Fred Quintana8851e162009-08-05 21:06:45 -07006021
6022 /**
6023 * The display name for the email address
6024 * <P>Type: TEXT</P>
6025 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006026 public static final String DISPLAY_NAME = DATA4;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006027
6028 /**
6029 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006030 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006031 */
6032 public static final int getTypeLabelResource(int type) {
6033 switch (type) {
6034 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
6035 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
6036 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
6037 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
6038 default: return com.android.internal.R.string.emailTypeCustom;
6039 }
6040 }
6041
6042 /**
6043 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006044 * possibly substituting the given {@link #LABEL} value
6045 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006046 */
6047 public static final CharSequence getTypeLabel(Resources res, int type,
6048 CharSequence label) {
6049 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6050 return label;
6051 } else {
6052 final int labelRes = getTypeLabelResource(type);
6053 return res.getText(labelRes);
6054 }
6055 }
Evan Millar088b2912009-05-28 15:24:37 -07006056 }
6057
6058 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006059 * <p>
6060 * A data kind representing a postal addresses.
6061 * </p>
6062 * <p>
6063 * You can use all columns defined for {@link ContactsContract.Data} as
6064 * well as the following aliases.
6065 * </p>
6066 * <h2>Column aliases</h2>
6067 * <table class="jd-sumtable">
6068 * <tr>
6069 * <th>Type</th>
6070 * <th>Alias</th><th colspan='2'>Data column</th>
6071 * </tr>
6072 * <tr>
6073 * <td>String</td>
6074 * <td>{@link #FORMATTED_ADDRESS}</td>
6075 * <td>{@link #DATA1}</td>
6076 * <td></td>
6077 * </tr>
6078 * <tr>
6079 * <td>int</td>
6080 * <td>{@link #TYPE}</td>
6081 * <td>{@link #DATA2}</td>
6082 * <td>Allowed values are:
6083 * <p>
6084 * <ul>
6085 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6086 * <li>{@link #TYPE_HOME}</li>
6087 * <li>{@link #TYPE_WORK}</li>
6088 * <li>{@link #TYPE_OTHER}</li>
6089 * </ul>
6090 * </p>
6091 * </td>
6092 * </tr>
6093 * <tr>
6094 * <td>String</td>
6095 * <td>{@link #LABEL}</td>
6096 * <td>{@link #DATA3}</td>
6097 * <td></td>
6098 * </tr>
6099 * <tr>
6100 * <td>String</td>
6101 * <td>{@link #STREET}</td>
6102 * <td>{@link #DATA4}</td>
6103 * <td></td>
6104 * </tr>
6105 * <tr>
6106 * <td>String</td>
6107 * <td>{@link #POBOX}</td>
6108 * <td>{@link #DATA5}</td>
6109 * <td>Post Office Box number</td>
6110 * </tr>
6111 * <tr>
6112 * <td>String</td>
6113 * <td>{@link #NEIGHBORHOOD}</td>
6114 * <td>{@link #DATA6}</td>
6115 * <td></td>
6116 * </tr>
6117 * <tr>
6118 * <td>String</td>
6119 * <td>{@link #CITY}</td>
6120 * <td>{@link #DATA7}</td>
6121 * <td></td>
6122 * </tr>
6123 * <tr>
6124 * <td>String</td>
6125 * <td>{@link #REGION}</td>
6126 * <td>{@link #DATA8}</td>
6127 * <td></td>
6128 * </tr>
6129 * <tr>
6130 * <td>String</td>
6131 * <td>{@link #POSTCODE}</td>
6132 * <td>{@link #DATA9}</td>
6133 * <td></td>
6134 * </tr>
6135 * <tr>
6136 * <td>String</td>
6137 * <td>{@link #COUNTRY}</td>
6138 * <td>{@link #DATA10}</td>
6139 * <td></td>
6140 * </tr>
6141 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006142 */
Yorke Lee94c87612014-07-18 18:57:17 -07006143 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns,
6144 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006145 /**
6146 * This utility class cannot be instantiated
6147 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006148 private StructuredPostal() {
6149 }
Evan Millar088b2912009-05-28 15:24:37 -07006150
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006151 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07006152 public static final String CONTENT_ITEM_TYPE =
6153 "vnd.android.cursor.item/postal-address_v2";
Evan Millar088b2912009-05-28 15:24:37 -07006154
Evan Millar161dd862009-06-12 16:02:43 -07006155 /**
6156 * The MIME type of {@link #CONTENT_URI} providing a directory of
6157 * postal addresses.
6158 */
Evan Millarb3c49982009-09-01 11:38:04 -07006159 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
Evan Millar161dd862009-06-12 16:02:43 -07006160
6161 /**
6162 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006163 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07006164 */
6165 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6166 "postals");
6167
Evan Millar088b2912009-05-28 15:24:37 -07006168 public static final int TYPE_HOME = 1;
6169 public static final int TYPE_WORK = 2;
6170 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006171
6172 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07006173 * The full, unstructured postal address. <i>This field must be
6174 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006175 * <p>
6176 * Type: TEXT
6177 */
6178 public static final String FORMATTED_ADDRESS = DATA;
6179
6180 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006181 * Can be street, avenue, road, etc. This element also includes the
6182 * house number and room/apartment/flat/floor number.
6183 * <p>
6184 * Type: TEXT
6185 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006186 public static final String STREET = DATA4;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006187
6188 /**
6189 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
6190 * usually but not always mutually exclusive with street.
6191 * <p>
6192 * Type: TEXT
6193 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006194 public static final String POBOX = DATA5;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006195
6196 /**
6197 * This is used to disambiguate a street address when a city
6198 * contains more than one street with the same name, or to specify a
6199 * small place whose mail is routed through a larger postal town. In
6200 * China it could be a county or a minor city.
6201 * <p>
6202 * Type: TEXT
6203 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006204 public static final String NEIGHBORHOOD = DATA6;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006205
6206 /**
6207 * Can be city, village, town, borough, etc. This is the postal town
6208 * and not necessarily the place of residence or place of business.
6209 * <p>
6210 * Type: TEXT
6211 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006212 public static final String CITY = DATA7;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006213
6214 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006215 * A state, province, county (in Ireland), Land (in Germany),
6216 * departement (in France), etc.
6217 * <p>
6218 * Type: TEXT
6219 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006220 public static final String REGION = DATA8;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006221
6222 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07006223 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006224 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
6225 * <p>
6226 * Type: TEXT
6227 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006228 public static final String POSTCODE = DATA9;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006229
6230 /**
6231 * The name or code of the country.
6232 * <p>
6233 * Type: TEXT
6234 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006235 public static final String COUNTRY = DATA10;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006236
6237 /**
6238 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006239 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006240 */
6241 public static final int getTypeLabelResource(int type) {
6242 switch (type) {
6243 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
6244 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
6245 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
6246 default: return com.android.internal.R.string.postalTypeCustom;
6247 }
6248 }
6249
6250 /**
6251 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006252 * possibly substituting the given {@link #LABEL} value
6253 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006254 */
6255 public static final CharSequence getTypeLabel(Resources res, int type,
6256 CharSequence label) {
6257 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6258 return label;
6259 } else {
6260 final int labelRes = getTypeLabelResource(type);
6261 return res.getText(labelRes);
6262 }
6263 }
Evan Millar088b2912009-05-28 15:24:37 -07006264 }
6265
Fred Quintana8851e162009-08-05 21:06:45 -07006266 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006267 * <p>
6268 * A data kind representing an IM address
6269 * </p>
6270 * <p>
6271 * You can use all columns defined for {@link ContactsContract.Data} as
6272 * well as the following aliases.
6273 * </p>
6274 * <h2>Column aliases</h2>
6275 * <table class="jd-sumtable">
6276 * <tr>
6277 * <th>Type</th>
6278 * <th>Alias</th><th colspan='2'>Data column</th>
6279 * </tr>
6280 * <tr>
6281 * <td>String</td>
6282 * <td>{@link #DATA}</td>
6283 * <td>{@link #DATA1}</td>
6284 * <td></td>
6285 * </tr>
6286 * <tr>
6287 * <td>int</td>
6288 * <td>{@link #TYPE}</td>
6289 * <td>{@link #DATA2}</td>
6290 * <td>Allowed values are:
6291 * <p>
6292 * <ul>
6293 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6294 * <li>{@link #TYPE_HOME}</li>
6295 * <li>{@link #TYPE_WORK}</li>
6296 * <li>{@link #TYPE_OTHER}</li>
6297 * </ul>
6298 * </p>
6299 * </td>
6300 * </tr>
6301 * <tr>
6302 * <td>String</td>
6303 * <td>{@link #LABEL}</td>
6304 * <td>{@link #DATA3}</td>
6305 * <td></td>
6306 * </tr>
6307 * <tr>
6308 * <td>String</td>
6309 * <td>{@link #PROTOCOL}</td>
6310 * <td>{@link #DATA5}</td>
6311 * <td>
6312 * <p>
6313 * Allowed values:
6314 * <ul>
6315 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
6316 * as {@link #CUSTOM_PROTOCOL}.</li>
6317 * <li>{@link #PROTOCOL_AIM}</li>
6318 * <li>{@link #PROTOCOL_MSN}</li>
6319 * <li>{@link #PROTOCOL_YAHOO}</li>
6320 * <li>{@link #PROTOCOL_SKYPE}</li>
6321 * <li>{@link #PROTOCOL_QQ}</li>
6322 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
6323 * <li>{@link #PROTOCOL_ICQ}</li>
6324 * <li>{@link #PROTOCOL_JABBER}</li>
6325 * <li>{@link #PROTOCOL_NETMEETING}</li>
6326 * </ul>
6327 * </p>
6328 * </td>
6329 * </tr>
6330 * <tr>
6331 * <td>String</td>
6332 * <td>{@link #CUSTOM_PROTOCOL}</td>
6333 * <td>{@link #DATA6}</td>
6334 * <td></td>
6335 * </tr>
6336 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006337 */
Yorke Lee94c87612014-07-18 18:57:17 -07006338 public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006339 /**
6340 * This utility class cannot be instantiated
6341 */
Evan Millar088b2912009-05-28 15:24:37 -07006342 private Im() {}
6343
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006344 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006345 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
6346
Evan Millar088b2912009-05-28 15:24:37 -07006347 public static final int TYPE_HOME = 1;
6348 public static final int TYPE_WORK = 2;
6349 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006350
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07006351 /**
6352 * This column should be populated with one of the defined
6353 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
6354 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
6355 * should contain the name of the custom protocol.
6356 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006357 public static final String PROTOCOL = DATA5;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006358
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006359 public static final String CUSTOM_PROTOCOL = DATA6;
Jeff Sharkey732da922009-07-30 09:59:31 -07006360
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07006361 /*
6362 * The predefined IM protocol types.
Evan Millar088b2912009-05-28 15:24:37 -07006363 */
Jeff Sharkey732da922009-07-30 09:59:31 -07006364 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07006365 public static final int PROTOCOL_AIM = 0;
6366 public static final int PROTOCOL_MSN = 1;
6367 public static final int PROTOCOL_YAHOO = 2;
6368 public static final int PROTOCOL_SKYPE = 3;
6369 public static final int PROTOCOL_QQ = 4;
6370 public static final int PROTOCOL_GOOGLE_TALK = 5;
6371 public static final int PROTOCOL_ICQ = 6;
6372 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07006373 public static final int PROTOCOL_NETMEETING = 8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006374
6375 /**
6376 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006377 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006378 */
6379 public static final int getTypeLabelResource(int type) {
6380 switch (type) {
6381 case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
6382 case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
6383 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
6384 default: return com.android.internal.R.string.imTypeCustom;
6385 }
6386 }
6387
6388 /**
6389 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006390 * possibly substituting the given {@link #LABEL} value
6391 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006392 */
6393 public static final CharSequence getTypeLabel(Resources res, int type,
6394 CharSequence label) {
6395 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6396 return label;
6397 } else {
6398 final int labelRes = getTypeLabelResource(type);
6399 return res.getText(labelRes);
6400 }
6401 }
6402
6403 /**
6404 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006405 * {@link #PROTOCOL}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006406 */
6407 public static final int getProtocolLabelResource(int type) {
6408 switch (type) {
6409 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
6410 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
6411 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
6412 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
6413 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
6414 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
6415 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
6416 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
6417 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
6418 default: return com.android.internal.R.string.imProtocolCustom;
6419 }
6420 }
6421
6422 /**
6423 * Return a {@link CharSequence} that best describes the given
6424 * protocol, possibly substituting the given
6425 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
6426 */
6427 public static final CharSequence getProtocolLabel(Resources res, int type,
6428 CharSequence label) {
6429 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
6430 return label;
6431 } else {
6432 final int labelRes = getProtocolLabelResource(type);
6433 return res.getText(labelRes);
6434 }
6435 }
Evan Millar088b2912009-05-28 15:24:37 -07006436 }
6437
6438 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006439 * <p>
6440 * A data kind representing an organization.
6441 * </p>
6442 * <p>
6443 * You can use all columns defined for {@link ContactsContract.Data} as
6444 * well as the following aliases.
6445 * </p>
6446 * <h2>Column aliases</h2>
6447 * <table class="jd-sumtable">
6448 * <tr>
6449 * <th>Type</th>
6450 * <th>Alias</th><th colspan='2'>Data column</th>
6451 * </tr>
6452 * <tr>
6453 * <td>String</td>
6454 * <td>{@link #COMPANY}</td>
6455 * <td>{@link #DATA1}</td>
6456 * <td></td>
6457 * </tr>
6458 * <tr>
6459 * <td>int</td>
6460 * <td>{@link #TYPE}</td>
6461 * <td>{@link #DATA2}</td>
6462 * <td>Allowed values are:
6463 * <p>
6464 * <ul>
6465 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6466 * <li>{@link #TYPE_WORK}</li>
6467 * <li>{@link #TYPE_OTHER}</li>
6468 * </ul>
6469 * </p>
6470 * </td>
6471 * </tr>
6472 * <tr>
6473 * <td>String</td>
6474 * <td>{@link #LABEL}</td>
6475 * <td>{@link #DATA3}</td>
6476 * <td></td>
6477 * </tr>
6478 * <tr>
6479 * <td>String</td>
6480 * <td>{@link #TITLE}</td>
6481 * <td>{@link #DATA4}</td>
6482 * <td></td>
6483 * </tr>
6484 * <tr>
6485 * <td>String</td>
6486 * <td>{@link #DEPARTMENT}</td>
6487 * <td>{@link #DATA5}</td>
6488 * <td></td>
6489 * </tr>
6490 * <tr>
6491 * <td>String</td>
6492 * <td>{@link #JOB_DESCRIPTION}</td>
6493 * <td>{@link #DATA6}</td>
6494 * <td></td>
6495 * </tr>
6496 * <tr>
6497 * <td>String</td>
6498 * <td>{@link #SYMBOL}</td>
6499 * <td>{@link #DATA7}</td>
6500 * <td></td>
6501 * </tr>
6502 * <tr>
6503 * <td>String</td>
6504 * <td>{@link #PHONETIC_NAME}</td>
6505 * <td>{@link #DATA8}</td>
6506 * <td></td>
6507 * </tr>
6508 * <tr>
6509 * <td>String</td>
6510 * <td>{@link #OFFICE_LOCATION}</td>
6511 * <td>{@link #DATA9}</td>
6512 * <td></td>
6513 * </tr>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006514 * <tr>
6515 * <td>String</td>
6516 * <td>PHONETIC_NAME_STYLE</td>
6517 * <td>{@link #DATA10}</td>
6518 * <td></td>
6519 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006520 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006521 */
Yorke Lee94c87612014-07-18 18:57:17 -07006522 public static final class Organization implements DataColumnsWithJoins, CommonColumns,
6523 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006524 /**
6525 * This utility class cannot be instantiated
6526 */
Evan Millar088b2912009-05-28 15:24:37 -07006527 private Organization() {}
6528
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006529 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006530 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
6531
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006532 public static final int TYPE_WORK = 1;
6533 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07006534
6535 /**
6536 * The company as the user entered it.
6537 * <P>Type: TEXT</P>
6538 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006539 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07006540
6541 /**
6542 * The position title at this company as the user entered it.
6543 * <P>Type: TEXT</P>
6544 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006545 public static final String TITLE = DATA4;
Fred Quintana8851e162009-08-05 21:06:45 -07006546
6547 /**
6548 * The department at this company as the user entered it.
6549 * <P>Type: TEXT</P>
6550 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006551 public static final String DEPARTMENT = DATA5;
Fred Quintana8851e162009-08-05 21:06:45 -07006552
6553 /**
6554 * The job description at this company as the user entered it.
6555 * <P>Type: TEXT</P>
6556 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006557 public static final String JOB_DESCRIPTION = DATA6;
Fred Quintana8851e162009-08-05 21:06:45 -07006558
6559 /**
6560 * The symbol of this company as the user entered it.
6561 * <P>Type: TEXT</P>
6562 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006563 public static final String SYMBOL = DATA7;
Fred Quintana8851e162009-08-05 21:06:45 -07006564
6565 /**
6566 * The phonetic name of this company as the user entered it.
6567 * <P>Type: TEXT</P>
6568 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006569 public static final String PHONETIC_NAME = DATA8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006570
6571 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07006572 * The office location of this organization.
6573 * <P>Type: TEXT</P>
6574 */
6575 public static final String OFFICE_LOCATION = DATA9;
6576
6577 /**
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006578 * The alphabet used for capturing the phonetic name.
6579 * See {@link ContactsContract.PhoneticNameStyle}.
6580 * @hide
6581 */
6582 public static final String PHONETIC_NAME_STYLE = DATA10;
6583
6584 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006585 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006586 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006587 */
6588 public static final int getTypeLabelResource(int type) {
6589 switch (type) {
6590 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
6591 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
6592 default: return com.android.internal.R.string.orgTypeCustom;
6593 }
6594 }
6595
6596 /**
6597 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006598 * possibly substituting the given {@link #LABEL} value
6599 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006600 */
6601 public static final CharSequence getTypeLabel(Resources res, int type,
6602 CharSequence label) {
6603 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6604 return label;
6605 } else {
6606 final int labelRes = getTypeLabelResource(type);
6607 return res.getText(labelRes);
6608 }
6609 }
Fred Quintana8851e162009-08-05 21:06:45 -07006610 }
6611
6612 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006613 * <p>
6614 * A data kind representing a relation.
6615 * </p>
6616 * <p>
6617 * You can use all columns defined for {@link ContactsContract.Data} as
6618 * well as the following aliases.
6619 * </p>
6620 * <h2>Column aliases</h2>
6621 * <table class="jd-sumtable">
6622 * <tr>
6623 * <th>Type</th>
6624 * <th>Alias</th><th colspan='2'>Data column</th>
6625 * </tr>
6626 * <tr>
6627 * <td>String</td>
6628 * <td>{@link #NAME}</td>
6629 * <td>{@link #DATA1}</td>
6630 * <td></td>
6631 * </tr>
6632 * <tr>
6633 * <td>int</td>
6634 * <td>{@link #TYPE}</td>
6635 * <td>{@link #DATA2}</td>
6636 * <td>Allowed values are:
6637 * <p>
6638 * <ul>
6639 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6640 * <li>{@link #TYPE_ASSISTANT}</li>
6641 * <li>{@link #TYPE_BROTHER}</li>
6642 * <li>{@link #TYPE_CHILD}</li>
6643 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
6644 * <li>{@link #TYPE_FATHER}</li>
6645 * <li>{@link #TYPE_FRIEND}</li>
6646 * <li>{@link #TYPE_MANAGER}</li>
6647 * <li>{@link #TYPE_MOTHER}</li>
6648 * <li>{@link #TYPE_PARENT}</li>
6649 * <li>{@link #TYPE_PARTNER}</li>
6650 * <li>{@link #TYPE_REFERRED_BY}</li>
6651 * <li>{@link #TYPE_RELATIVE}</li>
6652 * <li>{@link #TYPE_SISTER}</li>
6653 * <li>{@link #TYPE_SPOUSE}</li>
6654 * </ul>
6655 * </p>
6656 * </td>
6657 * </tr>
6658 * <tr>
6659 * <td>String</td>
6660 * <td>{@link #LABEL}</td>
6661 * <td>{@link #DATA3}</td>
6662 * <td></td>
6663 * </tr>
6664 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006665 */
Yorke Lee94c87612014-07-18 18:57:17 -07006666 public static final class Relation implements DataColumnsWithJoins, CommonColumns,
6667 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006668 /**
6669 * This utility class cannot be instantiated
6670 */
Fred Quintana8851e162009-08-05 21:06:45 -07006671 private Relation() {}
6672
6673 /** MIME type used when storing this in data table. */
6674 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
6675
6676 public static final int TYPE_ASSISTANT = 1;
6677 public static final int TYPE_BROTHER = 2;
6678 public static final int TYPE_CHILD = 3;
6679 public static final int TYPE_DOMESTIC_PARTNER = 4;
6680 public static final int TYPE_FATHER = 5;
6681 public static final int TYPE_FRIEND = 6;
6682 public static final int TYPE_MANAGER = 7;
6683 public static final int TYPE_MOTHER = 8;
6684 public static final int TYPE_PARENT = 9;
6685 public static final int TYPE_PARTNER = 10;
6686 public static final int TYPE_REFERRED_BY = 11;
6687 public static final int TYPE_RELATIVE = 12;
6688 public static final int TYPE_SISTER = 13;
6689 public static final int TYPE_SPOUSE = 14;
6690
6691 /**
6692 * The name of the relative as the user entered it.
6693 * <P>Type: TEXT</P>
6694 */
6695 public static final String NAME = DATA;
Daniel Lehmann1fb39f02010-10-28 13:40:38 -07006696
6697 /**
6698 * Return the string resource that best describes the given
6699 * {@link #TYPE}. Will always return a valid resource.
6700 */
6701 public static final int getTypeLabelResource(int type) {
6702 switch (type) {
6703 case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant;
6704 case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother;
6705 case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild;
6706 case TYPE_DOMESTIC_PARTNER:
6707 return com.android.internal.R.string.relationTypeDomesticPartner;
6708 case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather;
6709 case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend;
6710 case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager;
6711 case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother;
6712 case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent;
6713 case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner;
6714 case TYPE_REFERRED_BY:
6715 return com.android.internal.R.string.relationTypeReferredBy;
6716 case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative;
6717 case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister;
6718 case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse;
6719 default: return com.android.internal.R.string.orgTypeCustom;
6720 }
6721 }
6722
6723 /**
6724 * Return a {@link CharSequence} that best describes the given type,
6725 * possibly substituting the given {@link #LABEL} value
6726 * for {@link #TYPE_CUSTOM}.
6727 */
6728 public static final CharSequence getTypeLabel(Resources res, int type,
6729 CharSequence label) {
6730 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6731 return label;
6732 } else {
6733 final int labelRes = getTypeLabelResource(type);
6734 return res.getText(labelRes);
6735 }
6736 }
Fred Quintana8851e162009-08-05 21:06:45 -07006737 }
6738
6739 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006740 * <p>
6741 * A data kind representing an event.
6742 * </p>
6743 * <p>
6744 * You can use all columns defined for {@link ContactsContract.Data} as
6745 * well as the following aliases.
6746 * </p>
6747 * <h2>Column aliases</h2>
6748 * <table class="jd-sumtable">
6749 * <tr>
6750 * <th>Type</th>
6751 * <th>Alias</th><th colspan='2'>Data column</th>
6752 * </tr>
6753 * <tr>
6754 * <td>String</td>
6755 * <td>{@link #START_DATE}</td>
6756 * <td>{@link #DATA1}</td>
6757 * <td></td>
6758 * </tr>
6759 * <tr>
6760 * <td>int</td>
6761 * <td>{@link #TYPE}</td>
6762 * <td>{@link #DATA2}</td>
6763 * <td>Allowed values are:
6764 * <p>
6765 * <ul>
6766 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6767 * <li>{@link #TYPE_ANNIVERSARY}</li>
6768 * <li>{@link #TYPE_OTHER}</li>
6769 * <li>{@link #TYPE_BIRTHDAY}</li>
6770 * </ul>
6771 * </p>
6772 * </td>
6773 * </tr>
6774 * <tr>
6775 * <td>String</td>
6776 * <td>{@link #LABEL}</td>
6777 * <td>{@link #DATA3}</td>
6778 * <td></td>
6779 * </tr>
6780 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006781 */
Yorke Lee94c87612014-07-18 18:57:17 -07006782 public static final class Event implements DataColumnsWithJoins, CommonColumns,
6783 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006784 /**
6785 * This utility class cannot be instantiated
6786 */
Fred Quintana8851e162009-08-05 21:06:45 -07006787 private Event() {}
6788
6789 /** MIME type used when storing this in data table. */
Fred Quintanac868acf2009-09-30 18:17:47 -07006790 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
Fred Quintana8851e162009-08-05 21:06:45 -07006791
6792 public static final int TYPE_ANNIVERSARY = 1;
6793 public static final int TYPE_OTHER = 2;
Fred Quintanac868acf2009-09-30 18:17:47 -07006794 public static final int TYPE_BIRTHDAY = 3;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006795
Fred Quintana8851e162009-08-05 21:06:45 -07006796 /**
6797 * The event start date as the user entered it.
6798 * <P>Type: TEXT</P>
6799 */
6800 public static final String START_DATE = DATA;
Fred Quintanac868acf2009-09-30 18:17:47 -07006801
6802 /**
6803 * Return the string resource that best describes the given
6804 * {@link #TYPE}. Will always return a valid resource.
6805 */
6806 public static int getTypeResource(Integer type) {
6807 if (type == null) {
6808 return com.android.internal.R.string.eventTypeOther;
6809 }
6810 switch (type) {
6811 case TYPE_ANNIVERSARY:
6812 return com.android.internal.R.string.eventTypeAnniversary;
6813 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
6814 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
Daniel Lehmanndd384a72010-11-01 18:40:50 -07006815 default: return com.android.internal.R.string.eventTypeCustom;
Fred Quintanac868acf2009-09-30 18:17:47 -07006816 }
6817 }
Paul Soulos6b2dd632014-07-24 17:17:42 -07006818
6819 /**
6820 * Return a {@link CharSequence} that best describes the given type,
6821 * possibly substituting the given {@link #LABEL} value
6822 * for {@link #TYPE_CUSTOM}.
6823 */
6824 public static final CharSequence getTypeLabel(Resources res, int type,
6825 CharSequence label) {
6826 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6827 return label;
6828 } else {
6829 final int labelRes = getTypeResource(type);
6830 return res.getText(labelRes);
6831 }
6832 }
Evan Millar088b2912009-05-28 15:24:37 -07006833 }
6834
6835 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006836 * <p>
Dave Santoroa5282372011-06-29 00:25:16 -07006837 * A data kind representing a photo for the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006838 * </p>
6839 * <p>
6840 * Some sync adapters will choose to download photos in a separate
6841 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
6842 * through {@link ContactsContract.Data#SYNC4} to store temporary
6843 * data, e.g. the image URL or ID, state of download, server-side version
6844 * of the image. It is allowed for the {@link #PHOTO} to be null.
6845 * </p>
6846 * <p>
6847 * You can use all columns defined for {@link ContactsContract.Data} as
6848 * well as the following aliases.
6849 * </p>
6850 * <h2>Column aliases</h2>
6851 * <table class="jd-sumtable">
6852 * <tr>
6853 * <th>Type</th>
6854 * <th>Alias</th><th colspan='2'>Data column</th>
6855 * </tr>
6856 * <tr>
Dave Santoroa5282372011-06-29 00:25:16 -07006857 * <td>NUMBER</td>
6858 * <td>{@link #PHOTO_FILE_ID}</td>
6859 * <td>{@link #DATA14}</td>
6860 * <td>ID of the hi-res photo file.</td>
6861 * </tr>
6862 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006863 * <td>BLOB</td>
6864 * <td>{@link #PHOTO}</td>
6865 * <td>{@link #DATA15}</td>
Dave Santoroa5282372011-06-29 00:25:16 -07006866 * <td>By convention, binary data is stored in DATA15. The thumbnail of the
6867 * photo is stored in this column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006868 * </tr>
6869 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006870 */
Yorke Lee94c87612014-07-18 18:57:17 -07006871 public static final class Photo implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006872 /**
6873 * This utility class cannot be instantiated
6874 */
Evan Millar088b2912009-05-28 15:24:37 -07006875 private Photo() {}
6876
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006877 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006878 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
6879
6880 /**
Dave Santoroa5282372011-06-29 00:25:16 -07006881 * Photo file ID for the display photo of the raw contact.
6882 * See {@link ContactsContract.DisplayPhoto}.
6883 * <p>
6884 * Type: NUMBER
6885 */
6886 public static final String PHOTO_FILE_ID = DATA14;
6887
6888 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07006889 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07006890 * that could be inflated using {@link android.graphics.BitmapFactory}.
Evan Millar088b2912009-05-28 15:24:37 -07006891 * <p>
6892 * Type: BLOB
6893 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006894 public static final String PHOTO = DATA15;
Evan Millar088b2912009-05-28 15:24:37 -07006895 }
6896
6897 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006898 * <p>
Evan Millar088b2912009-05-28 15:24:37 -07006899 * Notes about the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006900 * </p>
6901 * <p>
6902 * You can use all columns defined for {@link ContactsContract.Data} as
6903 * well as the following aliases.
6904 * </p>
6905 * <h2>Column aliases</h2>
6906 * <table class="jd-sumtable">
6907 * <tr>
6908 * <th>Type</th>
6909 * <th>Alias</th><th colspan='2'>Data column</th>
6910 * </tr>
6911 * <tr>
6912 * <td>String</td>
6913 * <td>{@link #NOTE}</td>
6914 * <td>{@link #DATA1}</td>
6915 * <td></td>
6916 * </tr>
6917 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006918 */
Yorke Lee94c87612014-07-18 18:57:17 -07006919 public static final class Note implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006920 /**
6921 * This utility class cannot be instantiated
6922 */
Evan Millar088b2912009-05-28 15:24:37 -07006923 private Note() {}
6924
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006925 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006926 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
6927
6928 /**
6929 * The note text.
6930 * <P>Type: TEXT</P>
6931 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006932 public static final String NOTE = DATA1;
Evan Millar088b2912009-05-28 15:24:37 -07006933 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006934
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07006935 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006936 * <p>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006937 * Group Membership.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006938 * </p>
6939 * <p>
6940 * You can use all columns defined for {@link ContactsContract.Data} as
6941 * well as the following aliases.
6942 * </p>
6943 * <h2>Column aliases</h2>
6944 * <table class="jd-sumtable">
6945 * <tr>
6946 * <th>Type</th>
6947 * <th>Alias</th><th colspan='2'>Data column</th>
6948 * </tr>
6949 * <tr>
6950 * <td>long</td>
6951 * <td>{@link #GROUP_ROW_ID}</td>
6952 * <td>{@link #DATA1}</td>
6953 * <td></td>
6954 * </tr>
6955 * <tr>
6956 * <td>String</td>
6957 * <td>{@link #GROUP_SOURCE_ID}</td>
6958 * <td>none</td>
6959 * <td>
6960 * <p>
6961 * The sourceid of the group that this group membership refers to.
6962 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
6963 * inserting a row.
6964 * </p>
6965 * <p>
6966 * If this field is specified, the provider will first try to
6967 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group
6968 * is found, it will use the corresponding row id. If the group is not
6969 * found, it will create one.
6970 * </td>
6971 * </tr>
6972 * </table>
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006973 */
Yorke Lee94c87612014-07-18 18:57:17 -07006974 public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006975 /**
6976 * This utility class cannot be instantiated
6977 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006978 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006979
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006980 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006981 public static final String CONTENT_ITEM_TYPE =
6982 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006983
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006984 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07006985 * The row id of the group that this group membership refers to. Exactly one of
6986 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006987 * <P>Type: INTEGER</P>
6988 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006989 public static final String GROUP_ROW_ID = DATA1;
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006990
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006991 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07006992 * The sourceid of the group that this group membership refers to. Exactly one of
6993 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006994 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006995 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07006996 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006997 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006998
6999 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007000 * <p>
7001 * A data kind representing a website related to the contact.
7002 * </p>
7003 * <p>
7004 * You can use all columns defined for {@link ContactsContract.Data} as
7005 * well as the following aliases.
7006 * </p>
7007 * <h2>Column aliases</h2>
7008 * <table class="jd-sumtable">
7009 * <tr>
7010 * <th>Type</th>
7011 * <th>Alias</th><th colspan='2'>Data column</th>
7012 * </tr>
7013 * <tr>
7014 * <td>String</td>
7015 * <td>{@link #URL}</td>
7016 * <td>{@link #DATA1}</td>
7017 * <td></td>
7018 * </tr>
7019 * <tr>
7020 * <td>int</td>
7021 * <td>{@link #TYPE}</td>
7022 * <td>{@link #DATA2}</td>
7023 * <td>Allowed values are:
7024 * <p>
7025 * <ul>
7026 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7027 * <li>{@link #TYPE_HOMEPAGE}</li>
7028 * <li>{@link #TYPE_BLOG}</li>
7029 * <li>{@link #TYPE_PROFILE}</li>
7030 * <li>{@link #TYPE_HOME}</li>
7031 * <li>{@link #TYPE_WORK}</li>
7032 * <li>{@link #TYPE_FTP}</li>
7033 * <li>{@link #TYPE_OTHER}</li>
7034 * </ul>
7035 * </p>
7036 * </td>
7037 * </tr>
7038 * <tr>
7039 * <td>String</td>
7040 * <td>{@link #LABEL}</td>
7041 * <td>{@link #DATA3}</td>
7042 * <td></td>
7043 * </tr>
7044 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007045 */
Yorke Lee94c87612014-07-18 18:57:17 -07007046 public static final class Website implements DataColumnsWithJoins, CommonColumns,
7047 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007048 /**
7049 * This utility class cannot be instantiated
7050 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007051 private Website() {}
7052
7053 /** MIME type used when storing this in data table. */
7054 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
7055
Fred Quintana8851e162009-08-05 21:06:45 -07007056 public static final int TYPE_HOMEPAGE = 1;
7057 public static final int TYPE_BLOG = 2;
7058 public static final int TYPE_PROFILE = 3;
7059 public static final int TYPE_HOME = 4;
7060 public static final int TYPE_WORK = 5;
7061 public static final int TYPE_FTP = 6;
7062 public static final int TYPE_OTHER = 7;
7063
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007064 /**
7065 * The website URL string.
7066 * <P>Type: TEXT</P>
7067 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07007068 public static final String URL = DATA;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007069 }
David Brown846eb302010-08-23 17:40:51 -07007070
7071 /**
7072 * <p>
7073 * A data kind representing a SIP address for the contact.
7074 * </p>
7075 * <p>
7076 * You can use all columns defined for {@link ContactsContract.Data} as
7077 * well as the following aliases.
7078 * </p>
7079 * <h2>Column aliases</h2>
7080 * <table class="jd-sumtable">
7081 * <tr>
7082 * <th>Type</th>
7083 * <th>Alias</th><th colspan='2'>Data column</th>
7084 * </tr>
7085 * <tr>
7086 * <td>String</td>
7087 * <td>{@link #SIP_ADDRESS}</td>
7088 * <td>{@link #DATA1}</td>
7089 * <td></td>
7090 * </tr>
David Brown747c6152010-09-15 13:34:13 -07007091 * <tr>
7092 * <td>int</td>
7093 * <td>{@link #TYPE}</td>
7094 * <td>{@link #DATA2}</td>
7095 * <td>Allowed values are:
7096 * <p>
7097 * <ul>
7098 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7099 * <li>{@link #TYPE_HOME}</li>
7100 * <li>{@link #TYPE_WORK}</li>
7101 * <li>{@link #TYPE_OTHER}</li>
7102 * </ul>
7103 * </p>
7104 * </td>
7105 * </tr>
7106 * <tr>
7107 * <td>String</td>
7108 * <td>{@link #LABEL}</td>
7109 * <td>{@link #DATA3}</td>
7110 * <td></td>
7111 * </tr>
David Brown846eb302010-08-23 17:40:51 -07007112 * </table>
7113 */
Yorke Lee94c87612014-07-18 18:57:17 -07007114 public static final class SipAddress implements DataColumnsWithJoins, CommonColumns,
7115 ContactCounts {
David Brown846eb302010-08-23 17:40:51 -07007116 /**
7117 * This utility class cannot be instantiated
7118 */
7119 private SipAddress() {}
7120
7121 /** MIME type used when storing this in data table. */
7122 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address";
7123
David Brown747c6152010-09-15 13:34:13 -07007124 public static final int TYPE_HOME = 1;
7125 public static final int TYPE_WORK = 2;
7126 public static final int TYPE_OTHER = 3;
7127
David Brown846eb302010-08-23 17:40:51 -07007128 /**
7129 * The SIP address.
7130 * <P>Type: TEXT</P>
7131 */
7132 public static final String SIP_ADDRESS = DATA1;
David Brown747c6152010-09-15 13:34:13 -07007133 // ...and TYPE and LABEL come from the CommonColumns interface.
7134
7135 /**
7136 * Return the string resource that best describes the given
7137 * {@link #TYPE}. Will always return a valid resource.
7138 */
7139 public static final int getTypeLabelResource(int type) {
7140 switch (type) {
7141 case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome;
7142 case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork;
7143 case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther;
7144 default: return com.android.internal.R.string.sipAddressTypeCustom;
7145 }
7146 }
7147
7148 /**
7149 * Return a {@link CharSequence} that best describes the given type,
7150 * possibly substituting the given {@link #LABEL} value
7151 * for {@link #TYPE_CUSTOM}.
7152 */
7153 public static final CharSequence getTypeLabel(Resources res, int type,
7154 CharSequence label) {
7155 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7156 return label;
7157 } else {
7158 final int labelRes = getTypeLabelResource(type);
7159 return res.getText(labelRes);
7160 }
7161 }
David Brown846eb302010-08-23 17:40:51 -07007162 }
Fred Quintana4923f1d2011-08-05 15:58:17 -07007163
7164 /**
7165 * A data kind representing an Identity related to the contact.
7166 * <p>
7167 * This can be used as a signal by the aggregator to combine raw contacts into
7168 * contacts, e.g. if two contacts have Identity rows with
7169 * the same NAMESPACE and IDENTITY values the aggregator can know that they refer
7170 * to the same person.
7171 * </p>
7172 */
Yorke Lee94c87612014-07-18 18:57:17 -07007173 public static final class Identity implements DataColumnsWithJoins, ContactCounts {
Fred Quintana4923f1d2011-08-05 15:58:17 -07007174 /**
7175 * This utility class cannot be instantiated
7176 */
7177 private Identity() {}
7178
7179 /** MIME type used when storing this in data table. */
7180 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity";
7181
7182 /**
7183 * The identity string.
7184 * <P>Type: TEXT</P>
7185 */
7186 public static final String IDENTITY = DataColumns.DATA1;
7187
7188 /**
7189 * The namespace of the identity string, e.g. "com.google"
7190 * <P>Type: TEXT</P>
7191 */
7192 public static final String NAMESPACE = DataColumns.DATA2;
7193 }
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007194
7195 /**
7196 * <p>
7197 * Convenient functionalities for "callable" data. Note that, this is NOT a separate data
7198 * kind.
7199 * </p>
7200 * <p>
7201 * This URI allows the ContactsProvider to return a unified result for "callable" data
7202 * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the
7203 * current examples for "callable", but may be expanded to the other types.
7204 * </p>
7205 * <p>
7206 * Each returned row may have a different MIMETYPE and thus different interpretation for
7207 * each column. For example the meaning for {@link Phone}'s type is different than
7208 * {@link SipAddress}'s.
7209 * </p>
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007210 */
Yorke Lee94c87612014-07-18 18:57:17 -07007211 public static final class Callable implements DataColumnsWithJoins, CommonColumns,
7212 ContactCounts {
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007213 /**
7214 * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only
7215 * phone numbers.
7216 */
7217 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7218 "callables");
7219 /**
7220 * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable
7221 * data.
7222 */
7223 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
7224 "filter");
7225 }
Yorke Lee4f401eb2013-03-06 17:17:17 -08007226
7227 /**
7228 * A special class of data items, used to refer to types of data that can be used to attempt
7229 * to start communicating with a person ({@link Phone} and {@link Email}). Note that this
7230 * is NOT a separate data kind.
7231 *
7232 * This URI allows the ContactsProvider to return a unified result for data items that users
7233 * can use to initiate communications with another contact. {@link Phone} and {@link Email}
7234 * are the current data types in this category.
7235 */
Yorke Lee94c87612014-07-18 18:57:17 -07007236 public static final class Contactables implements DataColumnsWithJoins, CommonColumns,
7237 ContactCounts {
Yorke Lee4f401eb2013-03-06 17:17:17 -08007238 /**
7239 * The content:// style URI for these data items, which requests a directory of data
7240 * rows matching the selection criteria.
7241 */
7242 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7243 "contactables");
7244
7245 /**
7246 * The content:// style URI for these data items, which allows for a query parameter to
7247 * be appended onto the end to filter for data items matching the query.
7248 */
7249 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
7250 Contactables.CONTENT_URI, "filter");
7251
7252 /**
7253 * A boolean parameter for {@link Data#CONTENT_URI}.
7254 * This specifies whether or not the returned data items should be filtered to show
7255 * data items belonging to visible contacts only.
7256 */
7257 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
7258 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07007259 }
Fred Quintana435e4272009-06-04 17:30:28 -07007260
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007261 /**
7262 * @see Groups
7263 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07007264 protected interface GroupsColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007265 /**
Dave Santorod7bdc182011-06-24 15:39:39 -07007266 * The data set within the account that this group belongs to. This allows
7267 * multiple sync adapters for the same account type to distinguish between
7268 * each others' group data.
7269 *
7270 * This is empty by default, and is completely optional. It only needs to
7271 * be populated if multiple sync adapters are entering distinct group data
7272 * for the same account type and account name.
7273 * <P>Type: TEXT</P>
7274 */
7275 public static final String DATA_SET = "data_set";
7276
7277 /**
Dave Santoro1d55c332011-07-25 16:44:45 -07007278 * A concatenation of the account type and data set (delimited by a forward
7279 * slash) - if the data set is empty, this will be the same as the account
7280 * type. For applications that need to be aware of the data set, this can
7281 * be used instead of account type to distinguish sets of data. This is
7282 * never intended to be used for specifying accounts.
7283 * @hide
7284 */
7285 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
7286
7287 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007288 * The display title of this group.
7289 * <p>
7290 * Type: TEXT
7291 */
7292 public static final String TITLE = "title";
7293
7294 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007295 * The package name to use when creating {@link Resources} objects for
7296 * this group. This value is only designed for use when building user
7297 * interfaces, and should not be used to infer the owner.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007298 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007299 public static final String RES_PACKAGE = "res_package";
7300
7301 /**
7302 * The display title of this group to load as a resource from
7303 * {@link #RES_PACKAGE}, which may be localized.
7304 * <P>Type: TEXT</P>
7305 */
7306 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007307
7308 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07007309 * Notes about the group.
7310 * <p>
7311 * Type: TEXT
7312 */
7313 public static final String NOTES = "notes";
7314
7315 /**
7316 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
7317 * to the sync adapter, null otherwise.
7318 * <P>Type: TEXT</P>
7319 */
7320 public static final String SYSTEM_ID = "system_id";
7321
7322 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007323 * The total number of {@link Contacts} that have
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007324 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007325 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
7326 * <p>
7327 * Type: INTEGER
7328 */
7329 public static final String SUMMARY_COUNT = "summ_count";
7330
7331 /**
Daisuke Miyakawa15dec392011-07-23 11:39:23 -07007332 * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}.
7333 * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}.
7334 *
7335 * @hide
7336 */
7337 public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT =
7338 "return_group_count_per_account";
7339
7340 /**
7341 * The total number of groups of the account that a group belongs to.
7342 * This column is available only when the parameter
7343 * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in
7344 * {@link Groups#CONTENT_SUMMARY_URI}.
7345 *
7346 * For example, when the account "A" has two groups "group1" and "group2", and the account
7347 * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for
7348 * "group3" returns "1" for this column.
7349 *
7350 * Note: This counts only non-favorites, non-auto-add, and not deleted groups.
7351 *
7352 * Type: INTEGER
7353 * @hide
7354 */
7355 public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account";
7356
7357 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007358 * The total number of {@link Contacts} that have both
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007359 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007360 * Read-only value that is only present when querying
7361 * {@link Groups#CONTENT_SUMMARY_URI}.
7362 * <p>
7363 * Type: INTEGER
7364 */
7365 public static final String SUMMARY_WITH_PHONES = "summ_phones";
7366
7367 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007368 * Flag indicating if the contacts belonging to this group should be
7369 * visible in any user interface.
7370 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007371 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007372 */
7373 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07007374
7375 /**
7376 * The "deleted" flag: "0" by default, "1" if the row has been marked
7377 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007378 * called on a group, it is marked for deletion. The sync adaptor
7379 * deletes the group on the server and then calls ContactResolver.delete
7380 * once more, this time setting the the
7381 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
7382 * finalize the data removal.
Fred Quintana00c89f62009-08-10 14:43:24 -07007383 * <P>Type: INTEGER</P>
7384 */
7385 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07007386
7387 /**
7388 * Whether this group should be synced if the SYNC_EVERYTHING settings
7389 * is false for this group's account.
7390 * <p>
7391 * Type: INTEGER (boolean)
7392 */
7393 public static final String SHOULD_SYNC = "should_sync";
Fred Quintanaa31a9452010-04-13 14:52:20 -07007394
7395 /**
7396 * Any newly created contacts will automatically be added to groups that have this
7397 * flag set to true.
7398 * <p>
7399 * Type: INTEGER (boolean)
7400 */
7401 public static final String AUTO_ADD = "auto_add";
7402
7403 /**
7404 * When a contacts is marked as a favorites it will be automatically added
7405 * to the groups that have this flag set, and when it is removed from favorites
7406 * it will be removed from these groups.
7407 * <p>
7408 * Type: INTEGER (boolean)
7409 */
7410 public static final String FAVORITES = "favorites";
Dmitri Plotnikov4ccf33a2010-11-19 11:10:43 -08007411
7412 /**
7413 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
7414 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
7415 * <P>Type: INTEGER</P>
7416 */
7417 public static final String GROUP_IS_READ_ONLY = "group_is_read_only";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007418 }
7419
7420 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007421 * Constants for the groups table. Only per-account groups are supported.
7422 * <h2>Columns</h2>
7423 * <table class="jd-sumtable">
7424 * <tr>
7425 * <th colspan='4'>Groups</th>
7426 * </tr>
7427 * <tr>
7428 * <td>long</td>
7429 * <td>{@link #_ID}</td>
7430 * <td>read-only</td>
7431 * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
7432 * In other words, it would be a really bad idea to delete and reinsert a
7433 * group. A sync adapter should always do an update instead.</td>
7434 * </tr>
Dave Santorod7bdc182011-06-24 15:39:39 -07007435 # <tr>
7436 * <td>String</td>
7437 * <td>{@link #DATA_SET}</td>
7438 * <td>read/write-once</td>
7439 * <td>
7440 * <p>
7441 * The data set within the account that this group belongs to. This allows
7442 * multiple sync adapters for the same account type to distinguish between
7443 * each others' group data. The combination of {@link #ACCOUNT_TYPE},
7444 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
7445 * that is associated with a single sync adapter.
7446 * </p>
7447 * <p>
7448 * This is empty by default, and is completely optional. It only needs to
7449 * be populated if multiple sync adapters are entering distinct data for
7450 * the same account type and account name.
7451 * </p>
7452 * <p>
7453 * It should be set at the time the group is inserted and never changed
7454 * afterwards.
7455 * </p>
7456 * </td>
7457 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007458 * <tr>
7459 * <td>String</td>
7460 * <td>{@link #TITLE}</td>
7461 * <td>read/write</td>
7462 * <td>The display title of this group.</td>
7463 * </tr>
7464 * <tr>
7465 * <td>String</td>
7466 * <td>{@link #NOTES}</td>
7467 * <td>read/write</td>
7468 * <td>Notes about the group.</td>
7469 * </tr>
7470 * <tr>
7471 * <td>String</td>
7472 * <td>{@link #SYSTEM_ID}</td>
7473 * <td>read/write</td>
7474 * <td>The ID of this group if it is a System Group, i.e. a group that has a
7475 * special meaning to the sync adapter, null otherwise.</td>
7476 * </tr>
7477 * <tr>
7478 * <td>int</td>
7479 * <td>{@link #SUMMARY_COUNT}</td>
7480 * <td>read-only</td>
7481 * <td>The total number of {@link Contacts} that have
7482 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
7483 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
7484 * </tr>
7485 * <tr>
7486 * <td>int</td>
7487 * <td>{@link #SUMMARY_WITH_PHONES}</td>
7488 * <td>read-only</td>
7489 * <td>The total number of {@link Contacts} that have both
7490 * {@link CommonDataKinds.GroupMembership} in this group, and also have
7491 * phone numbers. Read-only value that is only present when querying
7492 * {@link Groups#CONTENT_SUMMARY_URI}.</td>
7493 * </tr>
7494 * <tr>
7495 * <td>int</td>
7496 * <td>{@link #GROUP_VISIBLE}</td>
7497 * <td>read-only</td>
7498 * <td>Flag indicating if the contacts belonging to this group should be
7499 * visible in any user interface. Allowed values: 0 and 1.</td>
7500 * </tr>
7501 * <tr>
7502 * <td>int</td>
7503 * <td>{@link #DELETED}</td>
7504 * <td>read/write</td>
7505 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
7506 * for deletion. When {@link android.content.ContentResolver#delete} is
7507 * called on a group, it is marked for deletion. The sync adaptor deletes
7508 * the group on the server and then calls ContactResolver.delete once more,
7509 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
7510 * query parameter to finalize the data removal.</td>
7511 * </tr>
7512 * <tr>
7513 * <td>int</td>
7514 * <td>{@link #SHOULD_SYNC}</td>
7515 * <td>read/write</td>
7516 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
7517 * is false for this group's account.</td>
7518 * </tr>
7519 * </table>
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007520 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007521 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007522 /**
7523 * This utility class cannot be instantiated
7524 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007525 private Groups() {
7526 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007527
7528 /**
7529 * The content:// style URI for this table
7530 */
7531 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
7532
7533 /**
7534 * The content:// style URI for this table joined with details data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007535 * {@link ContactsContract.Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007536 */
7537 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
7538 "groups_summary");
7539
7540 /**
7541 * The MIME type of a directory of groups.
7542 */
7543 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
7544
7545 /**
7546 * The MIME type of a single group.
7547 */
7548 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
Fred Quintana328c0e72009-12-07 14:52:28 -08007549
7550 public static EntityIterator newEntityIterator(Cursor cursor) {
7551 return new EntityIteratorImpl(cursor);
7552 }
7553
7554 private static class EntityIteratorImpl extends CursorEntityIterator {
7555 public EntityIteratorImpl(Cursor cursor) {
7556 super(cursor);
7557 }
7558
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08007559 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08007560 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
7561 // we expect the cursor is already at the row we need to read from
7562 final ContentValues values = new ContentValues();
7563 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
7564 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
7565 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
7566 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
7567 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
7568 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
7569 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
7570 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
7571 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
7572 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
7573 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
7574 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
7575 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
7576 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
7577 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
7578 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
7579 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
7580 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
Fred Quintanaa31a9452010-04-13 14:52:20 -07007581 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES);
7582 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD);
Fred Quintana328c0e72009-12-07 14:52:28 -08007583 cursor.moveToNext();
7584 return new Entity(values);
7585 }
7586 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007587 }
7588
Fred Quintana435e4272009-06-04 17:30:28 -07007589 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007590 * <p>
Fred Quintana435e4272009-06-04 17:30:28 -07007591 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007592 * aggregation rules overriding those used by automatic aggregation. This
7593 * type only supports query and update. Neither insert nor delete are
7594 * supported.
7595 * </p>
7596 * <h2>Columns</h2>
7597 * <table class="jd-sumtable">
7598 * <tr>
7599 * <th colspan='4'>AggregationExceptions</th>
7600 * </tr>
7601 * <tr>
7602 * <td>int</td>
7603 * <td>{@link #TYPE}</td>
7604 * <td>read/write</td>
7605 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
7606 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
7607 * </tr>
7608 * <tr>
7609 * <td>long</td>
7610 * <td>{@link #RAW_CONTACT_ID1}</td>
7611 * <td>read/write</td>
7612 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
7613 * the rule applies to.</td>
7614 * </tr>
7615 * <tr>
7616 * <td>long</td>
7617 * <td>{@link #RAW_CONTACT_ID2}</td>
7618 * <td>read/write</td>
7619 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
7620 * that the rule applies to.</td>
7621 * </tr>
7622 * </table>
Fred Quintana435e4272009-06-04 17:30:28 -07007623 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07007624 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07007625 /**
7626 * This utility class cannot be instantiated
7627 */
7628 private AggregationExceptions() {}
7629
7630 /**
7631 * The content:// style URI for this table
7632 */
7633 public static final Uri CONTENT_URI =
7634 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
7635
7636 /**
7637 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
7638 */
7639 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
7640
7641 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07007642 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
7643 */
7644 public static final String CONTENT_ITEM_TYPE =
7645 "vnd.android.cursor.item/aggregation_exception";
7646
7647 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007648 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007649 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07007650 *
7651 * <P>Type: INTEGER</P>
7652 */
7653 public static final String TYPE = "type";
7654
Fred Quintana435e4272009-06-04 17:30:28 -07007655 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007656 * Allows the provider to automatically decide whether the specified raw contacts should
7657 * be included in the same aggregate contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07007658 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007659 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07007660
7661 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007662 * Makes sure that the specified raw contacts are included in the same
7663 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007664 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007665 public static final int TYPE_KEEP_TOGETHER = 1;
7666
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007667 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007668 * Makes sure that the specified raw contacts are NOT included in the same
7669 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007670 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007671 public static final int TYPE_KEEP_SEPARATE = 2;
7672
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007673 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007674 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07007675 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007676 public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
7677
7678 /**
7679 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
7680 * applies to.
7681 */
7682 public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
Fred Quintana435e4272009-06-04 17:30:28 -07007683 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07007684
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007685 /**
7686 * @see Settings
7687 */
Dmitri Plotnikovfe4c8712009-10-14 00:28:48 -07007688 protected interface SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007689 /**
7690 * The name of the account instance to which this row belongs.
7691 * <P>Type: TEXT</P>
7692 */
7693 public static final String ACCOUNT_NAME = "account_name";
7694
7695 /**
7696 * The type of account to which this row belongs, which when paired with
7697 * {@link #ACCOUNT_NAME} identifies a specific account.
7698 * <P>Type: TEXT</P>
7699 */
7700 public static final String ACCOUNT_TYPE = "account_type";
7701
7702 /**
Dave Santoro7c4479f2011-09-07 16:52:27 -07007703 * The data set within the account that this row belongs to. This allows
7704 * multiple sync adapters for the same account type to distinguish between
7705 * each others' data.
7706 *
7707 * This is empty by default, and is completely optional. It only needs to
7708 * be populated if multiple sync adapters are entering distinct data for
7709 * the same account type and account name.
7710 * <P>Type: TEXT</P>
7711 */
7712 public static final String DATA_SET = "data_set";
7713
7714 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07007715 * Depending on the mode defined by the sync-adapter, this flag controls
7716 * the top-level sync behavior for this data source.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007717 * <p>
7718 * Type: INTEGER (boolean)
7719 */
7720 public static final String SHOULD_SYNC = "should_sync";
7721
7722 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007723 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
Jeff Sharkeya6597442009-08-19 09:23:33 -07007724 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007725 * <p>
7726 * Type: INTEGER (boolean)
7727 */
7728 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
Jeff Sharkey06a03232009-08-21 17:37:56 -07007729
7730 /**
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07007731 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
7732 * {@link Groups#SHOULD_SYNC} under this account have been marked as
7733 * unsynced.
7734 */
7735 public static final String ANY_UNSYNCED = "any_unsynced";
7736
7737 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07007738 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07007739 * no {@link CommonDataKinds.GroupMembership} entries.
Jeff Sharkey06a03232009-08-21 17:37:56 -07007740 * <p>
7741 * Type: INTEGER
7742 */
7743 public static final String UNGROUPED_COUNT = "summ_count";
7744
7745 /**
7746 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07007747 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
Jeff Sharkey06a03232009-08-21 17:37:56 -07007748 * <p>
7749 * Type: INTEGER
7750 */
7751 public static final String UNGROUPED_WITH_PHONES = "summ_phones";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007752 }
7753
7754 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007755 * <p>
7756 * Contacts-specific settings for various {@link Account}'s.
7757 * </p>
7758 * <h2>Columns</h2>
7759 * <table class="jd-sumtable">
7760 * <tr>
7761 * <th colspan='4'>Settings</th>
7762 * </tr>
7763 * <tr>
7764 * <td>String</td>
7765 * <td>{@link #ACCOUNT_NAME}</td>
7766 * <td>read/write-once</td>
7767 * <td>The name of the account instance to which this row belongs.</td>
7768 * </tr>
7769 * <tr>
7770 * <td>String</td>
7771 * <td>{@link #ACCOUNT_TYPE}</td>
7772 * <td>read/write-once</td>
7773 * <td>The type of account to which this row belongs, which when paired with
7774 * {@link #ACCOUNT_NAME} identifies a specific account.</td>
7775 * </tr>
7776 * <tr>
7777 * <td>int</td>
7778 * <td>{@link #SHOULD_SYNC}</td>
7779 * <td>read/write</td>
7780 * <td>Depending on the mode defined by the sync-adapter, this flag controls
7781 * the top-level sync behavior for this data source.</td>
7782 * </tr>
7783 * <tr>
7784 * <td>int</td>
7785 * <td>{@link #UNGROUPED_VISIBLE}</td>
7786 * <td>read/write</td>
7787 * <td>Flag indicating if contacts without any
7788 * {@link CommonDataKinds.GroupMembership} entries should be visible in any
7789 * user interface.</td>
7790 * </tr>
7791 * <tr>
7792 * <td>int</td>
7793 * <td>{@link #ANY_UNSYNCED}</td>
7794 * <td>read-only</td>
7795 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
7796 * {@link Groups#SHOULD_SYNC} under this account have been marked as
7797 * unsynced.</td>
7798 * </tr>
7799 * <tr>
7800 * <td>int</td>
7801 * <td>{@link #UNGROUPED_COUNT}</td>
7802 * <td>read-only</td>
7803 * <td>Read-only count of {@link Contacts} from a specific source that have
7804 * no {@link CommonDataKinds.GroupMembership} entries.</td>
7805 * </tr>
7806 * <tr>
7807 * <td>int</td>
7808 * <td>{@link #UNGROUPED_WITH_PHONES}</td>
7809 * <td>read-only</td>
7810 * <td>Read-only count of {@link Contacts} from a specific source that have
7811 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
7812 * numbers.</td>
7813 * </tr>
7814 * </table>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007815 */
Jeff Sharkey06a03232009-08-21 17:37:56 -07007816 public static final class Settings implements SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007817 /**
7818 * This utility class cannot be instantiated
7819 */
7820 private Settings() {
7821 }
7822
7823 /**
7824 * The content:// style URI for this table
7825 */
7826 public static final Uri CONTENT_URI =
7827 Uri.withAppendedPath(AUTHORITY_URI, "settings");
7828
7829 /**
7830 * The MIME-type of {@link #CONTENT_URI} providing a directory of
7831 * settings.
7832 */
7833 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
7834
7835 /**
7836 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
7837 */
7838 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007839 }
7840
Evan Millardc2da5f2009-06-18 16:07:13 -07007841 /**
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08007842 * Private API for inquiring about the general status of the provider.
7843 *
7844 * @hide
7845 */
7846 public static final class ProviderStatus {
7847
7848 /**
7849 * Not instantiable.
7850 */
7851 private ProviderStatus() {
7852 }
7853
7854 /**
7855 * The content:// style URI for this table. Requests to this URI can be
7856 * performed on the UI thread because they are always unblocking.
7857 *
7858 * @hide
7859 */
7860 public static final Uri CONTENT_URI =
7861 Uri.withAppendedPath(AUTHORITY_URI, "provider_status");
7862
7863 /**
7864 * The MIME-type of {@link #CONTENT_URI} providing a directory of
7865 * settings.
7866 *
7867 * @hide
7868 */
7869 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status";
7870
7871 /**
7872 * An integer representing the current status of the provider.
7873 *
7874 * @hide
7875 */
7876 public static final String STATUS = "status";
7877
7878 /**
7879 * Default status of the provider.
7880 *
7881 * @hide
7882 */
7883 public static final int STATUS_NORMAL = 0;
7884
7885 /**
7886 * The status used when the provider is in the process of upgrading. Contacts
7887 * are temporarily unaccessible.
7888 *
7889 * @hide
7890 */
7891 public static final int STATUS_UPGRADING = 1;
7892
7893 /**
7894 * The status used if the provider was in the process of upgrading but ran
7895 * out of storage. The DATA1 column will contain the estimated amount of
7896 * storage required (in bytes). Update status to STATUS_NORMAL to force
7897 * the provider to retry the upgrade.
7898 *
7899 * @hide
7900 */
7901 public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2;
7902
7903 /**
7904 * The status used during a locale change.
7905 *
7906 * @hide
7907 */
7908 public static final int STATUS_CHANGING_LOCALE = 3;
7909
7910 /**
Dmitri Plotnikov37c34862010-11-12 16:12:53 -08007911 * The status that indicates that there are no accounts and no contacts
7912 * on the device.
7913 *
7914 * @hide
7915 */
7916 public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4;
7917
7918 /**
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08007919 * Additional data associated with the status.
7920 *
7921 * @hide
7922 */
7923 public static final String DATA1 = "data1";
7924 }
7925
7926 /**
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007927 * <p>
7928 * API allowing applications to send usage information for each {@link Data} row to the
Makoto Onukib0d22992012-04-12 17:09:58 -07007929 * Contacts Provider. Applications can also clear all usage information.
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007930 * </p>
7931 * <p>
7932 * With the feedback, Contacts Provider may return more contextually appropriate results for
7933 * Data listing, typically supplied with
7934 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI},
7935 * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI},
7936 * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit
7937 * from better ranked (sorted) lists in applications that show auto-complete list.
7938 * </p>
7939 * <p>
7940 * There is no guarantee for how this feedback is used, or even whether it is used at all.
7941 * The ranking algorithm will make best efforts to use the feedback data, but the exact
7942 * implementation, the storage data structures as well as the resulting sort order is device
7943 * and version specific and can change over time.
7944 * </p>
7945 * <p>
7946 * When updating usage information, users of this API need to use
7947 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed
7948 * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as
7949 * its last path. They also need to append a query parameter to the Uri, to specify the type of
7950 * the communication, which enables the Contacts Provider to differentiate between kinds of
7951 * interactions using the same contact data field (for example a phone number can be used to
7952 * make phone calls or send SMS).
7953 * </p>
7954 * <p>
7955 * Selection and selectionArgs are ignored and must be set to null. To get data ids,
7956 * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)}
7957 * toward {@link Data#CONTENT_URI}.
7958 * </p>
7959 * <p>
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07007960 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive
7961 * integer when successful, and returns 0 if no contact with that id was found.
7962 * </p>
7963 * <p>
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007964 * Example:
7965 * <pre>
Daisuke Miyakawa52e38232011-06-14 10:56:46 -07007966 * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007967 * .appendPath(TextUtils.join(",", dataIds))
Daisuke Miyakawa52e38232011-06-14 10:56:46 -07007968 * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
7969 * DataUsageFeedback.USAGE_TYPE_CALL)
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007970 * .build();
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07007971 * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0;
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007972 * </pre>
7973 * </p>
Makoto Onukib0d22992012-04-12 17:09:58 -07007974 * <p>
7975 * Applications can also clear all usage information with:
7976 * <pre>
Makoto Onuki7ebbfd02012-04-13 12:56:42 -07007977 * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0;
Makoto Onukib0d22992012-04-12 17:09:58 -07007978 * </pre>
7979 * </p>
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007980 */
7981 public static final class DataUsageFeedback {
7982
7983 /**
7984 * The content:// style URI for sending usage feedback.
7985 * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}.
7986 */
7987 public static final Uri FEEDBACK_URI =
7988 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback");
7989
7990 /**
Makoto Onuki7ebbfd02012-04-13 12:56:42 -07007991 * The content:// style URI for deleting all usage information.
7992 * Must be used with {@link ContentResolver#delete(Uri, String, String[])}.
7993 * The {@code where} and {@code selectionArgs} parameters are ignored.
7994 */
7995 public static final Uri DELETE_USAGE_URI =
7996 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage");
7997
7998 /**
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007999 * <p>
8000 * Name for query parameter specifying the type of data usage.
8001 * </p>
8002 */
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07008003 public static final String USAGE_TYPE = "type";
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008004
8005 /**
8006 * <p>
8007 * Type of usage for voice interaction, which includes phone call, voice chat, and
8008 * video chat.
8009 * </p>
8010 */
8011 public static final String USAGE_TYPE_CALL = "call";
8012
8013 /**
8014 * <p>
8015 * Type of usage for text interaction involving longer messages, which includes email.
8016 * </p>
8017 */
8018 public static final String USAGE_TYPE_LONG_TEXT = "long_text";
8019
8020 /**
8021 * <p>
8022 * Type of usage for text interaction involving shorter messages, which includes SMS,
8023 * text chat with email addresses.
8024 * </p>
8025 */
8026 public static final String USAGE_TYPE_SHORT_TEXT = "short_text";
8027 }
8028
8029 /**
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008030 * <p>
Yorke Leecadbe4c2014-06-20 11:52:27 -07008031 * Contact-specific information about whether or not a contact has been pinned by the user
8032 * at a particular position within the system contact application's user interface.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008033 * </p>
8034 *
8035 * <p>
8036 * This pinning information can be used by individual applications to customize how
8037 * they order particular pinned contacts. For example, a Dialer application could
8038 * use pinned information to order user-pinned contacts in a top row of favorites.
8039 * </p>
8040 *
8041 * <p>
8042 * It is possible for two or more contacts to occupy the same pinned position (due
8043 * to aggregation and sync), so this pinning information should be used on a best-effort
8044 * basis to order contacts in-application rather than an absolute guide on where a contact
8045 * should be positioned. Contacts returned by the ContactsProvider will not be ordered based
8046 * on this information, so it is up to the client application to reorder these contacts within
8047 * their own UI adhering to (or ignoring as appropriate) information stored in the pinned
8048 * column.
8049 * </p>
8050 *
8051 * <p>
8052 * By default, unpinned contacts will have a pinned position of
Yorke Lee7d246792014-07-25 10:05:55 -07008053 * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive
8054 * integers that are greater than 1.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008055 * </p>
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008056 */
8057 public static final class PinnedPositions {
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008058 /**
Yorke Lee0e040b02014-06-18 15:02:44 -07008059 * The method to invoke in order to undemote a formerly demoted contact. The contact id of
8060 * the contact must be provided as an argument. If the contact was not previously demoted,
8061 * nothing will be done.
Yorke Lee94c87612014-07-18 18:57:17 -07008062 * @hide
Yorke Lee0e040b02014-06-18 15:02:44 -07008063 */
8064 public static final String UNDEMOTE_METHOD = "undemote";
8065
8066 /**
Yorke Lee94c87612014-07-18 18:57:17 -07008067 * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing
8068 * will be done.
8069 *
8070 * @param contentResolver to perform the undemote operation on.
8071 * @param contactId the id of the contact to undemote.
8072 */
8073 public static void undemote(ContentResolver contentResolver, long contactId) {
8074 contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD,
8075 String.valueOf(contactId), null);
8076 }
8077
8078 /**
Yorke Leeb31c8ab2014-08-26 17:13:02 -07008079 * Pins a contact at a provided position, or unpins a contact.
8080 *
8081 * @param contentResolver to perform the pinning operation on.
8082 * @param pinnedPosition the position to pin the contact at. To unpin a contact, use
8083 * {@link PinnedPositions#UNPINNED}.
8084 */
8085 public static void pin(
8086 ContentResolver contentResolver, long contactId, int pinnedPosition) {
8087 final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId));
8088 final ContentValues values = new ContentValues();
8089 values.put(Contacts.PINNED, pinnedPosition);
8090 contentResolver.update(uri, values, null, null);
8091 }
8092
8093 /**
Yorke Lee94c87612014-07-18 18:57:17 -07008094 * Default value for the pinned position of an unpinned contact.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008095 */
Yorke Lee7d246792014-07-25 10:05:55 -07008096 public static final int UNPINNED = 0;
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008097
8098 /**
Yorke Lee3585e1a2013-07-31 18:53:31 -07008099 * Value of pinned position for a contact that a user has indicated should be considered
8100 * of the lowest priority. It is up to the client application to determine how to present
8101 * such a contact - for example all the way at the bottom of a contact list, or simply
8102 * just hidden from view.
8103 */
8104 public static final int DEMOTED = -1;
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008105 }
8106
8107 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008108 * Helper methods to display QuickContact dialogs that display all the information belonging to
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008109 * a specific {@link Contacts} entry.
8110 */
Evan Millare3ec9972009-09-30 19:37:36 -07008111 public static final class QuickContact {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008112 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008113 * Action used to launch the system contacts application and bring up a QuickContact dialog
8114 * for the provided {@link Contacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008115 */
Evan Millar5042f7e2009-09-30 21:28:33 -07008116 public static final String ACTION_QUICK_CONTACT =
Yorke Lee78814622014-09-04 16:07:50 -07008117 "android.provider.action.QUICK_CONTACT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008118
8119 /**
8120 * Extra used to specify pivot dialog location in screen coordinates.
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008121 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008122 * @hide
8123 */
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008124 @Deprecated
Makoto Onuki0e917332014-08-26 14:06:30 -07008125 public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008126
8127 /**
8128 * Extra used to specify size of pivot dialog.
8129 * @hide
8130 */
Makoto Onuki0e917332014-08-26 14:06:30 -07008131 public static final String EXTRA_MODE = "android.provider.extra.MODE";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008132
8133 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008134 * Extra used to indicate a list of specific MIME-types to exclude and not display in the
8135 * QuickContacts dialog. Stored as a {@link String} array.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008136 */
Makoto Onuki0e917332014-08-26 14:06:30 -07008137 public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008138
8139 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008140 * Small QuickContact mode, usually presented with minimal actions.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008141 */
8142 public static final int MODE_SMALL = 1;
8143
8144 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008145 * Medium QuickContact mode, includes actions and light summary describing
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008146 * the {@link Contacts} entry being shown. This may include social
8147 * status and presence details.
8148 */
8149 public static final int MODE_MEDIUM = 2;
8150
8151 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008152 * Large QuickContact mode, includes actions and larger, card-like summary
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008153 * of the {@link Contacts} entry being shown. This may include detailed
8154 * information, such as a photo.
8155 */
8156 public static final int MODE_LARGE = 3;
8157
8158 /**
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008159 * Constructs the QuickContacts intent with a view's rect.
8160 * @hide
8161 */
8162 public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri,
8163 int mode, String[] excludeMimes) {
8164 // Find location and bounds of target view, adjusting based on the
8165 // assumed local density.
8166 final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
8167 final int[] pos = new int[2];
8168 target.getLocationOnScreen(pos);
8169
8170 final Rect rect = new Rect();
8171 rect.left = (int) (pos[0] * appScale + 0.5f);
8172 rect.top = (int) (pos[1] * appScale + 0.5f);
8173 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
8174 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
8175
8176 return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes);
8177 }
8178
8179 /**
8180 * Constructs the QuickContacts intent.
8181 * @hide
8182 */
8183 public static Intent composeQuickContactsIntent(Context context, Rect target,
8184 Uri lookupUri, int mode, String[] excludeMimes) {
8185 // When launching from an Activiy, we don't want to start a new task, but otherwise
8186 // we *must* start a new task. (Otherwise startActivity() would crash.)
8187 Context actualContext = context;
8188 while ((actualContext instanceof ContextWrapper)
8189 && !(actualContext instanceof Activity)) {
8190 actualContext = ((ContextWrapper) actualContext).getBaseContext();
8191 }
Brian Attwell9ee66402014-08-11 22:42:26 -07008192 final int intentFlags = ((actualContext instanceof Activity)
8193 ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
8194 // Workaround for b/16898764. Declaring singleTop in manifest doesn't work.
8195 | Intent.FLAG_ACTIVITY_SINGLE_TOP;
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008196
8197 // Launch pivot dialog through intent for now
8198 final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
8199
8200 intent.setData(lookupUri);
8201 intent.setSourceBounds(target);
8202 intent.putExtra(EXTRA_MODE, mode);
8203 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
8204 return intent;
8205 }
8206
8207 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008208 * Trigger a dialog that lists the various methods of interacting with
8209 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008210 * {@link ContactsContract.Data} rows under that contact, and may also
8211 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008212 *
8213 * @param context The parent {@link Context} that may be used as the
8214 * parent for this dialog.
8215 * @param target Specific {@link View} from your layout that this dialog
8216 * should be centered around. In particular, if the dialog
8217 * has a "callout" arrow, it will be pointed and centered
8218 * around this {@link View}.
Evan Millar772722e2009-09-30 22:24:07 -07008219 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008220 * {@link Uri} that describes a specific contact to feature
8221 * in this dialog.
8222 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8223 * {@link #MODE_LARGE}, indicating the desired dialog size,
8224 * when supported.
8225 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8226 * to exclude when showing this dialog. For example, when
8227 * already viewing the contact details card, this can be used
8228 * to omit the details entry from the dialog.
8229 */
Evan Millare3ec9972009-09-30 19:37:36 -07008230 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008231 String[] excludeMimes) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008232 // Trigger with obtained rectangle
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008233 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8234 excludeMimes);
Yorke Lee4fc601a2013-12-06 16:35:29 -08008235 startActivityWithErrorToast(context, intent);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008236 }
8237
8238 /**
8239 * Trigger a dialog that lists the various methods of interacting with
8240 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008241 * {@link ContactsContract.Data} rows under that contact, and may also
8242 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008243 *
8244 * @param context The parent {@link Context} that may be used as the
8245 * parent for this dialog.
8246 * @param target Specific {@link Rect} that this dialog should be
8247 * centered around, in screen coordinates. In particular, if
8248 * the dialog has a "callout" arrow, it will be pointed and
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008249 * centered around this {@link Rect}. If you are running at a
8250 * non-native density, you need to manually adjust using
8251 * {@link DisplayMetrics#density} before calling.
Jeff Sharkey223bd7a2009-12-21 14:51:19 -08008252 * @param lookupUri A
8253 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008254 * {@link Uri} that describes a specific contact to feature
8255 * in this dialog.
8256 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8257 * {@link #MODE_LARGE}, indicating the desired dialog size,
8258 * when supported.
8259 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8260 * to exclude when showing this dialog. For example, when
8261 * already viewing the contact details card, this can be used
8262 * to omit the details entry from the dialog.
8263 */
Evan Millare3ec9972009-09-30 19:37:36 -07008264 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008265 String[] excludeMimes) {
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008266 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8267 excludeMimes);
Yorke Lee4fc601a2013-12-06 16:35:29 -08008268 startActivityWithErrorToast(context, intent);
8269 }
8270
8271 private static void startActivityWithErrorToast(Context context, Intent intent) {
8272 try {
8273 context.startActivity(intent);
8274 } catch (ActivityNotFoundException e) {
8275 Toast.makeText(context, com.android.internal.R.string.quick_contacts_not_available,
8276 Toast.LENGTH_SHORT).show();
8277 }
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008278 }
8279 }
8280
8281 /**
Dave Santoroa5282372011-06-29 00:25:16 -07008282 * Helper class for accessing full-size photos by photo file ID.
8283 * <p>
8284 * Usage example:
8285 * <dl>
8286 * <dt>Retrieving a full-size photo by photo file ID (see
8287 * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID})
8288 * </dt>
8289 * <dd>
8290 * <pre>
8291 * public InputStream openDisplayPhoto(long photoFileId) {
8292 * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
8293 * try {
Dave Santoro040e6b32011-07-15 15:14:08 -07008294 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
8295 * displayPhotoUri, "r");
Dave Santoroa5282372011-06-29 00:25:16 -07008296 * return fd.createInputStream();
Dave Santoro040e6b32011-07-15 15:14:08 -07008297 * } catch (IOException e) {
Dave Santoroa5282372011-06-29 00:25:16 -07008298 * return null;
8299 * }
8300 * }
8301 * </pre>
8302 * </dd>
8303 * </dl>
8304 * </p>
8305 */
8306 public static final class DisplayPhoto {
8307 /**
8308 * no public constructor since this is a utility class
8309 */
8310 private DisplayPhoto() {}
8311
8312 /**
8313 * The content:// style URI for this class, which allows access to full-size photos,
8314 * given a key.
8315 */
8316 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo");
8317
8318 /**
8319 * This URI allows the caller to query for the maximum dimensions of a display photo
8320 * or thumbnail. Requests to this URI can be performed on the UI thread because
8321 * they are always unblocking.
8322 */
8323 public static final Uri CONTENT_MAX_DIMENSIONS_URI =
8324 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions");
8325
8326 /**
8327 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8328 * contain this column, populated with the maximum height and width (in pixels)
8329 * that will be stored for a display photo. Larger photos will be down-sized to
8330 * fit within a square of this many pixels.
8331 */
8332 public static final String DISPLAY_MAX_DIM = "display_max_dim";
8333
8334 /**
8335 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8336 * contain this column, populated with the height and width (in pixels) for photo
8337 * thumbnails.
8338 */
8339 public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim";
8340 }
8341
8342 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008343 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
8344 * that involve contacts.
8345 */
8346 public static final class Intents {
8347 /**
8348 * This is the intent that is fired when a search suggestion is clicked on.
8349 */
8350 public static final String SEARCH_SUGGESTION_CLICKED =
8351 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
8352
8353 /**
8354 * This is the intent that is fired when a search suggestion for dialing a number
8355 * is clicked on.
8356 */
8357 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
8358 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
8359
8360 /**
8361 * This is the intent that is fired when a search suggestion for creating a contact
8362 * is clicked on.
8363 */
8364 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
8365 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
8366
8367 /**
Chiao Cheng2355d132013-03-20 16:54:06 -07008368 * This is the intent that is fired when the contacts database is created. <p> The
8369 * READ_CONTACT permission is required to receive these broadcasts.
8370 */
8371 public static final String CONTACTS_DATABASE_CREATED =
8372 "android.provider.Contacts.DATABASE_CREATED";
8373
8374 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008375 * Starts an Activity that lets the user pick a contact to attach an image to.
8376 * After picking the contact it launches the image cropper in face detection mode.
8377 */
8378 public static final String ATTACH_IMAGE =
8379 "com.android.contacts.action.ATTACH_IMAGE";
8380
8381 /**
Makoto Onuki85a01a62011-07-21 15:16:31 -07008382 * This is the intent that is fired when the user clicks the "invite to the network" button
8383 * on a contact. Only sent to an activity which is explicitly registered by a contact
8384 * provider which supports the "invite to the network" feature.
8385 * <p>
8386 * {@link Intent#getData()} contains the lookup URI for the contact.
8387 */
8388 public static final String INVITE_CONTACT =
8389 "com.android.contacts.action.INVITE_CONTACT";
8390
8391 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008392 * Takes as input a data URI with a mailto: or tel: scheme. If a single
8393 * contact exists with the given data it will be shown. If no contact
8394 * exists, a dialog will ask the user if they want to create a new
8395 * contact with the provided details filled in. If multiple contacts
8396 * share the data the user will be prompted to pick which contact they
8397 * want to view.
8398 * <p>
8399 * For <code>mailto:</code> URIs, the scheme specific portion must be a
8400 * raw email address, such as one built using
8401 * {@link Uri#fromParts(String, String, String)}.
8402 * <p>
8403 * For <code>tel:</code> URIs, the scheme specific portion is compared
8404 * to existing numbers using the standard caller ID lookup algorithm.
8405 * The number must be properly encoded, for example using
8406 * {@link Uri#fromParts(String, String, String)}.
8407 * <p>
8408 * Any extras from the {@link Insert} class will be passed along to the
8409 * create activity if there are no contacts to show.
8410 * <p>
8411 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
8412 * prompting the user when the contact doesn't exist.
8413 */
8414 public static final String SHOW_OR_CREATE_CONTACT =
8415 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
8416
8417 /**
Bai Taofc7838b2010-01-22 03:34:56 +08008418 * Starts an Activity that lets the user select the multiple phones from a
8419 * list of phone numbers which come from the contacts or
8420 * {@link #EXTRA_PHONE_URIS}.
8421 * <p>
8422 * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS}
8423 * could belong to the contacts or not, and will be selected by default.
8424 * <p>
8425 * The user's selection will be returned from
8426 * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
Fred Quintanaa31a9452010-04-13 14:52:20 -07008427 * if the resultCode is
Bai Taofc7838b2010-01-22 03:34:56 +08008428 * {@link android.app.Activity#RESULT_OK}, the array of picked phone
8429 * numbers are in the Intent's
8430 * {@link #EXTRA_PHONE_URIS}; otherwise, the
8431 * {@link android.app.Activity#RESULT_CANCELED} is returned if the user
8432 * left the Activity without changing the selection.
8433 *
8434 * @hide
8435 */
8436 public static final String ACTION_GET_MULTIPLE_PHONES =
8437 "com.android.contacts.action.GET_MULTIPLE_PHONES";
8438
8439 /**
Makoto Onuki90ddc902012-09-11 18:22:53 -07008440 * A broadcast action which is sent when any change has been made to the profile, such
8441 * as the profile name or the picture. A receiver must have
8442 * the android.permission.READ_PROFILE permission.
8443 *
8444 * @hide
8445 */
8446 public static final String ACTION_PROFILE_CHANGED =
8447 "android.provider.Contacts.PROFILE_CHANGED";
8448
8449 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008450 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
8451 * contact if no matching contact found. Otherwise, default behavior is
8452 * to prompt user with dialog before creating.
8453 * <p>
8454 * Type: BOOLEAN
8455 */
8456 public static final String EXTRA_FORCE_CREATE =
8457 "com.android.contacts.action.FORCE_CREATE";
8458
8459 /**
8460 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
8461 * description to be shown when prompting user about creating a new
8462 * contact.
8463 * <p>
8464 * Type: STRING
8465 */
8466 public static final String EXTRA_CREATE_DESCRIPTION =
8467 "com.android.contacts.action.CREATE_DESCRIPTION";
8468
8469 /**
Bai Taofc7838b2010-01-22 03:34:56 +08008470 * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value.
8471 * <p>
8472 * The phone numbers want to be picked by default should be passed in as
8473 * input value. These phone numbers could belong to the contacts or not.
8474 * <p>
8475 * The phone numbers which were picked by the user are returned as output
8476 * value.
8477 * <p>
8478 * Type: array of URIs, the tel URI is used for the phone numbers which don't
8479 * belong to any contact, the content URI is used for phone id in contacts.
Fred Quintanaa31a9452010-04-13 14:52:20 -07008480 *
Bai Taofc7838b2010-01-22 03:34:56 +08008481 * @hide
8482 */
8483 public static final String EXTRA_PHONE_URIS =
8484 "com.android.contacts.extra.PHONE_URIS";
8485
8486 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07008487 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
8488 * dialog location using screen coordinates. When not specified, the
8489 * dialog will be centered.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008490 *
8491 * @hide
Jeff Sharkey11322002009-06-04 17:25:51 -07008492 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008493 @Deprecated
Jeff Sharkey11322002009-06-04 17:25:51 -07008494 public static final String EXTRA_TARGET_RECT = "target_rect";
8495
8496 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008497 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
8498 * desired dialog style, usually a variation on size. One of
8499 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008500 *
8501 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008502 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008503 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008504 public static final String EXTRA_MODE = "mode";
8505
8506 /**
8507 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008508 *
8509 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008510 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008511 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008512 public static final int MODE_SMALL = 1;
8513
8514 /**
8515 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008516 *
8517 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008518 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008519 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008520 public static final int MODE_MEDIUM = 2;
8521
8522 /**
8523 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008524 *
8525 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008526 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008527 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008528 public static final int MODE_LARGE = 3;
8529
8530 /**
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008531 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
8532 * a list of specific MIME-types to exclude and not display. Stored as a
8533 * {@link String} array.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008534 *
8535 * @hide
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008536 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008537 @Deprecated
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008538 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
8539
8540 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008541 * Intents related to the Contacts app UI.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008542 *
8543 * @hide
Evan Millardc2da5f2009-06-18 16:07:13 -07008544 */
8545 public static final class UI {
8546 /**
8547 * The action for the default contacts list tab.
8548 */
8549 public static final String LIST_DEFAULT =
8550 "com.android.contacts.action.LIST_DEFAULT";
8551
8552 /**
8553 * The action for the contacts list tab.
8554 */
8555 public static final String LIST_GROUP_ACTION =
8556 "com.android.contacts.action.LIST_GROUP";
8557
8558 /**
8559 * When in LIST_GROUP_ACTION mode, this is the group to display.
8560 */
8561 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
8562
8563 /**
8564 * The action for the all contacts list tab.
8565 */
8566 public static final String LIST_ALL_CONTACTS_ACTION =
8567 "com.android.contacts.action.LIST_ALL_CONTACTS";
8568
8569 /**
8570 * The action for the contacts with phone numbers list tab.
8571 */
8572 public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
8573 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
8574
8575 /**
8576 * The action for the starred contacts list tab.
8577 */
8578 public static final String LIST_STARRED_ACTION =
8579 "com.android.contacts.action.LIST_STARRED";
8580
8581 /**
8582 * The action for the frequent contacts list tab.
8583 */
8584 public static final String LIST_FREQUENT_ACTION =
8585 "com.android.contacts.action.LIST_FREQUENT";
8586
8587 /**
Brian Attwelle98a95c2014-07-22 20:53:59 -07008588 * The action for the "Join Contact" picker.
8589 */
8590 public static final String PICK_JOIN_CONTACT_ACTION =
8591 "com.android.contacts.action.JOIN_CONTACT";
8592
8593 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008594 * The action for the "strequent" contacts list tab. It first lists the starred
8595 * contacts in alphabetical order and then the frequent contacts in descending
8596 * order of the number of times they have been contacted.
8597 */
8598 public static final String LIST_STREQUENT_ACTION =
8599 "com.android.contacts.action.LIST_STREQUENT";
8600
8601 /**
8602 * A key for to be used as an intent extra to set the activity
8603 * title to a custom String value.
8604 */
8605 public static final String TITLE_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008606 "com.android.contacts.extra.TITLE_EXTRA";
Evan Millardc2da5f2009-06-18 16:07:13 -07008607
8608 /**
8609 * Activity Action: Display a filtered list of contacts
8610 * <p>
8611 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
8612 * filtering
8613 * <p>
8614 * Output: Nothing.
8615 */
8616 public static final String FILTER_CONTACTS_ACTION =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008617 "com.android.contacts.action.FILTER_CONTACTS";
Evan Millardc2da5f2009-06-18 16:07:13 -07008618
8619 /**
8620 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
8621 * intents to supply the text on which to filter.
8622 */
8623 public static final String FILTER_TEXT_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008624 "com.android.contacts.extra.FILTER_TEXT";
Brian Attwelle98a95c2014-07-22 20:53:59 -07008625
8626 /**
8627 * Used with JOIN_CONTACT action to set the target for aggregation. This action type
8628 * uses contact ids instead of contact uris for the sake of backwards compatibility.
8629 * <p>
8630 * Type: LONG
8631 */
8632 public static final String TARGET_CONTACT_ID_EXTRA_KEY
8633 = "com.android.contacts.action.CONTACT_ID";
Evan Millardc2da5f2009-06-18 16:07:13 -07008634 }
8635
8636 /**
8637 * Convenience class that contains string constants used
8638 * to create contact {@link android.content.Intent Intents}.
8639 */
8640 public static final class Insert {
8641 /** The action code to use when adding a contact */
8642 public static final String ACTION = Intent.ACTION_INSERT;
8643
8644 /**
8645 * If present, forces a bypass of quick insert mode.
8646 */
8647 public static final String FULL_MODE = "full_mode";
8648
8649 /**
8650 * The extra field for the contact name.
8651 * <P>Type: String</P>
8652 */
8653 public static final String NAME = "name";
8654
8655 // TODO add structured name values here.
8656
8657 /**
8658 * The extra field for the contact phonetic name.
8659 * <P>Type: String</P>
8660 */
8661 public static final String PHONETIC_NAME = "phonetic_name";
8662
8663 /**
8664 * The extra field for the contact company.
8665 * <P>Type: String</P>
8666 */
8667 public static final String COMPANY = "company";
8668
8669 /**
8670 * The extra field for the contact job title.
8671 * <P>Type: String</P>
8672 */
8673 public static final String JOB_TITLE = "job_title";
8674
8675 /**
8676 * The extra field for the contact notes.
8677 * <P>Type: String</P>
8678 */
8679 public static final String NOTES = "notes";
8680
8681 /**
8682 * The extra field for the contact phone number.
8683 * <P>Type: String</P>
8684 */
8685 public static final String PHONE = "phone";
8686
8687 /**
8688 * The extra field for the contact phone number type.
8689 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008690 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008691 * or a string specifying a custom label.</P>
8692 */
8693 public static final String PHONE_TYPE = "phone_type";
8694
8695 /**
8696 * The extra field for the phone isprimary flag.
8697 * <P>Type: boolean</P>
8698 */
8699 public static final String PHONE_ISPRIMARY = "phone_isprimary";
8700
8701 /**
8702 * The extra field for an optional second contact phone number.
8703 * <P>Type: String</P>
8704 */
8705 public static final String SECONDARY_PHONE = "secondary_phone";
8706
8707 /**
8708 * The extra field for an optional second contact phone number type.
8709 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008710 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008711 * or a string specifying a custom label.</P>
8712 */
8713 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
8714
8715 /**
8716 * The extra field for an optional third contact phone number.
8717 * <P>Type: String</P>
8718 */
8719 public static final String TERTIARY_PHONE = "tertiary_phone";
8720
8721 /**
8722 * The extra field for an optional third contact phone number type.
8723 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008724 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008725 * or a string specifying a custom label.</P>
8726 */
8727 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
8728
8729 /**
8730 * The extra field for the contact email address.
8731 * <P>Type: String</P>
8732 */
8733 public static final String EMAIL = "email";
8734
8735 /**
8736 * The extra field for the contact email type.
8737 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008738 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008739 * or a string specifying a custom label.</P>
8740 */
8741 public static final String EMAIL_TYPE = "email_type";
8742
8743 /**
8744 * The extra field for the email isprimary flag.
8745 * <P>Type: boolean</P>
8746 */
8747 public static final String EMAIL_ISPRIMARY = "email_isprimary";
8748
8749 /**
8750 * The extra field for an optional second contact email address.
8751 * <P>Type: String</P>
8752 */
8753 public static final String SECONDARY_EMAIL = "secondary_email";
8754
8755 /**
8756 * The extra field for an optional second contact email type.
8757 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008758 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008759 * or a string specifying a custom label.</P>
8760 */
8761 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
8762
8763 /**
8764 * The extra field for an optional third contact email address.
8765 * <P>Type: String</P>
8766 */
8767 public static final String TERTIARY_EMAIL = "tertiary_email";
8768
8769 /**
8770 * The extra field for an optional third contact email type.
8771 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008772 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008773 * or a string specifying a custom label.</P>
8774 */
8775 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
8776
8777 /**
8778 * The extra field for the contact postal address.
8779 * <P>Type: String</P>
8780 */
8781 public static final String POSTAL = "postal";
8782
8783 /**
8784 * The extra field for the contact postal address type.
8785 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008786 * {@link CommonDataKinds.StructuredPostal}
Evan Millardc2da5f2009-06-18 16:07:13 -07008787 * or a string specifying a custom label.</P>
8788 */
8789 public static final String POSTAL_TYPE = "postal_type";
8790
8791 /**
8792 * The extra field for the postal isprimary flag.
8793 * <P>Type: boolean</P>
8794 */
8795 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
8796
8797 /**
8798 * The extra field for an IM handle.
8799 * <P>Type: String</P>
8800 */
8801 public static final String IM_HANDLE = "im_handle";
8802
8803 /**
8804 * The extra field for the IM protocol
Evan Millardc2da5f2009-06-18 16:07:13 -07008805 */
8806 public static final String IM_PROTOCOL = "im_protocol";
8807
8808 /**
8809 * The extra field for the IM isprimary flag.
8810 * <P>Type: boolean</P>
8811 */
8812 public static final String IM_ISPRIMARY = "im_isprimary";
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008813
8814 /**
8815 * The extra field that allows the client to supply multiple rows of
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07008816 * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT}
8817 * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of
8818 * {@link ContentValues}, one per data row. Supplying this extra is
8819 * similar to inserting multiple rows into the {@link Data} table,
8820 * except the user gets a chance to see and edit them before saving.
8821 * Each ContentValues object must have a value for {@link Data#MIMETYPE}.
8822 * If supplied values are not visible in the editor UI, they will be
8823 * dropped. Duplicate data will dropped. Some fields
8824 * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically
8825 * adjusted to comply with the constraints of the specific account type.
8826 * For example, an Exchange contact can only have one phone numbers of type Home,
8827 * so the contact editor may choose a different type for this phone number to
8828 * avoid dropping the valueable part of the row, which is the phone number.
8829 * <p>
8830 * Example:
8831 * <pre>
8832 * ArrayList&lt;ContentValues&gt; data = new ArrayList&lt;ContentValues&gt;();
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008833 *
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07008834 * ContentValues row1 = new ContentValues();
8835 * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE);
8836 * row1.put(Organization.COMPANY, "Android");
8837 * data.add(row1);
8838 *
8839 * ContentValues row2 = new ContentValues();
8840 * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
8841 * row2.put(Email.TYPE, Email.TYPE_CUSTOM);
8842 * row2.put(Email.LABEL, "Green Bot");
8843 * row2.put(Email.ADDRESS, "android@android.com");
8844 * data.add(row2);
8845 *
8846 * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
8847 * intent.putParcelableArrayListExtra(Insert.DATA, data);
8848 *
8849 * startActivity(intent);
8850 * </pre>
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008851 */
8852 public static final String DATA = "data";
Daniel Lehmanncde1ac62010-10-21 20:40:11 -07008853
8854 /**
8855 * Used to specify the account in which to create the new contact.
8856 * <p>
8857 * If this value is not provided, the user is presented with a disambiguation
8858 * dialog to chose an account
8859 * <p>
8860 * Type: {@link Account}
8861 *
8862 * @hide
8863 */
8864 public static final String ACCOUNT = "com.android.contacts.extra.ACCOUNT";
Dave Santoro1d55c332011-07-25 16:44:45 -07008865
8866 /**
8867 * Used to specify the data set within the account in which to create the
8868 * new contact.
8869 * <p>
8870 * This value is optional - if it is not specified, the contact will be
8871 * created in the base account, with no data set.
8872 * <p>
8873 * Type: String
8874 *
8875 * @hide
8876 */
8877 public static final String DATA_SET = "com.android.contacts.extra.DATA_SET";
Evan Millardc2da5f2009-06-18 16:07:13 -07008878 }
8879 }
Evan Millar088b2912009-05-28 15:24:37 -07008880}