|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.content.ContentResolver
public abstract class ContentResolver
This class provides applications access to the content model.
| Field Summary | |
|---|---|
static String |
CURSOR_DIR_BASE_TYPE
This is the Android platform's base MIME type for a content: URI containing a Cursor of zero or more items. |
static String |
CURSOR_ITEM_BASE_TYPE
This is the Android platform's base MIME type for a content: URI containing a Cursor of a single item. |
static String |
SCHEME_ANDROID_RESOURCE
|
static String |
SCHEME_CONTENT
|
static String |
SCHEME_FILE
|
static String |
SYNC_EXTRAS_ACCOUNT
|
static String |
SYNC_EXTRAS_DISCARD_LOCAL_DELETIONS
|
static String |
SYNC_EXTRAS_EXPEDITED
|
static String |
SYNC_EXTRAS_FORCE
|
static String |
SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS
|
static String |
SYNC_EXTRAS_UPLOAD
|
| Constructor Summary | |
|---|---|
ContentResolver(Context context)
|
|
| Method Summary | |
|---|---|
protected abstract IContentProvider |
acquireProvider(Context c,
String name)
|
IContentProvider |
acquireProvider(String name)
|
IContentProvider |
acquireProvider(Uri uri)
Returns the content provider for the given content URI.. |
int |
bulkInsert(Uri url,
ContentValues[] values)
Inserts multiple rows into a table at the given URL. |
void |
cancelSync(Uri uri)
|
int |
delete(Uri url,
String where,
String[] selectionArgs)
Deletes row(s) specified by a content URI. |
String |
getType(Uri url)
Return the MIME type of the given content URL. |
Uri |
insert(Uri url,
ContentValues values)
Inserts a row into a table at the given URL. |
void |
notifyChange(Uri uri,
ContentObserver observer)
Notify registered observers that a row was updated. |
void |
notifyChange(Uri uri,
ContentObserver observer,
boolean syncToNetwork)
Notify registered observers that a row was updated. |
ParcelFileDescriptor |
openFileDescriptor(Uri uri,
String mode)
Open a raw file descriptor to access data under a "content:" URI. |
InputStream |
openInputStream(Uri uri)
Open a stream on to the content associated with a content URI. |
OutputStream |
openOutputStream(Uri uri)
Open a stream on to the content associated with a content URI. |
Cursor |
query(Uri uri,
String[] projection,
String selection,
String[] selectionArgs,
String sortOrder)
Query the given URI, returning a Cursor over the result set. |
void |
registerContentObserver(Uri uri,
boolean notifyForDescendents,
ContentObserver observer)
Register an observer class that gets callbacks when data identified by a given content URI changes. |
abstract boolean |
releaseProvider(IContentProvider icp)
|
void |
startSync(Uri uri,
Bundle extras)
Start an asynchronous sync operation. |
void |
unregisterContentObserver(ContentObserver observer)
Unregisters a change observer. |
int |
update(Uri uri,
ContentValues values,
String where,
String[] selectionArgs)
Update row(s) in a content URI. |
static void |
validateSyncExtrasBundle(Bundle extras)
Check that only values of the following types are in the Bundle: Integer Long Boolean Float Double String null |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String SYNC_EXTRAS_ACCOUNT
public static final String SYNC_EXTRAS_EXPEDITED
public static final String SYNC_EXTRAS_FORCE
public static final String SYNC_EXTRAS_UPLOAD
public static final String SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS
public static final String SYNC_EXTRAS_DISCARD_LOCAL_DELETIONS
public static final String SCHEME_CONTENT
public static final String SCHEME_ANDROID_RESOURCE
public static final String SCHEME_FILE
public static final String CURSOR_ITEM_BASE_TYPE
content://com.company.provider.imap/inbox/1 for a particular
message in the inbox, whose MIME type would be reported as
CURSOR_ITEM_BASE_TYPE + "/vnd.company.imap-msg"
Compare with CURSOR_DIR_BASE_TYPE.
public static final String CURSOR_DIR_BASE_TYPE
content://com.company.provider.imap/inbox for all of the
messages in its inbox, whose MIME type would be reported as
CURSOR_DIR_BASE_TYPE + "/vnd.company.imap-msg"
Note how the base MIME type varies between this and
CURSOR_ITEM_BASE_TYPE depending on whether there is
one single item or multiple items in the data set, while the sub-type
remains the same because in either case the data structure contained
in the cursor is the same.
| Constructor Detail |
|---|
public ContentResolver(Context context)
| Method Detail |
|---|
protected abstract IContentProvider acquireProvider(Context c,
String name)
public abstract boolean releaseProvider(IContentProvider icp)
public final String getType(Uri url)
url - A Uri identifying content (either a list or specific type),
using the content:// scheme.
public final Cursor query(Uri uri,
String[] projection,
String selection,
String[] selectionArgs,
String sortOrder)
Cursor over the result set.
uri - The URI, using the content:// scheme, for the content to
retrieve.projection - A list of which columns to return. Passing null will
return all columns, which is discouraged to prevent reading data
from storage that isn't going to be used.selection - A filter declaring which rows to return, formatted as an
SQL WHERE clause (excluding the WHERE itself). Passing null will
return all rows for the given URI.selectionArgs - You may include ?s in selection, which will be
replaced by the values from selectionArgs, in the order that they
appear in the selection. The values will be bound as Strings.sortOrder - How to order the rows, formatted as an SQL ORDER BY
clause (excluding the ORDER BY itself). Passing null will use the
default sort order, which may be unordered.
Cursor
public final InputStream openInputStream(Uri uri)
throws FileNotFoundException
SCHEME_CONTENT)SCHEME_ANDROID_RESOURCE)SCHEME_FILE)SCHEME_ANDROID_RESOURCE) SchemeA Uri object can be used to reference a resource in an APK file. The Uri should be one of the following formats:
android.resource://package_name/id_numberpackage_name is your package name as listed in your AndroidManifest.xml.
For example com.example.myappid_number is the int form of the ID.Uri uri = Uri.parse("android.resource://com.example.myapp/" + R.raw.my_resource");
android.resource://package_name/type/namepackage_name is your package name as listed in your AndroidManifest.xml.
For example com.example.myapptype is the string form of the resource type. For example, raw
or drawable.
name is the string form of the resource name. That is, whatever the file
name was in your res directory, without the type extension.
The easiest way to construct this form is
Uri uri = Uri.parse("android.resource://com.example.myapp/raw/my_resource");
uri - The desired "content:" URI.
FileNotFoundException - if the provided URI could not be opened.
public final OutputStream openOutputStream(Uri uri)
throws FileNotFoundException
SCHEME_CONTENT)
uri - The desired "content:" URI.
FileNotFoundException
public final ParcelFileDescriptor openFileDescriptor(Uri uri,
String mode)
throws FileNotFoundException
ContentProvider.openFile(android.net.Uri, java.lang.String)
ContentProvider.openFile()} method of the provider associated with the
given URI, to retrieve any file stored there.
SCHEME_CONTENT)
uri - The desired URI to open.mode - The file mode to use, as per ContentProvider.openFile.
FileNotFoundException - Throws FileNotFoundException of no
file exists under the URI or the mode is invalid.
public final Uri insert(Uri url,
ContentValues values)
url - The URL of the table to insert into.values - The initial values for the newly inserted row. The key is the column name for
the field. Passing an empty ContentValues will create an empty row.
public final int bulkInsert(Uri url,
ContentValues[] values)
url - The URL of the table to insert into.values - The initial values for the newly inserted rows. The key is the column name for
the field. Passing null will create an empty row.
public final int delete(Uri url,
String where,
String[] selectionArgs)
url - The URL of the row to delete.where - A filter to apply to rows before deleting, formatted as an SQL WHERE clause
(excluding the WHERE itself).
public final int update(Uri uri,
ContentValues values,
String where,
String[] selectionArgs)
uri - The URI to modify.values - The new field values. The key is the column name for the field.
A null value will remove an existing field value.where - A filter to apply to rows before deleting, formatted as an SQL WHERE clause
(excluding the WHERE itself).
NullPointerException - if uri or values are nullpublic final IContentProvider acquireProvider(Uri uri)
uri - The URI to a content provider
public final IContentProvider acquireProvider(String name)
public final void registerContentObserver(Uri uri,
boolean notifyForDescendents,
ContentObserver observer)
uri - The URI to watch for changes. This can be a specific row URI, or a base URI
for a whole class of content.notifyForDescendents - If true changes to URIs beginning with uri
will also cause notifications to be sent. If false only changes to the exact URI
specified by uri will cause notifications to be sent. If true, than any URI values
at or below the specified URI will also trigger a match.observer - The object that receives callbacks when changes occur.unregisterContentObserver(android.database.ContentObserver)public final void unregisterContentObserver(ContentObserver observer)
observer - The previously registered observer that is no longer needed.registerContentObserver(android.net.Uri, boolean, android.database.ContentObserver)
public void notifyChange(Uri uri,
ContentObserver observer)
registerContentObserver().
By default, CursorAdapter objects will get this notification.
uri - observer - The observer that originated the change, may be null
public void notifyChange(Uri uri,
ContentObserver observer,
boolean syncToNetwork)
registerContentObserver().
By default, CursorAdapter objects will get this notification.
uri - observer - The observer that originated the change, may be nullsyncToNetwork - If true, attempt to sync the change to the network.
public void startSync(Uri uri,
Bundle extras)
uri - the uri of the provider to sync or null to sync all providers.extras - any extras to pass to the SyncAdapter.public static void validateSyncExtrasBundle(Bundle extras)
extras - the Bundle to checkpublic void cancelSync(Uri uri)
|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||