Added in API level 19

DocumentsProvider


abstract class DocumentsProvider : ContentProvider

Base class for a document provider. A document provider offers read and write access to durable files, such as files stored on a local disk, or files in a cloud storage service. To create a document provider, extend this class, implement the abstract methods, and add it to your manifest like this:

<manifest>
     ...
     <application>
         ...
         <provider
             android:name="com.example.MyCloudProvider"
             android:authorities="com.example.mycloudprovider"
             android:exported="true"
             android:grantUriPermissions="true"
             android:permission="android.permission.MANAGE_DOCUMENTS"
             android:enabled="@bool/isAtLeastKitKat">
             <intent-filter>
                 <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
             </intent-filter>
         </provider>
         ...
     </application>
 </manifest>

When defining your provider, you must protect it with android.Manifest.permission#MANAGE_DOCUMENTS, which is a permission only the system can obtain. Applications cannot use a documents provider directly; they must go through Intent.ACTION_OPEN_DOCUMENT or Intent.ACTION_CREATE_DOCUMENT which requires a user to actively navigate and select documents. When a user selects documents through that UI, the system issues narrow URI permission grants to the requesting application.

Documents

A document can be either an openable stream (with a specific MIME type), or a directory containing additional documents (with the Document.MIME_TYPE_DIR MIME type). Each directory represents the top of a subtree containing zero or more documents, which can recursively contain even more documents and directories.

Each document can have different capabilities, as described by Document.COLUMN_FLAGS. For example, if a document can be represented as a thumbnail, your provider can set Document.FLAG_SUPPORTS_THUMBNAIL and implement openDocumentThumbnail(java.lang.String,android.graphics.Point,android.os.CancellationSignal) to return that thumbnail.

Each document under a provider is uniquely referenced by its Document.COLUMN_DOCUMENT_ID, which must not change once returned. A single document can be included in multiple directories when responding to queryChildDocuments(java.lang.String,java.lang.String[],java.lang.String). For example, a provider might surface a single photo in multiple locations: once in a directory of geographic locations, and again in a directory of dates.

Roots

All documents are surfaced through one or more "roots." Each root represents the top of a document tree that a user can navigate. For example, a root could represent an account or a physical storage device. Similar to documents, each root can have capabilities expressed through Root.COLUMN_FLAGS.

Summary

Inherited constants
Int TRIM_MEMORY_BACKGROUND

Level for onTrimMemory(int): the process has gone on to the LRU list. This is a good opportunity to clean up resources that can efficiently and quickly be re-built if the user returns to the app.

Int TRIM_MEMORY_COMPLETE

Level for onTrimMemory(int): the process is nearing the end of the background LRU list, and if more memory isn't found soon it will be killed.

Int TRIM_MEMORY_MODERATE

Level for onTrimMemory(int): the process is around the middle of the background LRU list; freeing memory can help the system keep other processes running later in the list for better overall performance.

Int TRIM_MEMORY_RUNNING_CRITICAL

Level for onTrimMemory(int): the process is not an expendable background process, but the device is running extremely low on memory and is about to not be able to keep any background processes running. Your running process should free up as many non-critical resources as it can to allow that memory to be used elsewhere. The next thing that will happen after this is onLowMemory() called to report that nothing at all can be kept in the background, a situation that can start to notably impact the user.

Int TRIM_MEMORY_RUNNING_LOW

Level for onTrimMemory(int): the process is not an expendable background process, but the device is running low on memory. Your running process should free up unneeded resources to allow that memory to be used elsewhere.

Int TRIM_MEMORY_RUNNING_MODERATE

Level for onTrimMemory(int): the process is not an expendable background process, but the device is running moderately low on memory. Your running process may want to release some unneeded resources for use elsewhere.

Int TRIM_MEMORY_UI_HIDDEN

Level for onTrimMemory(int): the process had been showing a user interface, and is no longer doing so. Large allocations with the UI should be released at this point to allow memory to be better managed.

Public constructors

Public methods
open Unit
attachInfo(context: Context!, info: ProviderInfo!)

Implementation is provided by the parent class.

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

Implementation is provided by the parent class.

open Uri?

Implementation is provided by the parent class.

open String!
copyDocument(sourceDocumentId: String!, targetParentDocumentId: String!)

Copy the requested document or a document tree.

open String!
createDocument(parentDocumentId: String!, mimeType: String!, displayName: String!)

Create a new document and return its newly generated Document.COLUMN_DOCUMENT_ID.

open IntentSender!
createWebLinkIntent(documentId: String!, options: Bundle?)

Creates an intent sender for a web link, if the document is web linkable.

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

Implementation is provided by the parent class.

open Unit
deleteDocument(documentId: String!)

Delete the requested document.

open Unit
ejectRoot(rootId: String!)

Ejects the root.

open DocumentsContract.Path!
findDocumentPath(parentDocumentId: String?, childDocumentId: String!)

Finds the canonical path for the requested document.

open Bundle?

Returns metadata associated with the document.

open Array<String!>!
getDocumentStreamTypes(documentId: String!, mimeTypeFilter: String!)

Return a list of streamable MIME types matching the filter, which can be passed to openTypedDocument(java.lang.String,java.lang.String,android.os.Bundle,android.os.CancellationSignal).

open String!
getDocumentType(documentId: String!)

Return concrete MIME type of the requested document.

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

Called by a client to determine the types of data streams that this content provider support for the given URI.

String?
getType(uri: Uri)

Implementation is provided by the parent class.

String?

An unrestricted version of getType, which does not reveal sensitive information

Uri?
insert(uri: Uri, values: ContentValues?)

Implementation is provided by the parent class.

open Boolean
isChildDocument(parentDocumentId: String!, documentId: String!)

Test if a document is descendant (child, grandchild, etc) from the given parent.

open String!
moveDocument(sourceDocumentId: String!, sourceParentDocumentId: String!, targetParentDocumentId: String!)

Move the requested document or a document tree.

