Reference:Android.content.ContentResolver

From Triled Wiki

Jump to: navigation, search


android.content
public abstract class android.content.ContentResolver

java.lang.Object
android.content.ContentResolver

This class provides applications access to the content model.

[edit] Summary

[edit] Constants

      Value  
String   SCHEME_ANDROID_RESOURCE     "android.resource" 
String   SCHEME_CONTENT     "content" 
String   SCHEME_FILE     "file" 
String   SYNC_EXTRAS_ACCOUNT     "account" 
String   SYNC_EXTRAS_EXPEDITED     "expedited" 

[edit] Public Constructors

          ContentResolver (Context context)

[edit] Public Methods

    final    int  bulkInsert (Uri url, ContentValues[ ] values)
Inserts multiple rows into a table at the given URL.
        void  cancelSync ()
    final    int  delete (Uri url, String where, String[ ] selectionArgs)
Deletes row(s) specified by a content URI.
    final    String   getDataFilePath (Uri url)
DO NOT USE THIS FUNCTION!! Someone added this, and they shouldn't have.
    final    IContentProvider   getProvider (Uri uri)
Returns the content provider for the given content URI..
    final    IContentProvider   getProviderByName (String name)
Returns the content provider for the given name.
        String   getSyncMoreStatusText ()
        String   getSyncStatusText ()
        String   getSyncingAccount ()
    final    String   getType (Uri url)
Return the MIME type of the given content URL.
    final    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.
    final    ParcelFileDescriptor   openFileDescriptor (Uri uri, String mode)
Open a raw file descriptor to access data under a "content:" URI.
    final    InputStream   openInputStream (Uri uri)
Open a stream on to the content associated with a content URI.
    final    OutputStream   openOutputStream (Uri uri)
Open a stream on to the content associated with a content URI.
    final    Cursor   query (Uri uri, String[ ] projection, String selection, String[ ] selectionArgs, String sortOrder)
Query the given URI, returning a Cursor over the result set.
    final    void  registerContentObserver (Uri uri, boolean notifyForDescendents, ContentObserver observer)
Register an observer class that gets callbacks when data identified by a given content URI changes.
        void  registerSyncObserver (SyncObserver observer)
Register an observer of sync progress.
        void  startSync (Uri uri, Map extras)
Start an asynchronous sync operation.
    final    void  unregisterContentObserver (ContentObserver observer)
Unregisters a change observer.
        void  unregisterSyncObserver (SyncObserver observer)
Unregister an observer of sync progress.
    final    int  update (Uri uri, ContentValues values, String where, String[ ] selectionArgs)
Update row(s) in a content URI.

[edit] Protected Methods

abstract        IContentProvider   getProviderByName (Context context, String name)
abstract        void  removeProvider (IContentProvider provider)

[edit] Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

[edit] Details

[edit] Constants

[edit] public static final String SCHEME_ANDROID_RESOURCE

Constant Value: "android.resource"

[edit] public static final String SCHEME_CONTENT

Constant Value: "content"

[edit] public static final String SCHEME_FILE

Constant Value: "file"

[edit] public static final String SYNC_EXTRAS_ACCOUNT

Constant Value: "account"

[edit] public static final String SYNC_EXTRAS_EXPEDITED

Constant Value: "expedited"

[edit] Public Constructors

[edit] public ContentResolver(Context context)

[edit] Public Methods

[edit] public final int bulkInsert(Uri url, ContentValues[ ] values)

Inserts multiple rows into a table at the given URL. If the content provider supports transactions all of the insertions will be atomic.

Parameters

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.

Returns

  • the number of newly created rows.

[edit] public void cancelSync()

[edit] public final int delete(Uri url, String where, String[ ] selectionArgs)

Deletes row(s) specified by a content URI. If the content provider supports transactions, the deletion will be atomic.

Parameters

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).

Returns

  • The number of rows deleted.

[edit] public final String getDataFilePath(Uri url)

DO NOT USE THIS FUNCTION!! Someone added this, and they shouldn't have. You do not have direct access to files inside of a content provider. Don't touch this. Go away.

Return the path to the content associated with a content URL. If there is no data associated with the URL, null is returned.

Parameters

url The desired content URL.

Returns

  • Path

[edit] public final IContentProvider getProvider(Uri uri)

Returns the content provider for the given content URI..

Parameters

uri The URI to a content provider

