Added in API level 5

ContentProviderClient


open class ContentProviderClient : AutoCloseable
kotlin.Any
   ↳ android.content.ContentProviderClient

The public interface object used to interact with a specific ContentProvider.

Instances can be obtained by calling android.content.ContentResolver#acquireContentProviderClient or android.content.ContentResolver#acquireUnstableContentProviderClient. 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 and #openFile 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

Public methods
open Array<ContentProviderResult!>

See android.

open Array<ContentProviderResult!>

See android.

open Int
bulkInsert(url: Uri, initialValues: Array<ContentValues!>)

See ContentProvider.bulkInsert

open Bundle?
call(method: String, arg: String?, extras: Bundle?)

See ContentProvider.call(String, String, Bundle)

open Bundle?
call(authority: String, method: String, arg: String?, extras: Bundle?)

See ContentProvider.call(String, String, Bundle)

Uri?

See ContentProvider.canonicalize

open Unit

Closes this client connection, indicating to the system that the underlying ContentProvider is no longer needed.

open Int
delete(url: Uri, extras: Bundle?)

See android.

open Int
delete(url: Uri, selection: String?, selectionArgs: Array<String!>?)

See android.

open ContentProvider?

Get a reference to the ContentProvider that is associated with this client.

open Array<String!>?
getStreamTypes(url: Uri, mimeTypeFilter: String)

See ContentProvider.getStreamTypes

open String?
getType(url: Uri)

See ContentProvider.getType

open Uri?
insert(url: Uri, initialValues: ContentValues?)

See android.

open Uri?
insert(url: Uri, initialValues: ContentValues?, extras: Bundle?)

See android.

open AssetFileDescriptor?
openAssetFile(url: Uri, mode: String)

See android.

open AssetFileDescriptor?
openAssetFile(url: Uri, mode: String, signal: CancellationSignal?)

See android.

open ParcelFileDescriptor?
openFile(url: Uri, mode: String)

See android.

open ParcelFileDescriptor?
openFile(url: Uri, mode: String, signal: CancellationSignal?)

See android.

AssetFileDescriptor?
openTypedAssetFile(uri: Uri, mimeTypeFilter: String, opts: Bundle?, signal: CancellationSignal?)

AssetFileDescriptor?
openTypedAssetFileDescriptor(uri: Uri, mimeType: String, opts: Bundle?)

See android.

AssetFileDescriptor?
openTypedAssetFileDescriptor(uri: Uri, mimeType: String, opts: Bundle?, signal: CancellationSignal?)

See android.

open Cursor?
query(uri: Uri, projection: Array<String!>?, queryArgs: Bundle!, cancellationSignal: CancellationSignal?)

See android.

open Cursor?
query(url: Uri, projection: Array<String!>?, selection: String?, selectionArgs: Array<String!>?, sortOrder: String?)

See android.

open Cursor?
query(uri: Uri, projection: Array<String!>?, selection: String?, selectionArgs: Array<String!>?, sortOrder: String?, cancellationSignal: CancellationSignal?)

See android.

open Boolean
refresh(url: Uri!, extras: Bundle?, cancellationSignal: CancellationSignal?)

See ContentProvider.refresh

open Boolean

Uri?

See ContentProvider.uncanonicalize

open Int
update(url: Uri, values: ContentValues?, extras: Bundle?)

See android.

open Int
update(url: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<String!>?)

See android.

Protected methods
open Unit

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

Public methods

applyBatch

Added in API level 29
open fun applyBatch(
    authority: String,
    operations: ArrayList<ContentProviderOperation!>
): Array<ContentProviderResult!>

See android.content.ContentProvider#applyBatch

Parameters
authority String: This value cannot be null.
operations ArrayList<ContentProviderOperation!>: This value cannot be null.
Return
Array<ContentProviderResult!> This value cannot be null.

applyBatch

Added in API level 5
open fun applyBatch(operations: ArrayList<ContentProviderOperation!>): Array<ContentProviderResult!>

See android.content.ContentProvider#applyBatch

Parameters
operations ArrayList<ContentProviderOperation!>: This value cannot be null.
Return
Array<ContentProviderResult!> This value cannot be null.

bulkInsert

Added in API level 5
open fun bulkInsert(
    url: Uri,
    initialValues: Array<ContentValues!>
): Int

See ContentProvider.bulkInsert

Parameters
url Uri: This value cannot be null.
initialValues Array<ContentValues!>: This value cannot be null.

call

Added in API level 17
open fun call(
    method: String,
    arg: String?,
    extras: Bundle?
): Bundle?