AssetFileDescriptor?
openAssetFile(uri: Uri, mode: String)

Implementation is provided by the parent class.

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

Implementation is provided by the parent class.

abstract ParcelFileDescriptor!
openDocument(documentId: String!, mode: String!, signal: CancellationSignal?)

Open and return the requested document.

open AssetFileDescriptor!
openDocumentThumbnail(documentId: String!, sizeHint: Point!, signal: CancellationSignal!)

Open and return a thumbnail of the requested document.

ParcelFileDescriptor?
openFile(uri: Uri, mode: String)

Implementation is provided by the parent class.

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

Implementation is provided by the parent class.

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

Implementation is provided by the parent class.

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

Implementation is provided by the parent class.

open AssetFileDescriptor!
openTypedDocument(documentId: String!, mimeTypeFilter: String!, opts: Bundle!, signal: CancellationSignal!)

Open and return the document in a format matching the specified MIME type filter.

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

Implementation is provided by the parent class.

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

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

WARNING: Sub-classes should not override this method.

open Cursor!
queryChildDocuments(parentDocumentId: String!, projection: Array<String!>?, queryArgs: Bundle?)

Override this method to return the children documents contained in the requested directory.

abstract Cursor!
queryChildDocuments(parentDocumentId: String!, projection: Array<String!>!, sortOrder: String!)

Return the children documents contained in the requested directory.

abstract Cursor!
queryDocument(documentId: String!, projection: Array<String!>!)

Return metadata for the single requested document.

open Cursor!
queryRecentDocuments(rootId: String!, projection: Array<String!>!)

Return recently modified documents under the requested root.

open Cursor?
queryRecentDocuments(rootId: String, projection: Array<String!>?, queryArgs: Bundle?, signal: CancellationSignal?)

Return recently modified documents under the requested root.

abstract Cursor!
queryRoots(projection: Array<String!>!)

Return all roots currently provided.

open Cursor!
querySearchDocuments(rootId: String!, query: String!, projection: Array<String!>!)

Return documents that match the given query under the requested root.

open Cursor?
querySearchDocuments(rootId: String, projection: Array<String!>?, queryArgs: Bundle)

Return documents that match the given query under the requested root.

open Unit
removeDocument(documentId: String!, parentDocumentId: String!)

Removes the requested document or a document tree.

open String!
renameDocument(documentId: String!, displayName: String!)

Rename an existing document.

Unit

Revoke any active permission grants for the given Document.COLUMN_DOCUMENT_ID, usually called when a document becomes invalid.

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

Implementation is provided by the parent class.

Inherited functions
Array<ContentProviderResult!> applyBatch(authority: String, operations: ArrayList<ContentProviderOperation!>)

Override this to handle requests to perform a batch of operations, or the default implementation will iterate over the operations and call ContentProviderOperation.apply on each of them. If all calls to ContentProviderOperation.apply succeed then a ContentProviderResult array with as many elements as there were operations will be returned. If any of the calls fail, it is up to the implementation how many of the others take effect. This method can be called from multiple threads, as described in Processes and Threads.

Array<ContentProviderResult!> applyBatch(operations: ArrayList<ContentProviderOperation!>)

Int bulkInsert(uri: Uri, values: Array<ContentValues!>)

Override this to handle requests to insert a set of new rows, or the default implementation will iterate over the values and call #insert on each of them. As a courtesy, call notifyChange() after inserting. This method can be called from multiple threads, as described in Processes and Threads.

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

Call a provider-defined method. This can be used to implement interfaces that are cheaper and/or unnatural for a table-like model.

WARNING: The framework does no permission checking on this entry into the content provider besides the basic ability for the application to get access to the provider at all. For example, it has no idea whether the call being executed may read or write data in the provider, so can't enforce those individual permissions. Any implementation of this method must do its own permission checks on incoming calls to make sure they are allowed.

ContentProvider.CallingIdentity clearCallingIdentity()

Reset the identity of the incoming IPC on the current thread.

Internally this calls Binder.clearCallingIdentity() and also clears any value stored in getCallingPackage().

Int delete(uri: Uri, extras: Bundle?)

Implement this to handle requests to delete one or more rows. The implementation should apply the selection clause when performing deletion, allowing the operation to affect multiple rows in a directory. As a courtesy, call notifyChange() after deleting. This method can be called from multiple threads, as described in Processes and Threads.

The implementation is responsible for parsing out a row ID at the end of the URI, if a specific row is being deleted. That is, the client would pass in content://contacts/people/22 and the implementation is responsible for parsing the record number (22) when creating a SQL statement.

Unit dump(fd: FileDescriptor!, writer: PrintWriter!, args: Array<String!>!)

Print the Provider's state into the given stream. This gets invoked if you run "adb shell dumpsys activity provider <provider_component_name>".

AttributionSource? getCallingAttributionSource()

Gets the attribution source of the calling app. If you want to attribute the data access to the calling app you can create an attribution context via android.content.Context#createContext(ContextParams) and passing this identity to ContextParams.Builder.setNextAttributionSource(.

String? getCallingAttributionTag()

Return the attribution tag of the caller that initiated the request being processed on the current thread. Returns null if not currently processing a request of the request is for the default attribution.

This will always return null when processing getTypeAnonymous(android.net.Uri) requests For getType(android.net.Uri) requests, this will be only available for cases, where the caller can be identified. See getTypeAnonymous(android.net.Uri)

String? getCallingPackage()

Return the package name of the caller that initiated the request being processed on the current thread. The returned package will have been verified to belong to the calling UID. Returns null if not currently processing a request.

This will always return null when processing getTypeAnonymous(android.net.Uri) requests For getType(android.net.Uri) requests, this will be only available for cases, where the caller can be identified. See getTypeAnonymous(android.net.Uri)

String? getCallingPackageUnchecked()

Return the package name of the caller that initiated the request being processed on the current thread. The returned package will have not been verified to belong to the calling UID. Returns null if not currently processing a request.