Returns

  • The ContentProvider for the given URI, or null if no content provider is found.

[edit] public final IContentProvider getProviderByName(String name)

Returns the content provider for the given name.

Parameters

name The name of a content provider

Returns

  • The ContentProvider for the given name, or null if no content provider is found.

[edit] public String getSyncMoreStatusText()

[edit] public String getSyncStatusText()

[edit] public String getSyncingAccount()

[edit] public final String getType(Uri url)

Return the MIME type of the given content URL.

Parameters

url A Uri identifying content (either a list or specific type), using the content:// scheme.

Returns

  • A MIME type for the content, or null if the URL is invalid or the type is unknown

[edit] public final Uri insert(Uri url, ContentValues values)

Inserts a row into a table at the given URL. If the content provider supports transactions the insertion will be atomic.

Parameters

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 null will create an empty row.

Returns

  • the URL of the newly created row.

[edit] public void notifyChange(Uri uri, ContentObserver observer)

Notify registered observers that a row was updated. To register, call registerContentObserver(). By default, CursorAdapter objects will get this notification.

Parameters

observer The observer that originated the change, may be null

[edit] public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork)

Notify registered observers that a row was updated. To register, call registerContentObserver(). By default, CursorAdapter objects will get this notification.

Parameters

observer The observer that originated the change, may be null
syncToNetwork If true, attempt to sync the change to the network.

[edit] public final ParcelFileDescriptor openFileDescriptor(Uri uri, String mode)

Open a raw file descriptor to access data under a "content:" URI. This interacts with the underlying openFile(Uri, String) ContentProvider.openFile()} method of the provider associated with the given URI, to retrieve any file stored there.
[edit] Accepts the following URI schemes:

Parameters

uri The desired URI to open.
mode The file mode to use, as per ContentProvider.openFile.

Returns

  • Returns a new ParcelFileDescriptor pointing to the file. You own this descriptor and are responsible for closing it when done.

Throws

FileNotFoundException Throws FileNotFoundException of no file exists under the URI or the mode is invalid.

[edit] public final InputStream openInputStream(Uri uri)

Open a stream on to the content associated with a content URI. If there is no data associated with the URI, FileNotFoundException is thrown.
[edit] Accepts the following URI schemes:

Parameters

uri The desired "content:" URI.

Returns

  • InputStream

Throws

FileNotFoundException if the provided URI could not be opened.

[edit] public final OutputStream openOutputStream(Uri uri)

Open a stream on to the content associated with a content URI. If there is no data associated with the URI, FileNotFoundException is thrown.
[edit] Accepts the following URI schemes:

Parameters

uri The desired "content:" URI.

Returns

  • OutputStream

Throws

FileNotFoundException

[edit] public final Cursor query(Uri uri, String[ ] projection, String selection, String[ ] selectionArgs, String sortOrder)

Query the given URI, returning a Cursor over the result set.

Parameters

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.

Returns

  • A Cursor object, which is positioned before the first entry

See Also

[edit] public final void registerContentObserver(Uri uri, boolean notifyForDescendents, ContentObserver observer)

Register an observer class that gets callbacks when data identified by a given content URI changes.

Parameters

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 uriwill 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.

See Also

[edit] public void registerSyncObserver(SyncObserver observer)

Register an observer of sync progress.

Parameters

observer the observer to register.

[edit] public void startSync(Uri uri, Map extras)

Start an asynchronous sync operation. If you want to monitor the progress of the sync you may register a SyncObvserver.

Parameters

uri the uri of the provider to sync or null to sync all providers.
extras any extras to pass to the SyncAdapter.

[edit] public final void unregisterContentObserver(ContentObserver observer)

Unregisters a change observer.

Parameters

observer The previously registered observer that is no longer needed.

See Also

[edit] public void unregisterSyncObserver(SyncObserver observer)

Unregister an observer of sync progress.

Parameters

observer the observer to unregister.

[edit] public final int update(Uri uri, ContentValues values, String where, String[ ] selectionArgs)

Update row(s) in a content URI. If the content provider supports transactions the update will be atomic.

Parameters

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).

Returns

  • the URL of the newly created row

Throws

NullPointerException if uri or values are null

[edit] Protected Methods

[edit] protected abstract IContentProvider getProviderByName(Context context, String name)

[edit] protected abstract void removeProvider(IContentProvider provider)

[edit] References

Personal tools