ContentProviderClient
public
class
ContentProviderClient
extends Object
implements
AutoCloseable
| java.lang.Object | |
| ↳ | android.content.ContentProviderClient |
The public interface object used to interact with a specific
ContentProvider.
Instances can be obtained by calling
acquireContentProviderClient(Uri) or
acquireUnstableContentProviderClient(Uri). Instances must
be released using close() in order to indicate to the system that
the underlying ContentProvider is no longer needed and can be killed
to free up resources.
Note that you should generally create a new ContentProviderClient instance
for each thread that will be performing operations. Unlike
ContentResolver, the methods here such as query(Uri, String[], Bundle, CancellationSignal) and
openFile(Uri, String) are not thread safe -- you must not call close()
on the ContentProviderClient those calls are made from until you are finished
with the data they have returned.
Summary
Protected methods | |
|---|---|
void
|
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
Inherited methods | |
|---|---|
java.lang.Object
| |
java.lang.AutoCloseable
| |
Public methods
applyBatch
ContentProviderResult[] applyBatch (ArrayList<ContentProviderOperation> operations)
See ContentProvider.applyBatch
| Parameters | |
|---|---|
operations |
ArrayList This value must never be |
| Returns | |
|---|---|
ContentProviderResult[] |
This value will never be |
| Throws | |
|---|---|
RemoteException |
|
OperationApplicationException |
|
bulkInsert
int bulkInsert (Uri url, ContentValues[] initialValues)
See ContentProvider.bulkInsert
| Parameters | |
|---|---|
url |
Uri This value must never be |
initialValues |
ContentValues This value must never be |
| Returns | |
|---|---|
int |
|
| Throws | |
|---|---|
RemoteException |
|
call
Bundle call (String method, String arg, Bundle extras)
See call(String, String, Bundle)
| Parameters | |
|---|---|
method |
String This value must never be |
arg |
String This value may be |
extras |
Bundle This value may be |
| Returns | |
|---|---|
Bundle |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
canonicalize
Uri canonicalize (Uri url)
| Parameters | |
|---|---|
url |
Uri This value must never be |
| Returns | |
|---|---|
Uri |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
close
void close ()
Closes this client connection, indicating to the system that the
underlying ContentProvider is no longer needed.
delete
int delete (Uri url, String selection, String[] selectionArgs)
| Parameters | |
|---|---|
url |
Uri This value must never be |
selection |
String This value may be |
selectionArgs |
String This value may be |
| Returns | |
|---|---|
int |
|
| Throws | |
|---|---|
RemoteException |
|
getLocalContentProvider
ContentProvider getLocalContentProvider ()
Get a reference to the ContentProvider that is associated with this
client. If the ContentProvider is running in a different process then
null will be returned. This can be used if you know you are running in the same
process as a provider, and want to get direct access to its implementation details.
| Returns | |
|---|---|
ContentProvider |
If the associated ContentProvider is local, returns it.
Otherwise returns null.
This value may be |
getStreamTypes
String[] getStreamTypes (Uri url, String mimeTypeFilter)
See ContentProvider.getStreamTypes
| Parameters | |
|---|---|
url |
Uri This value must never be |
mimeTypeFilter |
String This value must never be |
| Returns | |
|---|---|
String[] |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
getType
String getType (Uri url)
| Parameters | |
|---|---|
url |
Uri This value must never be |
| Returns | |
|---|---|
String |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
insert
Uri insert (Uri url, ContentValues initialValues)
| Parameters | |
|---|---|
url |
Uri This value must never be |
initialValues |
ContentValues This value may be |
| Returns | |
|---|---|
Uri |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
openAssetFile
AssetFileDescriptor openAssetFile (Uri url, String mode, CancellationSignal signal)
See ContentProvider.openAssetFile.
Note that this does not
take care of non-content: URIs such as file:. It is strongly recommended
you use the ContentResolver.openAssetFileDescriptor API instead.
| Parameters | |
|---|---|
url |
Uri This value must never be |
mode |
String This value must never be |
signal |
CancellationSignal This value may be |
| Returns | |
|---|---|
AssetFileDescriptor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
FileNotFoundException |
|
openAssetFile
AssetFileDescriptor openAssetFile (Uri url, String mode)
See ContentProvider.openAssetFile.
Note that this does not
take care of non-content: URIs such as file:. It is strongly recommended
you use the ContentResolver.openAssetFileDescriptor API instead.
| Parameters | |
|---|---|
url |
Uri This value must never be |
mode |
String This value must never be |
| Returns | |
|---|---|
AssetFileDescriptor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
FileNotFoundException |
|
openFile
ParcelFileDescriptor openFile (Uri url, String mode, CancellationSignal signal)
See ContentProvider.openFile. Note that
this does not
take care of non-content: URIs such as file:. It is strongly recommended
you use the ContentResolver.openFileDescriptor API instead.
| Parameters | |
|---|---|
url |
Uri This value must never be |
mode |
String This value must never be |
signal |
CancellationSignal This value may be |
| Returns | |
|---|---|
ParcelFileDescriptor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
FileNotFoundException |
|
openFile
ParcelFileDescriptor openFile (Uri url, String mode)
See ContentProvider.openFile. Note that
this does not
take care of non-content: URIs such as file:. It is strongly recommended
you use the ContentResolver.openFileDescriptor API instead.
| Parameters | |
|---|---|
url |
Uri This value must never be |
mode |
String This value must never be |
| Returns | |
|---|---|
ParcelFileDescriptor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
FileNotFoundException |
|
openTypedAssetFileDescriptor
AssetFileDescriptor openTypedAssetFileDescriptor (Uri uri, String mimeType, Bundle opts, CancellationSignal signal)
See ContentProvider.openTypedAssetFile
| Parameters | |
|---|---|
uri |
Uri This value must never be |
mimeType |
String This value must never be |
opts |
Bundle This value may be |
signal |
CancellationSignal This value may be |
| Returns | |
|---|---|
AssetFileDescriptor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
FileNotFoundException |
|
openTypedAssetFileDescriptor
AssetFileDescriptor openTypedAssetFileDescriptor (Uri uri, String mimeType, Bundle opts)
See ContentProvider.openTypedAssetFile
| Parameters | |
|---|---|
uri |
Uri This value must never be |
mimeType |
String This value must never be |
opts |
Bundle This value may be |
| Returns | |
|---|---|
AssetFileDescriptor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
FileNotFoundException |
|
query
Cursor query (Uri uri, String[] projection, Bundle queryArgs, CancellationSignal cancellationSignal)
| Parameters | |
|---|---|
uri |
Uri This value must never be |
projection |
String This value may be |
queryArgs |
Bundle |
cancellationSignal |
CancellationSignal This value may be |
| Returns | |
|---|---|
Cursor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
query
Cursor query (Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder)
| Parameters | |
|---|---|
url |
Uri This value must never be |
projection |
String This value may be |
selection |
String This value may be |
selectionArgs |
String This value may be |
sortOrder |
String This value may be |
| Returns | |
|---|---|
Cursor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
query
Cursor query (Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal)
| Parameters | |
|---|---|
uri |
Uri This value must never be |
projection |
String This value may be |
selection |
String This value may be |
selectionArgs |
String This value may be |
sortOrder |
String This value may be |
cancellationSignal |
CancellationSignal This value may be |
| Returns | |
|---|---|
Cursor |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
refresh
boolean refresh (Uri url, Bundle args, CancellationSignal cancellationSignal)
See refresh(Uri, Bundle, CancellationSignal)
| Parameters | |
|---|---|
url |
Uri |
args |
Bundle This value may be |
cancellationSignal |
CancellationSignal This value may be |
| Returns | |
|---|---|
boolean |
|
| Throws | |
|---|---|
RemoteException |
|
release
boolean release ()
This method was deprecated
in API level 24.
replaced by close().
| Returns | |
|---|---|
boolean |
|
uncanonicalize
Uri uncanonicalize (Uri url)
| Parameters | |
|---|---|
url |
Uri This value must never be |
| Returns | |
|---|---|
Uri |
This value may be |
| Throws | |
|---|---|
RemoteException |
|
update
int update (Uri url, ContentValues values, String selection, String[] selectionArgs)
| Parameters | |
|---|---|
url |
Uri This value must never be |
values |
ContentValues This value may be |
selection |
String This value may be |
selectionArgs |
String This value may be |
| Returns | |
|---|---|
int |
|
| Throws | |
|---|---|
RemoteException |
|
Protected methods
finalize
void finalize ()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the finalize method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked
if and when the Java™ virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize method may take any action, including
making this object available again to other threads; the usual purpose
of finalize, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize method of class Object performs no
special action; it simply returns normally. Subclasses of
Object may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize method causes
the finalization of this object to be halted, but is otherwise
ignored.
| Throws | |
|---|---|
Throwable |
|
Interfaces
- ClipboardManager.OnPrimaryClipChangedListener
- ComponentCallbacks
- ComponentCallbacks2
- ContentProvider.PipeDataWriter
- DialogInterface
- DialogInterface.OnCancelListener
- DialogInterface.OnClickListener
- DialogInterface.OnDismissListener
- DialogInterface.OnKeyListener
- DialogInterface.OnMultiChoiceClickListener
- DialogInterface.OnShowListener
- EntityIterator
- IntentSender.OnFinished
- Loader.OnLoadCanceledListener
- Loader.OnLoadCompleteListener
- ServiceConnection
- SharedPreferences
- SharedPreferences.Editor
- SharedPreferences.OnSharedPreferenceChangeListener
- SyncStatusObserver
Classes
- AbstractThreadedSyncAdapter
- AsyncQueryHandler
- AsyncQueryHandler.WorkerArgs
- AsyncQueryHandler.WorkerHandler
- AsyncTaskLoader
- BroadcastReceiver
- BroadcastReceiver.PendingResult
- ClipboardManager
- ClipData
- ClipData.Item
- ClipDescription
- ComponentName
- ContentProvider
- ContentProviderClient
- ContentProviderOperation
- ContentProviderOperation.Builder
- ContentProviderResult
- ContentQueryMap
- ContentResolver
- ContentUris
- ContentValues
- Context
- ContextWrapper
- CursorLoader
- Entity
- Entity.NamedContentValues
- Intent
- Intent.FilterComparison
- Intent.ShortcutIconResource
- IntentFilter
- IntentFilter.AuthorityEntry
- IntentSender
- Loader
- Loader.ForceLoadContentObserver
- MutableContextWrapper
- PeriodicSync
- QuickViewConstants
- RestrictionEntry
- RestrictionsManager
- SearchRecentSuggestionsProvider
- SyncAdapterType
- SyncContext
- SyncInfo
- SyncRequest
- SyncRequest.Builder
- SyncResult
- SyncStats
- UriMatcher
- UriPermission
Exceptions