java.lang.Object | |
↳ | android.content.ContentResolver |
Known Direct Subclasses |
This class provides applications access to the content model.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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. | |||||||||
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. | |||||||||
String | SCHEME_ANDROID_RESOURCE | ||||||||||
String | SCHEME_CONTENT | ||||||||||
String | SCHEME_FILE | ||||||||||
String | SYNC_EXTRAS_ACCOUNT | ||||||||||
String | SYNC_EXTRAS_DISCARD_LOCAL_DELETIONS | ||||||||||
String | SYNC_EXTRAS_EXPEDITED | ||||||||||
String | SYNC_EXTRAS_FORCE | ||||||||||
String | SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS | ||||||||||
String | SYNC_EXTRAS_UPLOAD |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Inserts multiple rows into a table at the given URL.
| |||||||||||
Deletes row(s) specified by a content URI.
| |||||||||||
Return the MIME type of the given content URL.
| |||||||||||
Inserts a row into a table at the given URL.
| |||||||||||
Notify registered observers that a row was updated.
| |||||||||||
Notify registered observers that a row was updated.
| |||||||||||
Open a raw file descriptor to access data under a "content:" URI.
| |||||||||||
Open a raw file descriptor to access data under a "content:" URI.
| |||||||||||
Open a stream on to the content associated with a content URI.
| |||||||||||
Synonym for openOutputStream(uri, "w").
| |||||||||||
Open a stream on to the content associated with a content URI.
| |||||||||||
Query the given URI, returning a Cursor over the result set.
| |||||||||||
Register an observer class that gets callbacks when data identified by a
given content URI changes.
| |||||||||||
Start an asynchronous sync operation.
| |||||||||||
Unregisters a change observer.
| |||||||||||
Update row(s) in a content URI.
| |||||||||||
Check that only values of the following types are in the Bundle:
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
This is the Android platform's base MIME type for a content: URI
containing a Cursor of zero or more items. Applications should use this
as the base type along with their own sub-type of their content: URIs
that represent a directory of items. For example, hypothetical IMAP email
client may have a URI
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.
This is the Android platform's base MIME type for a content: URI
containing a Cursor of a single item. Applications should use this
as the base type along with their own sub-type of their content: URIs
that represent a particular item. For example, hypothetical IMAP email
client may have a URI
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.
Inserts multiple rows into a table at the given URL. This function make no guarantees about the atomicity of the insertions.
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. |
Deletes row(s) specified by a content URI. If the content provider supports transactions, the deletion will be atomic.
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). |
Return the MIME type of the given content URL.
url | A Uri identifying content (either a list or specific type), using the content:// scheme. |
---|
Inserts a row into a table at the given URL. If the content provider supports transactions the insertion will be atomic.
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. |
Notify registered observers that a row was updated. To register, call registerContentObserver(). By default, CursorAdapter objects will get this notification.
observer | The observer that originated the change, may be null
|
---|
Notify registered observers that a row was updated. To register, call registerContentObserver(). By default, CursorAdapter objects will get this notification.
observer | The observer that originated the change, may be null |
---|---|
syncToNetwork | If true, attempt to sync the change to the network. |
Open a raw file descriptor to access data under a "content:" URI. This interacts with the underlying openAssetFile(Uri, String) ContentProvider.openAssetFile()} method of the provider associated with the given URI, to retrieve any file stored there.
A 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_number
package_name
is your package name as listed in your AndroidManifest.xml.
For example com.example.myapp
id_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/name
package_name
is your package name as listed in your AndroidManifest.xml.
For example com.example.myapp
type
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 URI to open. |
---|---|
mode | The file mode to use, as per ContentProvider.openAssetFile. |
FileNotFoundException | Throws FileNotFoundException of no file exists under the URI or the mode is invalid. |
---|
Open a raw file descriptor to access data under a "content:" URI. This is like openAssetFileDescriptor(Uri, String), but uses the underlying openFile(Uri, String) ContentProvider.openFile()} method, so will not work with providers that return sub-sections of files. If at all possible, you should use openAssetFileDescriptor(Uri, String). You will receive a FileNotFoundException exception if the provider returns a sub-section of a file.
See openAssetFileDescriptor(Uri, String) for more information on these schemes.
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. |
---|
Open a stream on to the content associated with a content URI. If there is no data associated with the URI, FileNotFoundException is thrown.
See openAssetFileDescriptor(Uri, String) for more information on these schemes.
uri | The desired URI. |
---|
FileNotFoundException | if the provided URI could not be opened. |
---|
Synonym for openOutputStream(uri, "w").
FileNotFoundException | if the provided URI could not be opened. |
---|
Open a stream on to the content associated with a content URI. If there is no data associated with the URI, FileNotFoundException is thrown.
See openAssetFileDescriptor(Uri, String) for more information on these schemes.
uri | The desired URI. |
---|---|
mode | May be "w", "wa", "rw", or "rwt". |
FileNotFoundException | if the provided URI could not be opened. |
---|
Query the given URI, returning a 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. |
Register an observer class that gets callbacks when data identified by a given content URI changes.
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. |
Start an asynchronous sync operation. If you want to monitor the progress of the sync you may register a SyncObserver. Only values of the following types may be used in the extras bundle:
uri | the uri of the provider to sync or null to sync all providers. |
---|---|
extras | any extras to pass to the SyncAdapter. |
Unregisters a change observer.
observer | The previously registered observer that is no longer needed. |
---|
Update row(s) in a content URI. If the content provider supports transactions the update will be atomic.
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 null |
---|
Check that only values of the following types are in the Bundle:
extras | the Bundle to check |
---|