This will always return null when processing getTypeAnonymous(android.net.Uri) requests For getType(android.net.Uri) requests, this will be only available for cases, where the caller can be identified. See getTypeAnonymous(android.net.Uri)

Context? getContext()

Retrieves the Context this provider is running in. Only available once onCreate has been called -- this will return null in the constructor.

Array<PathPermission!>? getPathPermissions()

Return the path-based permissions required for read and/or write access to this content provider. This method can be called from multiple threads, as described in Processes and Threads.

String? getReadPermission()

Return the name of the permission required for read-only access to this content provider. This method can be called from multiple threads, as described in Processes and Threads.

String? getWritePermission()

Return the name of the permission required for read/write access to this content provider. This method can be called from multiple threads, as described in Processes and Threads.

Uri? insert(uri: Uri, values: ContentValues?, extras: Bundle?)

Implement this to handle requests to insert a new row. As a courtesy, call notifyChange() after inserting. This method can be called from multiple threads, as described in Processes and Threads.

Boolean isTemporary()

Returns true if this instance is a temporary content provider.

Unit onCallingPackageChanged()

Called whenever the value of getCallingPackage() changes, giving the provider an opportunity to invalidate any security related caching it may be performing.

This typically happens when a ContentProvider makes a nested call back into itself when already processing a call from a remote process.

Unit onConfigurationChanged(newConfig: Configuration)

Called by the system when the device configuration changes while your component is running. Note that, unlike activities, other components are never restarted when a configuration changes: they must always deal with the results of the change, such as by re-retrieving resources.

At the time that this function has been called, your Resources object will have been updated to return resource values matching the new configuration.

For more information, read Handling Runtime Changes. This method is always called on the application main thread, and must not perform lengthy operations.

The default content provider implementation does nothing. Override this method to take appropriate action. (Content providers do not usually care about things like screen orientation, but may want to know about locale changes.)

Boolean onCreate()

Implement this to initialize your content provider on startup. This method is called for all registered content providers on the application main thread at application launch time. It must not perform lengthy operations, or application startup will be delayed.

