diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-08-06 12:16:55 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2010-08-08 18:49:31 -0700 |
commit | 23fdaf6fb62a9b5154b2508916a21c678462c5d0 (patch) | |
tree | 14b794a1f76f738576bbaa8295141914f5b2b123 /core/java/android/content/ContentProviderClient.java | |
parent | 163935113919a184122b8b3bd672ef08c8df65dc (diff) | |
download | frameworks_base-23fdaf6fb62a9b5154b2508916a21c678462c5d0.zip frameworks_base-23fdaf6fb62a9b5154b2508916a21c678462c5d0.tar.gz frameworks_base-23fdaf6fb62a9b5154b2508916a21c678462c5d0.tar.bz2 |
Add new ContentProvider for doing conversions to data streams.
This introduces basic infrastructure that should allow content
providers holding complex data to perform on-demand conversion
of their data to streams of various types. It is achieved through
two new content provider APIs, one to interrogate the possible
stream MIME types the provider can return, and the other to
request a stream of data in a particular MIME type.
Because implementations of this will often need to do on-demand
data conversion, there is also a utility intoduced in ContentProvider
for subclasses to easily run a function to write data into a
pipe that is read by the client.
This feature is mostly intended for cut and paste and drag and
drop, as the complex data interchange allowing the source and
destination to negotiate data types and copy (possible large)
data between them. However because it is fundamental facility
of ContentProvider, it can be used in other places, such as for
more advanced GET_CONTENT data exchanges.
An example implementation of this would be in ContactsProvider,
which can now provider a data stream when a client opens certain
pieces of it data, to return data as flat text, a vcard, or other
format.
Change-Id: I58627ea4ed359aa7cf2c66274adb18306c209cb2
Diffstat (limited to 'core/java/android/content/ContentProviderClient.java')
-rw-r--r-- | core/java/android/content/ContentProviderClient.java | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/core/java/android/content/ContentProviderClient.java b/core/java/android/content/ContentProviderClient.java index 0858ea5..0540109 100644 --- a/core/java/android/content/ContentProviderClient.java +++ b/core/java/android/content/ContentProviderClient.java @@ -18,6 +18,7 @@ package android.content; import android.database.Cursor; import android.net.Uri; +import android.os.Bundle; import android.os.RemoteException; import android.os.ParcelFileDescriptor; import android.content.res.AssetFileDescriptor; @@ -43,53 +44,77 @@ public class ContentProviderClient { mContentResolver = contentResolver; } - /** see {@link ContentProvider#query} */ + /** See {@link ContentProvider#query ContentProvider.query} */ public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder) throws RemoteException { return mContentProvider.query(url, projection, selection, selectionArgs, sortOrder); } - /** see {@link ContentProvider#getType} */ + /** See {@link ContentProvider#getType ContentProvider.getType} */ public String getType(Uri url) throws RemoteException { return mContentProvider.getType(url); } - /** see {@link ContentProvider#insert} */ + /** See {@link ContentProvider#getStreamTypes ContentProvider.getStreamTypes} */ + public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { + return mContentProvider.getStreamTypes(url, mimeTypeFilter); + } + + /** See {@link ContentProvider#insert ContentProvider.insert} */ public Uri insert(Uri url, ContentValues initialValues) throws RemoteException { return mContentProvider.insert(url, initialValues); } - /** see {@link ContentProvider#bulkInsert} */ + /** See {@link ContentProvider#bulkInsert ContentProvider.bulkInsert} */ public int bulkInsert(Uri url, ContentValues[] initialValues) throws RemoteException { return mContentProvider.bulkInsert(url, initialValues); } - /** see {@link ContentProvider#delete} */ + /** See {@link ContentProvider#delete ContentProvider.delete} */ public int delete(Uri url, String selection, String[] selectionArgs) throws RemoteException { return mContentProvider.delete(url, selection, selectionArgs); } - /** see {@link ContentProvider#update} */ + /** See {@link ContentProvider#update ContentProvider.update} */ public int update(Uri url, ContentValues values, String selection, String[] selectionArgs) throws RemoteException { return mContentProvider.update(url, values, selection, selectionArgs); } - /** see {@link ContentProvider#openFile} */ + /** + * See {@link ContentProvider#openFile ContentProvider.openFile}. Note that + * this <em>does not</em> + * take care of non-content: URIs such as file:. It is strongly recommended + * you use the {@link ContentResolver#openFileDescriptor + * ContentResolver.openFileDescriptor} API instead. + */ public ParcelFileDescriptor openFile(Uri url, String mode) throws RemoteException, FileNotFoundException { return mContentProvider.openFile(url, mode); } - /** see {@link ContentProvider#openAssetFile} */ + /** + * See {@link ContentProvider#openAssetFile ContentProvider.openAssetFile}. + * Note that this <em>does not</em> + * take care of non-content: URIs such as file:. It is strongly recommended + * you use the {@link ContentResolver#openAssetFileDescriptor + * ContentResolver.openAssetFileDescriptor} API instead. + */ public AssetFileDescriptor openAssetFile(Uri url, String mode) throws RemoteException, FileNotFoundException { return mContentProvider.openAssetFile(url, mode); } - /** see {@link ContentProvider#applyBatch} */ + /** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile} */ + public final AssetFileDescriptor openTypedAssetFileDescriptor(Uri uri, + String mimeType, Bundle opts) + throws RemoteException, FileNotFoundException { + return mContentProvider.openTypedAssetFile(uri, mimeType, opts); + } + + /** See {@link ContentProvider#applyBatch ContentProvider.applyBatch} */ public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) throws RemoteException, OperationApplicationException { return mContentProvider.applyBatch(operations); |