See ContentProvider.call(String, String, Bundle)

Parameters
method String: This value cannot be null.
arg String?: This value may be null.
extras Bundle?: This value may be null.
Return
Bundle? This value may be null.

call

Added in API level 29
open fun call(
    authority: String,
    method: String,
    arg: String?,
    extras: Bundle?
): Bundle?

See ContentProvider.call(String, String, Bundle)

Parameters
authority String: This value cannot be null.
method String: This value cannot be null.
arg String?: This value may be null.
extras Bundle?: This value may be null.
Return
Bundle? This value may be null.

canonicalize

Added in API level 19
fun canonicalize(url: Uri): Uri?

See ContentProvider.canonicalize

Parameters
url Uri: This value cannot be null.
Return
Uri? This value may be null.

close

Added in API level 24
open fun close(): Unit

Closes this client connection, indicating to the system that the underlying ContentProvider is no longer needed.

Exceptions
java.lang.Exception if this resource cannot be closed

delete

Added in API level 30
open fun delete(
    url: Uri,
    extras: Bundle?
): Int

See android.content.ContentProvider#delete

Parameters
url Uri: This value cannot be null.
extras Bundle?: This value may be null.

delete

Added in API level 5
open fun delete(
    url: Uri,
    selection: String?,
    selectionArgs: Array<String!>?
): Int

See android.content.ContentProvider#delete

Parameters
url Uri: This value cannot be null.
selection String?: This value may be null.
selectionArgs Array<String!>?: This value may be null.

getLocalContentProvider

Added in API level 5
open fun getLocalContentProvider(): ContentProvider?

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.

Return
ContentProvider? If the associated ContentProvider is local, returns it. Otherwise returns null.

getStreamTypes

Added in API level 11
open fun getStreamTypes(
    url: Uri,
    mimeTypeFilter: String
): Array<String!>?

See ContentProvider.getStreamTypes

Parameters
url Uri: This value cannot be null.
mimeTypeFilter String: This value cannot be null.
Return
Array<String!>? This value may be null.

getType

Added in API level 5
open fun getType(url: Uri): String?

See ContentProvider.getType

Parameters
url Uri: This value cannot be null.
Return
String? This value may be null.

insert

Added in API level 5
open fun insert(
    url: Uri,
    initialValues: ContentValues?
): Uri?

See android.content.ContentProvider#insert

Parameters
url Uri: This value cannot be null.
initialValues ContentValues?: This value may be null.
Return
Uri? This value may be null.

insert

Added in API level 30
open fun insert(
    url: Uri,
    initialValues: ContentValues?,
    extras: Bundle?
): Uri?

See android.content.ContentProvider#insert

Parameters
url Uri: This value cannot be null.
initialValues ContentValues?: This value may be null.
extras Bundle?: This value may be null.
Return
Uri? This value may be null.

openAssetFile

Added in API level 5
open fun openAssetFile(
    url: Uri,
    mode: String
): AssetFileDescriptor?

See android.content.ContentProvider#openAssetFile. Note that this does not take care of non-content: URIs such as file:. It is strongly recommended you use the android.content.ContentResolver#openAssetFileDescriptor API instead.

Parameters
url Uri: This value cannot be null.
mode String: This value cannot be null.
Return
AssetFileDescriptor? This value may be null.

openAssetFile

Added in API level 19
open fun openAssetFile(
    url: Uri,
    mode: String,
    signal: CancellationSignal?
): AssetFileDescriptor?

See android.content.ContentProvider#openAssetFile. Note that this does not take care of non-content: URIs such as file:. It is strongly recommended you use the android.content.ContentResolver#openAssetFileDescriptor API instead.

Parameters
url Uri: This value cannot be null.
mode String: This value cannot be null.
signal CancellationSignal?: This value may be null.
Return
AssetFileDescriptor? This value may be null.

openFile

Added in API level 5
open fun openFile(
    url: Uri,
    mode: String
): ParcelFileDescriptor?

See android.content.ContentProvider#openFile. Note that this does not take care of non-content: URIs such as file:. It is strongly recommended you use the android.content.ContentResolver#openFileDescriptor API instead.

Parameters
url Uri: This value cannot be null.
mode String: This value cannot be null.
Return
ParcelFileDescriptor? This value may be null.

openFile

Added in API level 19
open fun openFile(
    url: Uri,
    mode: String,
    signal: CancellationSignal?
): ParcelFileDescriptor?

See android.content.ContentProvider#openFile. Note that this does not take care of non-content: URIs such as file:. It is strongly recommended you use the android.content.ContentResolver#openFileDescriptor API instead.