You should defer nontrivial initialization (such as opening, upgrading, and scanning databases) until the content provider is used (via #query, #insert, etc). Deferred initialization keeps application startup fast, avoids unnecessary work if the provider turns out not to be needed, and stops database errors (such as a full disk) from halting application launch.

If you use SQLite, android.database.sqlite.SQLiteOpenHelper is a helpful utility class that makes it easy to manage databases, and will automatically defer opening until first use. If you do use SQLiteOpenHelper, make sure to avoid calling android.database.sqlite.SQLiteOpenHelper#getReadableDatabase or android.database.sqlite.SQLiteOpenHelper#getWritableDatabase from this method. (Instead, override android.database.sqlite.SQLiteOpenHelper#onOpen to initialize the database when it is first opened.)

Unit onLowMemory()

This is called when the overall system is running low on memory, and actively running processes should trim their memory usage. While the exact point at which this will be called is not defined, generally it will happen when all background process have been killed. That is, before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing. This method is always called on the application main thread, and must not perform lengthy operations.

The default content provider implementation does nothing. Subclasses may override this method to take appropriate action.

Unit onTrimMemory(level: Int)

ParcelFileDescriptor openFileHelper(uri: Uri, mode: String)

Convenience for subclasses that wish to implement #openFile by looking up a column named "_data" at the given URI.

ParcelFileDescriptor openPipeHelper(uri: Uri, mimeType: String, opts: Bundle?, args: T?, func: ContentProvider.PipeDataWriter<T>)

A helper function for implementing #openTypedAssetFile, for creating a data pipe and background thread allowing you to stream generated data back to the client. This function returns a new ParcelFileDescriptor that should be returned to the caller (the caller is responsible for closing it).

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

Implement this to support refresh of content identified by uri. By default, this method returns false; providers who wish to implement this should return true to signal the client that the provider has tried refreshing with its own implementation.

This allows clients to request an explicit refresh of content identified by uri.

Client code should only invoke this method when there is a strong indication (such as a user initiated pull to refresh gesture) that the content is stale.

Remember to send ContentResolver.notifyChange(Uri, android.database.ContentObserver) notifications when content changes.

Context requireContext()

Retrieves a Non-Nullable Context this provider is running in, this is intended to be called after onCreate. When called before context was created, an IllegalStateException will be thrown.

Note A provider must be declared in the manifest and created automatically by the system, and context is only available after onCreate is called.

Unit restoreCallingIdentity(identity: ContentProvider.CallingIdentity)

Restore the identity of the incoming IPC on the current thread back to a previously identity that was returned by clearCallingIdentity.

Internally this calls Binder.restoreCallingIdentity(long) and also restores any value stored in getCallingPackage().

Unit setPathPermissions(permissions: Array<PathPermission!>?)

Change the path-based permission required to read and/or write data in the content provider. This is normally set for you from its manifest information when the provider is first created.

Unit setReadPermission(permission: String?)

Change the permission required to read data from the content provider. This is normally set for you from its manifest information when the provider is first created.

Unit setWritePermission(permission: String?)

Change the permission required to read and write data in the content provider. This is normally set for you from its manifest information when the provider is first created.

Unit shutdown()

Implement this to shut down the ContentProvider instance. You can then invoke this method in unit tests.

Android normally handles ContentProvider startup and shutdown automatically. You do not need to start up or shut down a ContentProvider. When you invoke a test method on a ContentProvider, however, a ContentProvider instance is started and keeps running after the test finishes, even if a succeeding test instantiates another ContentProvider. A conflict develops because the two instances are usually running against the same underlying data source (for example, an sqlite database).

Implementing shutDown() avoids this conflict by providing a way to terminate the ContentProvider. This method can also prevent memory leaks from multiple instantiations of the ContentProvider, and it can ensure unit test isolation by allowing you to completely clean up the test fixture before moving on to the next test.

Uri? uncanonicalize(url: Uri)

Remove canonicalization from canonical URIs previously returned by canonicalize. For example, if your implementation is to add a query param to canonicalize a URI, this method can simply trip any query params on the URI. The default implementation always returns the same url that was passed in.

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

Implement this to handle requests to update one or more rows. The implementation should update all rows matching the selection to set the columns according to the provided values map. As a courtesy, call notifyChange() after updating. This method can be called from multiple threads, as described in Processes and Threads.

Unit onConfigurationChanged(newConfig: Configuration)

Called by the system when the device configuration changes while your component is running. Note that, unlike activities, other components are never restarted when a configuration changes: they must always deal with the results of the change, such as by re-retrieving resources.

At the time that this function has been called, your Resources object will have been updated to return resource values matching the new configuration.

For more information, read Handling Runtime Changes.

Unit onLowMemory()

This is called when the overall system is running low on memory, and actively running processes should trim their memory usage. While the exact point at which this will be called is not defined, generally it will happen when all background process have been killed. That is, before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

Public constructors

DocumentsProvider

DocumentsProvider()

Public methods

attachInfo

Added in API level 19
open fun attachInfo(
    context: Context!,
    info: ProviderInfo!
): Unit

Implementation is provided by the parent class.

Parameters
context Context!: The context this provider is running in
info ProviderInfo!: Registered information about this content provider

call

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

Implementation is provided by the parent class. Can be overridden to provide additional functionality, but subclasses must always call the superclass. If the superclass returns null, the subclass may implement custom behavior.
If you override this method you must call through to the superclass implementation.

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.

canonicalize

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

Implementation is provided by the parent class. Can be overridden to provide additional functionality, but subclasses must always call the superclass. If the superclass returns null, the subclass may implement custom behavior.

This is typically used to resolve a subtree URI into a concrete document reference, issuing a narrower single-document URI permission grant along the way.
If you override this method you must call through to the superclass implementation.

Parameters
url The Uri to canonicalize. This value cannot be null.
Return
Uri? Return the canonical representation of url, or null if canonicalization of that Uri is not supported.

copyDocument

Added in API level 24
open fun copyDocument(
    sourceDocumentId: String!,
    targetParentDocumentId: String!
): String!

Copy the requested document or a document tree.

Copies a document including all child documents to another location within the same document provider. Upon completion returns the document id of the copied document at the target destination. null must never be returned.

Parameters
sourceDocumentId String!: the document to copy.
targetParentDocumentId String!: the target document to be copied into as a child.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

createDocument

Added in API level 19
open fun createDocument(
    parentDocumentId: String!,
    mimeType: String!,
    displayName: String!
): String!

Create a new document and return its newly generated Document.COLUMN_DOCUMENT_ID. You must allocate a new Document.COLUMN_DOCUMENT_ID to represent the document, which must not change once returned.

Parameters
parentDocumentId String!: the parent directory to create the new document under.
mimeType String!: the concrete MIME type associated with the new document. If the MIME type is not supported, the provider must throw.
displayName String!: the display name of the new document. The provider may alter this name to meet any internal constraints, such as avoiding conflicting names.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

createWebLinkIntent

Added in API level 26
open fun createWebLinkIntent(
    documentId: String!,
    options: Bundle?
): IntentSender!

Creates an intent sender for a web link, if the document is web linkable.

AuthenticationRequiredException can be thrown if user does not have sufficient permission for the linked document. Before any new permissions are granted for the linked document, a visible UI must be shown, so the user can explicitly confirm whether the permission grants are expected. The user must be able to cancel the operation.

Options passed as an argument may include a list of recipients, such as email addresses. The provider should reflect these options if possible, but it's acceptable to ignore them. In either case, confirmation UI must be shown before any new permission grants are granted.

It is all right to generate a web link without granting new permissions, if opening the link would result in a page for requesting permission access. If it's impossible then the operation must fail by throwing an exception.

Parameters
documentId String!: the document to create a web link intent for.
options Bundle?: additional information, such as list of recipients. Optional. This value may be null.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

delete

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

Implementation is provided by the parent class. Throws by default, and cannot be overridden.

Parameters
uri Uri: The full URI to query, including a row ID (if a specific record is requested). This value cannot be null.
selection String?: An optional restriction to apply to rows when deleting. This value may be null.
selectionArgs Array<String!>?: This value may be null.
Return
Int The number of rows affected.
Exceptions
android.database.SQLException

deleteDocument

Added in API level 19
open fun deleteDocument(documentId: String!): Unit

Delete the requested document.

Upon returning, any URI permission grants for the given document will be revoked. If additional documents were deleted as a side effect of this call (such as documents inside a directory) the implementor is responsible for revoking those permissions using revokeDocumentPermission(java.lang.String).

Parameters
documentId String!: the document to delete.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

ejectRoot

Added in API level 26
open fun ejectRoot(rootId: String!): Unit

Ejects the root. Throws IllegalStateException if ejection failed.

Parameters
rootId String!: the root to be ejected.

findDocumentPath

Added in API level 26
open fun findDocumentPath(
    parentDocumentId: String?,
    childDocumentId: String!
): DocumentsContract.Path!

Finds the canonical path for the requested document. The path must start from the parent document if parentDocumentId is not null or the root document if parentDocumentId is null. If there are more than one path to this document, return the most typical one. Include both the parent document or root document and the requested document in the returned path.

This API assumes that document ID has enough info to infer the root. Different roots should use different document ID to refer to the same document.

Parameters
parentDocumentId String?: the document from which the path starts if not null, or null to indicate a path from the root is requested.
childDocumentId String!: the document which path is requested.
Return
DocumentsContract.Path! the path of the requested document. If parentDocumentId is null returned root ID must not be null. If parentDocumentId is not null returned root ID must be null.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

getDocumentMetadata

Added in API level 29
open fun getDocumentMetadata(documentId: String): Bundle?

Returns metadata associated with the document. The type of metadata returned is specific to the document type. For example the data returned for an image file will likely consist primarily or solely of EXIF metadata.

The returned Bundle will contain zero or more entries depending on the type of data supported by the document provider.

  1. A DocumentsContract.METADATA_TYPES containing a String[] value. The string array identifies the type or types of metadata returned. Each value in the can be used to access a Bundle of data containing that type of data.
  2. An entry each for each type of returned metadata. Each set of metadata is itself represented as a bundle and accessible via a string key naming the type of data.
Parameters
documentId String: get the metadata of the document This value cannot be null.
Return
Bundle? a Bundle of Bundles. This value may be null.

getDocumentStreamTypes

Added in API level 24
open fun getDocumentStreamTypes(
    documentId: String!,
    mimeTypeFilter: String!
): Array<String!>!

Return a list of streamable MIME types matching the filter, which can be passed to openTypedDocument(java.lang.String,java.lang.String,android.os.Bundle,android.os.CancellationSignal).

The default implementation returns a MIME type provided by queryDocument(java.lang.String,java.lang.String[]) as long as it matches the filter and the document does not have the Document.FLAG_VIRTUAL_DOCUMENT flag set.

Virtual documents must have at least one streamable format.

getDocumentType

Added in API level 19
open fun getDocumentType(documentId: String!): String!

Return concrete MIME type of the requested document. Must match the value of Document.COLUMN_MIME_TYPE for this document. The default implementation queries queryDocument(java.lang.String,java.lang.String[]), so providers may choose to override this as an optimization.

Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

getStreamTypes

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

Called by a client to determine the types of data streams that this content provider support for the given URI.

Overriding this method is deprecated. Override openTypedDocument instead.

Parameters
uri Uri: The data in the content provider being queried. This value cannot be null.
mimeTypeFilter String: The type of data the client desires. May be a pattern, such as */* to retrieve all possible data types. This value cannot be null.
Return
Array<String!>? Returns null if there are no possible data streams for the given mimeTypeFilter. Otherwise returns an array of all available concrete MIME types.

getType

Added in API level 19
fun getType(uri: Uri): String?

Implementation is provided by the parent class. Cannot be overridden.

Parameters
uri Uri: the URI to query. This value cannot be null.
Return
String? a MIME type string, or null if there is no type.

getTypeAnonymous

Added in API level 34
fun getTypeAnonymous(uri: Uri): String?

An unrestricted version of getType, which does not reveal sensitive information

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

insert

Added in API level 19
fun insert(
    uri: Uri,
    values: ContentValues?
): Uri?

Implementation is provided by the parent class. Throws by default, and cannot be overridden.

Parameters
uri Uri: The content:// URI of the insertion request. This value cannot be null.
values ContentValues?: A set of column_name/value pairs to add to the database. This value may be null.
Return
Uri? The URI for the newly inserted item. This value may be null.

isChildDocument

Added in API level 21
open fun isChildDocument(
    parentDocumentId: String!,
    documentId: String!
): Boolean

Test if a document is descendant (child, grandchild, etc) from the given parent. For example, providers must implement this to support Intent.ACTION_OPEN_DOCUMENT_TREE. You should avoid making network requests to keep this request fast.

Parameters
parentDocumentId String!: parent to verify against.
documentId String!: child to verify.
Return
Boolean if given document is a descendant of the given parent.

moveDocument

Added in API level 24
open fun moveDocument(
    sourceDocumentId: String!,
    sourceParentDocumentId: String!,
    targetParentDocumentId: String!
): String!

Move the requested document or a document tree.

Moves a document including all child documents to another location within the same document provider. Upon completion returns the document id of the copied document at the target destination. null must never be returned.

It's the responsibility of the provider to revoke grants if the document is no longer accessible using sourceDocumentId.

Parameters
sourceDocumentId String!: the document to move.
sourceParentDocumentId String!: the parent of the document to move.
targetParentDocumentId String!: the target document to be a new parent of the source document.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

openAssetFile

Added in API level 19
fun openAssetFile(
    uri: Uri,
    mode: String
): AssetFileDescriptor?

Implementation is provided by the parent class. Cannot be overridden.

Parameters
uri Uri: The URI whose file is to be opened. This value cannot be null.
mode String: The string representation of the file mode. Can be "r", "w", "wt", "wa", "rw" or "rwt". Please note the exact implementation of these may differ for each Provider implementation - for example, "w" may or may not truncate. This value cannot be null.
Return
AssetFileDescriptor? Returns a new AssetFileDescriptor which you can use to access the file. This value may be null.
Exceptions
java.io.FileNotFoundException Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid.
java.lang.SecurityException Throws SecurityException if the caller does not have permission to access the file.

openAssetFile

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

Implementation is provided by the parent class. Cannot be overridden.

Parameters
uri Uri: The URI whose file is to be opened. This value cannot be null.
mode String: The string representation of the file mode. Can be "r", "w", "wt", "wa", "rw" or "rwt". Please note the exact implementation of these may differ for each Provider implementation - for example, "w" may or may not truncate. This value cannot be null.
signal CancellationSignal?: A signal to cancel the operation in progress, or null if none. For example, if you are downloading a file from the network to service a "rw" mode request, you should periodically call CancellationSignal.throwIfCanceled() to check whether the client has canceled the request and abort the download.
Return
AssetFileDescriptor? Returns a new AssetFileDescriptor which you can use to access the file. This value may be null.
Exceptions
java.io.FileNotFoundException Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid.
java.lang.SecurityException Throws SecurityException if the caller does not have permission to access the file.

openDocument

Added in API level 19
abstract fun openDocument(
    documentId: String!,
    mode: String!,
    signal: CancellationSignal?
): ParcelFileDescriptor!

Open and return the requested document.

Your provider should return a reliable ParcelFileDescriptor to detect when the remote caller has finished reading or writing the document.

Mode "r" should always be supported. Provider should throw UnsupportedOperationException if the passing mode is not supported. You may return a pipe or socket pair if the mode is exclusively "r" or "w", but complex modes like "rw" imply a normal file on disk that supports seeking.

If you block while downloading content, you should periodically check CancellationSignal.isCanceled() to abort abandoned open requests.

Parameters
documentId String!: the document to return.
mode String!: the mode to open with, such as 'r', 'w', or 'rw'.
signal CancellationSignal?: used by the caller to signal if the request should be cancelled. May be null.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

openDocumentThumbnail

Added in API level 19
open fun openDocumentThumbnail(
    documentId: String!,
    sizeHint: Point!,
    signal: CancellationSignal!
): AssetFileDescriptor!

Open and return a thumbnail of the requested document.

A provider should return a thumbnail closely matching the hinted size, attempting to serve from a local cache if possible. A provider should never return images more than double the hinted size.

If you perform expensive operations to download or generate a thumbnail, you should periodically check CancellationSignal.isCanceled() to abort abandoned thumbnail requests.

Parameters
documentId String!: the document to return.
sizeHint Point!: hint of the optimal thumbnail dimensions.
signal CancellationSignal!: used by the caller to signal if the request should be cancelled. May be null.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

openFile

Added in API level 19
fun openFile(
    uri: Uri,
    mode: String
): ParcelFileDescriptor?

Implementation is provided by the parent class. Cannot be overridden.

Parameters
uri Uri: The URI whose file is to be opened. This value cannot be null.
mode String: The string representation of the file mode. Can be "r", "w", "wt", "wa", "rw" or "rwt". Please note the exact implementation of these may differ for each Provider implementation - for example, "w" may or may not truncate. This value cannot be null.
Return
ParcelFileDescriptor? Returns a new ParcelFileDescriptor which you can use to access the file. This value may be null.
Exceptions
java.io.FileNotFoundException Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid.
java.lang.SecurityException Throws SecurityException if the caller does not have permission to access the file.

openFile

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

Implementation is provided by the parent class. Cannot be overridden.

Parameters
uri Uri: The URI whose file is to be opened. This value cannot be null.
mode String: The string representation of the file mode. Can be "r", "w", "wt", "wa", "rw" or "rwt". Please note the exact implementation of these may differ for each Provider implementation - for example, "w" may or may not truncate. This value cannot be null.
signal CancellationSignal?: A signal to cancel the operation in progress, or null if none. For example, if you are downloading a file from the network to service a "rw" mode request, you should periodically call CancellationSignal.throwIfCanceled() to check whether the client has canceled the request and abort the download.
Return
ParcelFileDescriptor? Returns a new ParcelFileDescriptor which you can use to access the file. This value may be null.
Exceptions
java.io.FileNotFoundException Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid.
java.lang.SecurityException Throws SecurityException if the caller does not have permission to access the file.

openTypedAssetFile

Added in API level 19
fun openTypedAssetFile(
    uri: Uri,
    mimeTypeFilter: String,
    opts: Bundle?
): AssetFileDescriptor?

Implementation is provided by the parent class. Cannot be overridden.

Parameters
uri Uri: The data in the content provider being queried. This value cannot be null.
mimeTypeFilter String: The type of data the client desires. May be a pattern, such as */*, if the caller does not have specific type requirements; in this case the content provider will pick its best type matching the pattern. This value cannot be null.
opts Bundle?: Additional options from the client. The definitions of these are specific to the content provider being called. This value may be null.
Return
AssetFileDescriptor? Returns a new AssetFileDescriptor from which the client can read data of the desired type. This value may be null.
Exceptions
java.io.FileNotFoundException Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid.
java.lang.SecurityException Throws SecurityException if the caller does not have permission to access the data.
java.lang.IllegalArgumentException Throws IllegalArgumentException if the content provider does not support the requested MIME type.

openTypedAssetFile

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

Implementation is provided by the parent class. Cannot be overridden.

Parameters
uri Uri: The data in the content provider being queried. This value cannot be null.
mimeTypeFilter String: The type of data the client desires. May be a pattern, such as */*, if the caller does not have specific type requirements; in this case the content provider will pick its best type matching the pattern. This value cannot be null.
opts Bundle?: Additional options from the client. The definitions of these are specific to the content provider being called. This value may be null.
signal CancellationSignal?: A signal to cancel the operation in progress, or null if none. For example, if you are downloading a file from the network to service a "rw" mode request, you should periodically call CancellationSignal.throwIfCanceled() to check whether the client has canceled the request and abort the download.
Return
AssetFileDescriptor? Returns a new AssetFileDescriptor from which the client can read data of the desired type. This value may be null.
Exceptions
java.io.FileNotFoundException Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid.
java.lang.SecurityException Throws SecurityException if the caller does not have permission to access the data.
java.lang.IllegalArgumentException Throws IllegalArgumentException if the content provider does not support the requested MIME type.

openTypedDocument

Added in API level 24
open fun openTypedDocument(
    documentId: String!,
    mimeTypeFilter: String!,
    opts: Bundle!,
    signal: CancellationSignal!
): AssetFileDescriptor!

Open and return the document in a format matching the specified MIME type filter.

A provider may perform a conversion if the documents's MIME type is not matching the specified MIME type filter.

Virtual documents must have at least one streamable format.

Parameters
documentId String!: the document to return.
mimeTypeFilter String!: the MIME type filter for the requested format. May be *\/*, which matches any MIME type.
opts Bundle!: extra options from the client. Specific to the content provider.
signal CancellationSignal!: used by the caller to signal if the request should be cancelled. May be null.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

query

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

Implementation is provided by the parent class. Cannot be overridden.

Parameters
uri Uri: The URI to query. This will be the full URI sent by the client. This value cannot be null.
projection Array<String!>?: The list of columns to put into the cursor. If null provide a default set of columns.
queryArgs Bundle?: A Bundle containing additional information necessary for the operation. Arguments may include SQL style arguments, such as ContentResolver.QUERY_ARG_SQL_LIMIT, but note that the documentation for each individual provider will indicate which arguments they support. This value may be null.
cancellationSignal CancellationSignal?: A signal to cancel the operation in progress, or null.
Return
Cursor? a Cursor or null.

query

Added in API level 19
fun query(
    uri: Uri,
    projection: Array<String!>?,
    selection: String?,
    selectionArgs: Array<String!>?,
    sortOrder: String?
): Cursor?
Parameters
uri Uri: The URI to query. This will be the full URI sent by the client; if the client is requesting a specific record, the URI will end in a record number that the implementation should parse and add to a WHERE or HAVING clause, specifying that _id value. This value cannot be null.
projection Array<String!>?: The list of columns to put into the cursor. If null all columns are included.
selection String?: A selection criteria to apply when filtering rows. If null then all rows are included.
selectionArgs Array<String!>?: You may include ?s in selection, which will be replaced by the values from selectionArgs, in order that they appear in the selection. The values will be bound as Strings. This value may be null.
sortOrder String?: How the rows in the cursor should be sorted. If null then the provider is free to define the sort order.
Return
Cursor? a Cursor or null.

query

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

WARNING: Sub-classes should not override this method. This method is non-final solely for the purposes of backwards compatibility.

Parameters
uri Uri: The URI to query. This will be the full URI sent by the client; if the client is requesting a specific record, the URI will end in a record number that the implementation should parse and add to a WHERE or HAVING clause, specifying that _id value. This value cannot be null.
projection Array<String!>?: The list of columns to put into the cursor. If null all columns are included.
selection String?: A selection criteria to apply when filtering rows. If null then all rows are included.
selectionArgs Array<String!>?: You may include ?s in selection, which will be replaced by the values from selectionArgs, in order that they appear in the selection. The values will be bound as Strings. This value may be null.
sortOrder String?: How the rows in the cursor should be sorted. If null then the provider is free to define the sort order.
cancellationSignal CancellationSignal?: A signal to cancel the operation in progress, or null if none. If the operation is canceled, then android.os.OperationCanceledException will be thrown when the query is executed.
Return
Cursor? a Cursor or null.

queryChildDocuments

Added in API level 26
open fun queryChildDocuments(
    parentDocumentId: String!,
    projection: Array<String!>?,
    queryArgs: Bundle?
): Cursor!

Override this method to return the children documents contained in the requested directory. This must return immediate descendants only.

If your provider is cloud-based, and you have data cached locally, you may return the local data immediately, setting DocumentsContract.EXTRA_LOADING on Cursor extras to indicate that you are still fetching additional data. Then, when the network data is available, you can send a change notification to trigger a requery and return the complete contents. To return a Cursor with extras, you need to extend and override Cursor.getExtras().

To support change notifications, you must Cursor.setNotificationUri(ContentResolver, Uri) with a relevant Uri, such as DocumentsContract.buildChildDocumentsUri(String, String). Then you can call ContentResolver.notifyChange(Uri, with that Uri to send change notifications.

Parameters
parentDocumentId String!: the directory to return children for.
projection Array<String!>?: list of Document columns to put into the cursor. If null all supported columns should be included.
queryArgs Bundle?: Bundle containing sorting information or other argument useful to the provider. If no sorting information is available, default sorting will be used, which may be unordered. See ContentResolver.QUERY_ARG_SORT_COLUMNS for details. This value may be null.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

queryChildDocuments

Added in API level 19
abstract fun queryChildDocuments(
    parentDocumentId: String!,
    projection: Array<String!>!,
    sortOrder: String!
): Cursor!

Return the children documents contained in the requested directory. This must only return immediate descendants, as additional queries will be issued to recursively explore the tree.

Apps targeting android.os.Build.VERSION_CODES#O or higher should override queryChildDocuments(java.lang.String,java.lang.String[],android.os.Bundle).

If your provider is cloud-based, and you have some data cached or pinned locally, you may return the local data immediately, setting DocumentsContract.EXTRA_LOADING on the Cursor to indicate that you are still fetching additional data. Then, when the network data is available, you can send a change notification to trigger a requery and return the complete contents. To return a Cursor with extras, you need to extend and override Cursor.getExtras().

To support change notifications, you must Cursor.setNotificationUri(ContentResolver, Uri) with a relevant Uri, such as DocumentsContract.buildChildDocumentsUri(String, String). Then you can call ContentResolver.notifyChange(Uri, with that Uri to send change notifications.

Parameters
parentDocumentId String!: the directory to return children for.
projection Array<String!>!: list of Document columns to put into the cursor. If null all supported columns should be included.
sortOrder String!: 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. This ordering is a hint that can be used to prioritize how data is fetched from the network, but UI may always enforce a specific ordering.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

queryDocument

Added in API level 19
abstract fun queryDocument(
    documentId: String!,
    projection: Array<String!>!
): Cursor!

Return metadata for the single requested document. You should avoid making network requests to keep this request fast.

Parameters
documentId String!: the document to return.
projection Array<String!>!: list of Document columns to put into the cursor. If null all supported columns should be included.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

queryRecentDocuments

Added in API level 19
open fun queryRecentDocuments(
    rootId: String!,
    projection: Array<String!>!
): Cursor!

Return recently modified documents under the requested root. This will only be called for roots that advertise Root.FLAG_SUPPORTS_RECENTS. The returned documents should be sorted by Document.COLUMN_LAST_MODIFIED in descending order, and limited to only return the 64 most recently modified documents.

Recent documents do not support change notifications.

Parameters
projection Array<String!>!: list of Document columns to put into the cursor. If null all supported columns should be included.

queryRecentDocuments

Added in API level 29
open fun queryRecentDocuments(
    rootId: String,
    projection: Array<String!>?,
    queryArgs: Bundle?,
    signal: CancellationSignal?
): Cursor?

Return recently modified documents under the requested root. This will only be called for roots that advertise Root.FLAG_SUPPORTS_RECENTS. The returned documents should be sorted by Document.COLUMN_LAST_MODIFIED in descending order of the most recently modified documents.

If this method is overriden by the concrete DocumentsProvider and ContentResolver.QUERY_ARG_LIMIT is specified with a nonnegative int under queryArgs, the result will be limited by that number and ContentResolver.QUERY_ARG_LIMIT will be specified under ContentResolver.EXTRA_HONORED_ARGS. Otherwise, a default 64 limit will be used and no QUERY_ARG* will be specified under ContentResolver.EXTRA_HONORED_ARGS.

Recent documents do not support change notifications.

Parameters
projection Array<String!>?: list of Document columns to put into the cursor. If null all supported columns should be included.
queryArgs Bundle?: the extra query arguments. This value may be null.
signal CancellationSignal?: used by the caller to signal if the request should be cancelled. May be null.
rootId String: This value cannot be null.
Return
Cursor? This value may be null.

queryRoots

Added in API level 19
abstract fun queryRoots(projection: Array<String!>!): Cursor!

Return all roots currently provided. To display to users, you must define at least one root. You should avoid making network requests to keep this request fast.

Each root is defined by the metadata columns described in Root, including Root.COLUMN_DOCUMENT_ID which points to a directory representing a tree of documents to display under that root.

If this set of roots changes, you must call ContentResolver.notifyChange(Uri, with DocumentsContract.buildRootsUri(String) to notify the system.

Parameters
projection Array<String!>!: list of Root columns to put into the cursor. If null all supported columns should be included.

querySearchDocuments

Added in API level 19
open fun querySearchDocuments(
    rootId: String!,
    query: String!,
    projection: Array<String!>!
): Cursor!

Return documents that match the given query under the requested root. The returned documents should be sorted by relevance in descending order. How documents are matched against the query string is an implementation detail left to each provider, but it's suggested that at least Document.COLUMN_DISPLAY_NAME be matched in a case-insensitive fashion.

If your provider is cloud-based, and you have some data cached or pinned locally, you may return the local data immediately, setting DocumentsContract.EXTRA_LOADING on the Cursor to indicate that you are still fetching additional data. Then, when the network data is available, you can send a change notification to trigger a requery and return the complete contents.

To support change notifications, you must Cursor.setNotificationUri(ContentResolver, Uri) with a relevant Uri, such as DocumentsContract.buildSearchDocumentsUri(String,. Then you can call ContentResolver.notifyChange(Uri, with that Uri to send change notifications.

Parameters
rootId String!: the root to search under.
query String!: string to match documents against.
projection Array<String!>!: list of Document columns to put into the cursor. If null all supported columns should be included.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

querySearchDocuments

Added in API level 29
open fun querySearchDocuments(
    rootId: String,
    projection: Array<String!>?,
    queryArgs: Bundle
): Cursor?

Return documents that match the given query under the requested root. The returned documents should be sorted by relevance in descending order. How documents are matched against the query string is an implementation detail left to each provider, but it's suggested that at least Document.COLUMN_DISPLAY_NAME be matched in a case-insensitive fashion.

If your provider is cloud-based, and you have some data cached or pinned locally, you may return the local data immediately, setting DocumentsContract.EXTRA_LOADING on the Cursor to indicate that you are still fetching additional data. Then, when the network data is available, you can send a change notification to trigger a requery and return the complete contents.

To support change notifications, you must Cursor.setNotificationUri(ContentResolver, Uri) with a relevant Uri, such as DocumentsContract.buildSearchDocumentsUri(String,. Then you can call ContentResolver.notifyChange(Uri, with that Uri to send change notifications.

Parameters
rootId String: the root to search under. This value cannot be null.
projection Array<String!>?: list of Document columns to put into the cursor. If null all supported columns should be included.
queryArgs Bundle: the query arguments. DocumentsContract.QUERY_ARG_EXCLUDE_MEDIA, DocumentsContract.QUERY_ARG_DISPLAY_NAME, DocumentsContract.QUERY_ARG_MIME_TYPES, DocumentsContract.QUERY_ARG_FILE_SIZE_OVER, DocumentsContract.QUERY_ARG_LAST_MODIFIED_AFTER. This value cannot be null.
Return
Cursor? cursor containing search result. Include ContentResolver.EXTRA_HONORED_ARGS in Cursor extras Bundle when any QUERY_ARG_* value was honored during the preparation of the results. This value may be null.

removeDocument

Added in API level 24
open fun removeDocument(
    documentId: String!,
    parentDocumentId: String!
): Unit

Removes the requested document or a document tree.

In contrast to deleteDocument it requires specifying the parent. This method is especially useful if the document can be in multiple parents.

It's the responsibility of the provider to revoke grants if the document is removed from the last parent, and effectively the document is deleted.

Parameters
documentId String!: the document to remove.
parentDocumentId String!: the parent of the document to move.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

renameDocument

Added in API level 21
open fun renameDocument(
    documentId: String!,
    displayName: String!
): String!

Rename an existing document.

If a different Document.COLUMN_DOCUMENT_ID must be used to represent the renamed document, generate and return it. Any outstanding URI permission grants will be updated to point at the new document. If the original Document.COLUMN_DOCUMENT_ID is still valid after the rename, return null.

Parameters
documentId String!: the document to rename.
displayName String!: the updated display name of the document. The provider may alter this name to meet any internal constraints, such as avoiding conflicting names.
Exceptions
android.app.AuthenticationRequiredException If authentication is required from the user (such as login credentials), but it is not guaranteed that the client will handle this properly.

revokeDocumentPermission

Added in API level 21
fun revokeDocumentPermission(documentId: String!): Unit

Revoke any active permission grants for the given Document.COLUMN_DOCUMENT_ID, usually called when a document becomes invalid. Follows the same semantics as Context.revokeUriPermission(Uri, int).

update

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

Implementation is provided by the parent class. Throws by default, and cannot be overridden.

Parameters
uri Uri: The URI to query. This can potentially have a record ID if this is an update request for a specific record. This value cannot be null.
values ContentValues?: A set of column_name/value pairs to update in the database. This value may be null.
selection String?: An optional filter to match rows to update. This value may be null.
selectionArgs Array<String!>?: This value may be null.
Return
Int the number of rows affected.