Parameters
url Uri: This value cannot be null.
mode String: This value cannot be null.
signal CancellationSignal?: This value may be null.
Return
ParcelFileDescriptor? This value may be null.

openTypedAssetFile

Added in API level 29
fun openTypedAssetFile(
    uri: Uri,
    mimeTypeFilter: String,
    opts: Bundle?,
    signal: CancellationSignal?
): AssetFileDescriptor?
Parameters
uri Uri: This value cannot be null.
mimeTypeFilter String: This value cannot be null.
opts Bundle?: This value may be null.
signal CancellationSignal?: This value may be null.
Return
AssetFileDescriptor? This value may be null.

openTypedAssetFileDescriptor

Added in API level 11
fun openTypedAssetFileDescriptor(
    uri: Uri,
    mimeType: String,
    opts: Bundle?
): AssetFileDescriptor?

See android.content.ContentProvider#openTypedAssetFile

Parameters
uri Uri: This value cannot be null.
mimeType String: This value cannot be null.
opts Bundle?: This value may be null.
Return
AssetFileDescriptor? This value may be null.

openTypedAssetFileDescriptor

Added in API level 19
fun openTypedAssetFileDescriptor(
    uri: Uri,
    mimeType: String,
    opts: Bundle?,
    signal: CancellationSignal?
): AssetFileDescriptor?

See android.content.ContentProvider#openTypedAssetFile

Parameters
uri Uri: This value cannot be null.
mimeType String: This value cannot be null.
opts Bundle?: This value may be null.
signal CancellationSignal?: This value may be null.
Return
AssetFileDescriptor? This value may be null.

query

Added in API level 26
open fun query(
    uri: Uri,
    projection: Array<String!>?,
    queryArgs: Bundle!,
    cancellationSignal: CancellationSignal?
): Cursor?

See android.content.ContentProvider#query

Parameters
uri Uri: This value cannot be null.
projection Array<String!>?: This value may be null.
cancellationSignal CancellationSignal?: This value may be null.
Return
Cursor? This value may be null.

query

Added in API level 5
open fun query(
    url: Uri,
    projection: Array<String!>?,
    selection: String?,
    selectionArgs: Array<String!>?,
    sortOrder: String?
): Cursor?

See android.content.ContentProvider#query

Parameters
url Uri: This value cannot be null.
projection Array<String!>?: This value may be null.
selection String?: This value may be null.
selectionArgs Array<String!>?: This value may be null.
sortOrder String?: This value may be null.
Return
Cursor? This value may be null.

query

Added in API level 16
open fun query(
    uri: Uri,
    projection: Array<String!>?,
    selection: String?,
    selectionArgs: Array<String!>?,
    sortOrder: String?,
    cancellationSignal: CancellationSignal?
): Cursor?

See android.content.ContentProvider#query

Parameters
uri Uri: This value cannot be null.
projection Array<String!>?: This value may be null.
selection String?: This value may be null.
selectionArgs Array<String!>?: This value may be null.
sortOrder String?: This value may be null.
cancellationSignal CancellationSignal?: This value may be null.
Return
Cursor? This value may be null.

refresh

Added in API level 26
open fun refresh(
    url: Uri!,
    extras: Bundle?,
    cancellationSignal: CancellationSignal?
): Boolean

See ContentProvider.refresh

Parameters
extras Bundle?: This value may be null.
cancellationSignal CancellationSignal?: This value may be null.

release

Added in API level 5
Deprecated in API level 24
open fun release(): Boolean

Deprecated: replaced by close().

uncanonicalize

Added in API level 19
fun uncanonicalize(url: Uri): Uri?

See ContentProvider.uncanonicalize

Parameters
url Uri: This value cannot be null.
Return
Uri? This value may be null.

update

Added in API level 30
open fun update(
    url: Uri,
    values: ContentValues?,
    extras: Bundle?
): Int

See android.content.ContentProvider#update

Parameters
url Uri: This value cannot be null.
values ContentValues?: This value may be null.
extras Bundle?: This value may be null.

update

Added in API level 5
open fun update(
    url: Uri,
    values: ContentValues?,
    selection: String?,
    selectionArgs: Array<String!>?
): Int

See android.content.ContentProvider#update

Parameters
url Uri: This value cannot be null.
values ContentValues?: This value may be null.
selection String?: This value may be null.
selectionArgs Array<String!>?: This value may be null.

Protected methods

finalize

Added in API level 5
protected open fun finalize(): Unit

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.

Exceptions
java.lang.Throwable the Exception raised by this method