Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/provider/DocumentsContract#nestedclasses) \| [Constants](https://developer.android.com/reference/android/provider/DocumentsContract#constants) \| [Methods](https://developer.android.com/reference/android/provider/DocumentsContract#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/provider/DocumentsContract#inhmethods)

# DocumentsContract

*** ** * ** ***


`
public

final

class
DocumentsContract
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.provider.DocumentsContract |

<br />

*** ** * ** ***

Defines the contract between a documents provider and the platform.


To create a document provider, extend `https://developer.android.com/reference/android/provider/DocumentsProvider`, which
provides a foundational implementation of this contract.


All client apps must hold a valid URI permission grant to access documents,
typically issued when a user makes a selection through
`https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT`, `https://developer.android.com/reference/android/content/Intent#ACTION_CREATE_DOCUMENT`,
or `https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT_TREE`.
**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider`

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/provider/DocumentsContract.Document` Constants related to a document, including `https://developer.android.com/reference/android/database/Cursor` column names and flags. |
| ` class` | `https://developer.android.com/reference/android/provider/DocumentsContract.Path` Holds a path from a document to a particular document under it. |
| ` class` | `https://developer.android.com/reference/android/provider/DocumentsContract.Root` Constants related to a root of documents, including `https://developer.android.com/reference/android/database/Cursor` column names and flags. |

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#ACTION_DOCUMENT_SETTINGS` Action of intent issued by DocumentsUI when user wishes to open/configure/manage a particular document in the provider application. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#CATEGORY_APPROVED_DOCUMENT_HANDLER` Intent category to filter for activities that can handle document intents. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#EXTRA_ERROR` Optional string included in a directory `https://developer.android.com/reference/android/database/Cursor#getExtras()` providing an error message that should be shown to a user. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#EXTRA_EXCLUDE_SELF` Set this in a DocumentsUI intent to cause a package's own roots to be excluded from the roots list. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#EXTRA_INFO` Optional string included in a directory `https://developer.android.com/reference/android/database/Cursor#getExtras()` providing an informational message that should be shown to a user. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#EXTRA_INITIAL_URI` Sets the desired initial location visible to user when file chooser is shown. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#EXTRA_LOADING` Optional boolean flag included in a directory `https://developer.android.com/reference/android/database/Cursor#getExtras()` indicating that a document provider is still loading data. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#EXTRA_ORIENTATION` An extra number of degrees that an image should be rotated during the decode process to be presented correctly. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#EXTRA_PROMPT` Overrides the default prompt text in DocumentsUI when set in an intent. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#METADATA_EXIF` Get Exif information using DocumentsContract#getDocumentMetadata. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#METADATA_TREE_COUNT` Get total count of all documents currently stored under the given directory tree. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#METADATA_TREE_SIZE` Get total size of all documents currently stored under the given directory tree. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#METADATA_TYPES` Get string array identifies the type or types of metadata returned using DocumentsContract#getDocumentMetadata. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#PROVIDER_INTERFACE` Intent action used to identify `https://developer.android.com/reference/android/provider/DocumentsProvider` instances. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#QUERY_ARG_DISPLAY_NAME` Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to query display name is matched. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#QUERY_ARG_EXCLUDE_MEDIA` Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to decide whether the files that have been added to MediaStore should be excluded. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#QUERY_ARG_FILE_SIZE_OVER` Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to query the file size in bytes is larger than the value. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#QUERY_ARG_LAST_MODIFIED_AFTER` Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to query the last modified time is newer than the value. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/DocumentsContract#QUERY_ARG_MIME_TYPES` Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to query mime types is matched. |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildChildDocumentsUri(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String authority, https://developer.android.com/reference/java/lang/String parentDocumentId) ` Build URI representing the children of the target directory in a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildChildDocumentsUriUsingTree(android.net.Uri,%20java.lang.String)(https://developer.android.com/reference/android/net/Uri treeUri, https://developer.android.com/reference/java/lang/String parentDocumentId) ` Build URI representing the children of the target directory in a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildDocumentUri(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String authority, https://developer.android.com/reference/java/lang/String documentId) ` Build URI representing the target `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` in a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildDocumentUriUsingTree(android.net.Uri,%20java.lang.String)(https://developer.android.com/reference/android/net/Uri treeUri, https://developer.android.com/reference/java/lang/String documentId) ` Build URI representing the target `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` in a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildRecentDocumentsUri(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String authority, https://developer.android.com/reference/java/lang/String rootId) ` Build URI representing the recently modified documents of a specific root in a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildRootUri(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String authority, https://developer.android.com/reference/java/lang/String rootId) ` Build URI representing the given `https://developer.android.com/reference/android/provider/DocumentsContract.Root#COLUMN_ROOT_ID` in a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildRootsUri(java.lang.String)(https://developer.android.com/reference/java/lang/String authority) ` Build URI representing the roots of a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildSearchDocumentsUri(android.net.Uri,%20java.lang.String)(https://developer.android.com/reference/android/net/Uri parentDocumentUri, https://developer.android.com/reference/java/lang/String query) ` Build URI representing a search for matching documents under a specific directory in a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildSearchDocumentsUri(java.lang.String,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String authority, https://developer.android.com/reference/java/lang/String rootId, https://developer.android.com/reference/java/lang/String query) ` Build URI representing a search for matching documents under a specific root in a document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildTrashDocumentsUri(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String authority, https://developer.android.com/reference/java/lang/String rootId) ` Returns URI representing the query trash documents of a specific document provider. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#buildTreeDocumentUri(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String authority, https://developer.android.com/reference/java/lang/String documentId) ` Build URI representing access to descendant documents of the given `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID`. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#copyDocument(android.content.ContentResolver,%20android.net.Uri,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri sourceDocumentUri, https://developer.android.com/reference/android/net/Uri targetParentDocumentUri) ` Copies the given document. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#createDocument(android.content.ContentResolver,%20android.net.Uri,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri parentDocumentUri, https://developer.android.com/reference/java/lang/String mimeType, https://developer.android.com/reference/java/lang/String displayName) ` Create a new document with given MIME type and display name. |
| ` static https://developer.android.com/reference/android/content/IntentSender` | ` https://developer.android.com/reference/android/provider/DocumentsContract#createWebLinkIntent(android.content.ContentResolver,%20android.net.Uri,%20android.os.Bundle)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri uri, https://developer.android.com/reference/android/os/Bundle options) ` Creates an intent for obtaining a web link for the specified document. |
| ` static boolean` | ` https://developer.android.com/reference/android/provider/DocumentsContract#deleteDocument(android.content.ContentResolver,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri documentUri) ` Delete the given document. |
| ` static void` | ` https://developer.android.com/reference/android/provider/DocumentsContract#ejectRoot(android.content.ContentResolver,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri rootUri) ` Ejects the given root. |
| ` static https://developer.android.com/reference/android/provider/DocumentsContract.Path` | ` https://developer.android.com/reference/android/provider/DocumentsContract#findDocumentPath(android.content.ContentResolver,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri treeUri) ` Finds the canonical path from the top of the document tree. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentId(android.net.Uri)(https://developer.android.com/reference/android/net/Uri documentUri) ` Extract the `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` from the given URI. |
| ` static https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentMetadata(android.content.ContentResolver,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri documentUri) ` Returns metadata associated with the document. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentThumbnail(android.content.ContentResolver,%20android.net.Uri,%20android.graphics.Point,%20android.os.CancellationSignal)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri documentUri, https://developer.android.com/reference/android/graphics/Point size, https://developer.android.com/reference/android/os/CancellationSignal signal) ` Return thumbnail representing the document at the given URI. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/provider/DocumentsContract#getRootId(android.net.Uri)(https://developer.android.com/reference/android/net/Uri rootUri) ` Extract the `https://developer.android.com/reference/android/provider/DocumentsContract.Root#COLUMN_ROOT_ID` from the given URI. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/provider/DocumentsContract#getSearchDocumentsQuery(android.net.Uri)(https://developer.android.com/reference/android/net/Uri searchDocumentsUri) ` Extract the search query from a URI built by `https://developer.android.com/reference/android/provider/DocumentsContract#buildSearchDocumentsUri(java.lang.String,%20java.lang.String,%20java.lang.String)`. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/provider/DocumentsContract#getTreeDocumentId(android.net.Uri)(https://developer.android.com/reference/android/net/Uri documentUri) ` Extract the via `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` from the given URI. |
| ` static boolean` | ` https://developer.android.com/reference/android/provider/DocumentsContract#isChildDocument(android.content.ContentResolver,%20android.net.Uri,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri parentDocumentUri, https://developer.android.com/reference/android/net/Uri childDocumentUri) ` Test if a document is descendant (child, grandchild, etc) from the given parent. |
| ` static boolean` | ` https://developer.android.com/reference/android/provider/DocumentsContract#isDocumentUri(android.content.Context,%20android.net.Uri)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/net/Uri uri) ` Test if the given URI represents a `https://developer.android.com/reference/android/provider/DocumentsContract.Document` backed by a `https://developer.android.com/reference/android/provider/DocumentsProvider`. |
| ` static boolean` | ` https://developer.android.com/reference/android/provider/DocumentsContract#isRootUri(android.content.Context,%20android.net.Uri)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/net/Uri uri) ` Test if the given URI represents specific root backed by `https://developer.android.com/reference/android/provider/DocumentsProvider`. |
| ` static boolean` | ` https://developer.android.com/reference/android/provider/DocumentsContract#isRootsUri(android.content.Context,%20android.net.Uri)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/net/Uri uri) ` Test if the given URI represents all roots of the authority backed by `https://developer.android.com/reference/android/provider/DocumentsProvider`. |
| ` static boolean` | ` https://developer.android.com/reference/android/provider/DocumentsContract#isTreeUri(android.net.Uri)(https://developer.android.com/reference/android/net/Uri uri) ` Test if the given URI represents a `https://developer.android.com/reference/android/provider/DocumentsContract.Document` tree. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#moveDocument(android.content.ContentResolver,%20android.net.Uri,%20android.net.Uri,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri sourceDocumentUri, https://developer.android.com/reference/android/net/Uri sourceParentDocumentUri, https://developer.android.com/reference/android/net/Uri targetParentDocumentUri) ` Moves the given document under a new parent. |
| ` static boolean` | ` https://developer.android.com/reference/android/provider/DocumentsContract#removeDocument(android.content.ContentResolver,%20android.net.Uri,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri documentUri, https://developer.android.com/reference/android/net/Uri parentDocumentUri) ` Removes the given document from a parent directory. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#renameDocument(android.content.ContentResolver,%20android.net.Uri,%20java.lang.String)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri documentUri, https://developer.android.com/reference/java/lang/String displayName) ` Change the display name of an existing document. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#restoreDocumentFromTrash(android.content.ContentResolver,%20android.net.Uri,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri sourceDocumentUri, https://developer.android.com/reference/android/net/Uri targetParentDocumentUri) ` Restores a document from the trash. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/provider/DocumentsContract#trashDocument(android.content.ContentResolver,%20android.net.Uri)(https://developer.android.com/reference/android/content/ContentResolver content, https://developer.android.com/reference/android/net/Uri documentUri) ` Trashes the given document. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### ACTION_DOCUMENT_SETTINGS

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_DOCUMENT_SETTINGS
```

Action of intent issued by DocumentsUI when user wishes to open/configure/manage a particular
document in the provider application.

When issued, the intent will include the URI of the document as the intent data.

A provider wishing to provide support for this action should do two things.
- Add an `<intent-filter>` matching this action.
- When supplying information in `https://developer.android.com/reference/android/provider/DocumentsProvider#queryChildDocuments(java.lang.String,%20java.lang.String[],%20android.os.Bundle)`, include `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_SETTINGS` in the flags for each document that supports settings.

  <br />

  <br />

  Constant Value:

  "android.provider.action.DOCUMENT_SETTINGS"


### CATEGORY_APPROVED_DOCUMENT_HANDLER

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String CATEGORY_APPROVED_DOCUMENT_HANDLER
```

Intent category to filter for activities that can handle document intents.

Indicates that an approved activity can receive intents `https://developer.android.com/reference/android/content/Intent#ACTION_SEND` and/or
`https://developer.android.com/reference/android/content/Intent#ACTION_SEND_MULTIPLE`. The activity's package must be allowlisted by the system
file manager. The activity will appear in the system file manager as a menu item when
acceptable files are selected. The activity must also define an \`android:label\` to be
accepted as a menu item.

Optionally, the activity can declare the intent to be shown as an action button instead of
a menu item in \`AndroidManifest.xml\`. It must include an \`android:icon\` and a meta-data entry
\`android.approvedtarget.as_button\` with a value of \`true\`.

An example declaration:

```
 <activity android:name=".ApprovedDocumentHandlerActivity"
         ...
   <intent-filter>
       <action android:name="android.intent.action.SEND" />
       <category android:name="android.provider.category.APPROVED_DOCUMENT_HANDLER" />
       <data android:mimeType="text/plain" />
   </intent-filter>
 </activity>
 
```

<br />

<br />

Constant Value:

"android.provider.category.APPROVED_DOCUMENT_HANDLER"


### EXTRA_ERROR

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_ERROR
```

Optional string included in a directory `https://developer.android.com/reference/android/database/Cursor#getExtras()`
providing an error message that should be shown to a user. For example, a
provider may wish to indicate that a network error occurred. The user may
choose to retry, resulting in a new query.

<br />

Constant Value:

"error"


### EXTRA_EXCLUDE_SELF

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_EXCLUDE_SELF
```

Set this in a DocumentsUI intent to cause a package's own roots to be
excluded from the roots list.

<br />

Constant Value:

"android.provider.extra.EXCLUDE_SELF"


### EXTRA_INFO

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_INFO
```

Optional string included in a directory `https://developer.android.com/reference/android/database/Cursor#getExtras()`
providing an informational message that should be shown to a user. For
example, a provider may wish to indicate that not all documents are
available.

<br />

Constant Value:

"info"


### EXTRA_INITIAL_URI

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_INITIAL_URI
```

Sets the desired initial location visible to user when file chooser is shown.

Applicable to `https://developer.android.com/reference/android/content/Intent` with actions:

- `https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT`
- `https://developer.android.com/reference/android/content/Intent#ACTION_CREATE_DOCUMENT`
- `https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT_TREE`

Location should specify a document URI or a tree URI with document ID. If
this URI identifies a non-directory, document navigator will attempt to use the parent
of the document as the initial location.

The initial location is system specific if this extra is missing or document navigator
failed to locate the desired initial location.

<br />

Constant Value:

"android.provider.extra.INITIAL_URI"


### EXTRA_LOADING

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_LOADING
```

Optional boolean flag included in a directory `https://developer.android.com/reference/android/database/Cursor#getExtras()`
indicating that a document provider is still loading data. For example, a
provider has returned some results, but is still waiting on an
outstanding network request. The provider must send a content changed
notification when loading is finished.

<br />

**See also:**

- `https://developer.android.com/reference/android/content/ContentResolver#notifyChange(android.net.Uri,%20android.database.ContentObserver,%20boolean)`

Constant Value:

"loading"


### EXTRA_ORIENTATION

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_ORIENTATION
```

An extra number of degrees that an image should be rotated during the
decode process to be presented correctly.

<br />

**See also:**

- `https://developer.android.com/reference/android/content/res/AssetFileDescriptor#getExtras()`
- `https://developer.android.com/reference/android/provider/MediaStore.MediaColumns#ORIENTATION`

Constant Value:

"android.provider.extra.ORIENTATION"


### EXTRA_PROMPT

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_PROMPT
```

Overrides the default prompt text in DocumentsUI when set in an intent.

<br />

Constant Value:

"android.provider.extra.PROMPT"


### METADATA_EXIF

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String METADATA_EXIF
```

Get Exif information using DocumentsContract#getDocumentMetadata.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentMetadata(android.content.ContentResolver,%20android.net.Uri)`

Constant Value:

"android:documentExif"


### METADATA_TREE_COUNT

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String METADATA_TREE_COUNT
```

Get total count of all documents currently stored under the given
directory tree. Only valid for `https://developer.android.com/reference/android/provider/DocumentsContract.Document#MIME_TYPE_DIR` documents.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentMetadata(android.content.ContentResolver,%20android.net.Uri)`

Constant Value:

"android:metadataTreeCount"


### METADATA_TREE_SIZE

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String METADATA_TREE_SIZE
```

Get total size of all documents currently stored under the given
directory tree. Only valid for `https://developer.android.com/reference/android/provider/DocumentsContract.Document#MIME_TYPE_DIR` documents.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentMetadata(android.content.ContentResolver,%20android.net.Uri)`

Constant Value:

"android:metadataTreeSize"


### METADATA_TYPES

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String METADATA_TYPES
```

Get string array identifies the type or types of metadata returned
using DocumentsContract#getDocumentMetadata.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentMetadata(android.content.ContentResolver,%20android.net.Uri)`

Constant Value:

"android:documentMetadataTypes"


### PROVIDER_INTERFACE

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROVIDER_INTERFACE
```

Intent action used to identify `https://developer.android.com/reference/android/provider/DocumentsProvider` instances. This
is used in the `<intent-filter>` of a `<provider>`.

<br />

Constant Value:

"android.content.action.DOCUMENTS_PROVIDER"


### QUERY_ARG_DISPLAY_NAME

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String QUERY_ARG_DISPLAY_NAME
```

Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to query display name is matched.
The match of display name is partial matching and case-insensitive.
Ex: The value is "o", the display name of the results will contain
both "foo" and "Open".

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#querySearchDocuments(java.lang.String,%20java.lang.String[],%20android.os.Bundle)`

Constant Value:

"android:query-arg-display-name"


### QUERY_ARG_EXCLUDE_MEDIA

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String QUERY_ARG_EXCLUDE_MEDIA
```

Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to decide whether the files that
have been added to MediaStore should be excluded. If the value is
true, exclude them. Otherwise, include them.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#querySearchDocuments(java.lang.String,%20java.lang.String[],%20android.os.Bundle)`

Constant Value:

"android:query-arg-exclude-media"


### QUERY_ARG_FILE_SIZE_OVER

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String QUERY_ARG_FILE_SIZE_OVER
```

Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to query the file size in bytes is
larger than the value.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#querySearchDocuments(java.lang.String,%20java.lang.String[],%20android.os.Bundle)`

Constant Value:

"android:query-arg-file-size-over"


### QUERY_ARG_LAST_MODIFIED_AFTER

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String QUERY_ARG_LAST_MODIFIED_AFTER
```

Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to query the last modified time
is newer than the value. The unit is in milliseconds since
January 1, 1970 00:00:00.0 UTC.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#querySearchDocuments(java.lang.String,%20java.lang.String[],%20android.os.Bundle)`
- `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_LAST_MODIFIED`

Constant Value:

"android:query-arg-last-modified-after"


### QUERY_ARG_MIME_TYPES

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String QUERY_ARG_MIME_TYPES
```

Key for `https://developer.android.com/reference/android/provider/DocumentsProvider` to query mime types is matched.
The value is a string array, it can support different mime types.
Each items will be treated as "OR" condition. Ex: {"image/\*" ,
"video/\*"}. The mime types of the results will contain both image
type and video type.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#querySearchDocuments(java.lang.String,%20java.lang.String[],%20android.os.Bundle)`

Constant Value:

"android:query-arg-mime-types"


## Public methods

### buildChildDocumentsUri

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildChildDocumentsUri (String authority, 
                String parentDocumentId)
```

Build URI representing the children of the target directory in a document
provider. When queried, a provider will return zero or more rows with
columns defined by `https://developer.android.com/reference/android/provider/DocumentsContract.Document`.

<br />

| Parameters ||
|---|---|
| `authority` | `String` <br /> |
| `parentDocumentId` | `String`: the document to return children for, which must be a directory with MIME type of `https://developer.android.com/reference/android/provider/DocumentsContract.Document#MIME_TYPE_DIR`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#queryChildDocuments(java.lang.String,%20java.lang.String[],%20java.lang.String)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentId(android.net.Uri)`

### buildChildDocumentsUriUsingTree

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildChildDocumentsUriUsingTree (Uri treeUri, 
                String parentDocumentId)
```

Build URI representing the children of the target directory in a document
provider. When queried, a provider will return zero or more rows with
columns defined by `https://developer.android.com/reference/android/provider/DocumentsContract.Document`.


However, instead of directly accessing the target directory, the returned
URI will leverage access granted through a subtree URI, typically
returned by `https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT_TREE`. The target
directory must be a descendant (child, grandchild, etc) of the subtree.


This is typically used to access documents under a user-selected
directory tree, since it doesn't require the user to separately confirm
each new document access.

<br />

| Parameters ||
|---|---|
| `treeUri` | `Uri`: the subtree to leverage to gain access to the target document. The target directory must be a descendant of this subtree. <br /> |
| `parentDocumentId` | `String`: the document to return children for, which the caller may not have direct access to, and which must be a directory with MIME type of `https://developer.android.com/reference/android/provider/DocumentsContract.Document#MIME_TYPE_DIR`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT_TREE`
- `https://developer.android.com/reference/android/provider/DocumentsProvider#isChildDocument(java.lang.String,%20java.lang.String)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#buildChildDocumentsUri(java.lang.String,%20java.lang.String)`

### buildDocumentUri

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildDocumentUri (String authority, 
                String documentId)
```

Build URI representing the target `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` in
a document provider. When queried, a provider will return a single row
with columns defined by `https://developer.android.com/reference/android/provider/DocumentsContract.Document`.

<br />

| Parameters ||
|---|---|
| `authority` | `String` <br /> |
| `documentId` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#queryDocument(java.lang.String,%20java.lang.String[])`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentId(android.net.Uri)`

### buildDocumentUriUsingTree

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildDocumentUriUsingTree (Uri treeUri, 
                String documentId)
```

Build URI representing the target `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` in
a document provider. When queried, a provider will return a single row
with columns defined by `https://developer.android.com/reference/android/provider/DocumentsContract.Document`.


However, instead of directly accessing the target document, the returned
URI will leverage access granted through a subtree URI, typically
returned by `https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT_TREE`. The target document
must be a descendant (child, grandchild, etc) of the subtree.


This is typically used to access documents under a user-selected
directory tree, since it doesn't require the user to separately confirm
each new document access.

<br />

| Parameters ||
|---|---|
| `treeUri` | `Uri`: the subtree to leverage to gain access to the target document. The target directory must be a descendant of this subtree. <br /> |
| `documentId` | `String`: the target document, which the caller may not have direct access to. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT_TREE`
- `https://developer.android.com/reference/android/provider/DocumentsProvider#isChildDocument(java.lang.String,%20java.lang.String)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#buildDocumentUri(java.lang.String,%20java.lang.String)`

### buildRecentDocumentsUri

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildRecentDocumentsUri (String authority, 
                String rootId)
```

Build URI representing the recently modified documents of a specific root
in a document provider. When queried, a provider will return zero or more
rows with columns defined by `https://developer.android.com/reference/android/provider/DocumentsContract.Document`.

<br />

| Parameters ||
|---|---|
| `authority` | `String` <br /> |
| `rootId` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#queryRecentDocuments(java.lang.String,%20java.lang.String[])`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getRootId(android.net.Uri)`

### buildRootUri

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildRootUri (String authority, 
                String rootId)
```

Build URI representing the given `https://developer.android.com/reference/android/provider/DocumentsContract.Root#COLUMN_ROOT_ID` in a
document provider.

<br />

| Parameters ||
|---|---|
| `authority` | `String` <br /> |
| `rootId` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#getRootId(android.net.Uri)`

### buildRootsUri

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildRootsUri (String authority)
```

Build URI representing the roots of a document provider. When queried, a
provider will return one or more rows with columns defined by
`https://developer.android.com/reference/android/provider/DocumentsContract.Root`.

<br />

| Parameters ||
|---|---|
| `authority` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#queryRoots(java.lang.String[])`

### buildSearchDocumentsUri

Added in [version 37.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static Uri buildSearchDocumentsUri (Uri parentDocumentUri, 
                String query)
```

Build URI representing a search for matching documents under a specific directory in a
document provider. When queried, a provider will return zero or more rows with columns
defined by `https://developer.android.com/reference/android/provider/DocumentsContract.Document`.

<br />

| Parameters ||
|---|---|
| `parentDocumentUri` | `Uri`: the document that search results should be restricted to, which must be a directory with mime type of `https://developer.android.com/reference/android/provider/DocumentsContract.Document#MIME_TYPE_DIR` and have `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_SUBTREE_SEARCH` set. This value cannot be `null`. <br /> |
| `query` | `String`: string to match documents against. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#querySearchDocuments(java.lang.String,%20java.lang.String[],%20android.os.Bundle,%20android.os.CancellationSignal)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getDocumentId(android.net.Uri)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getSearchDocumentsQuery(android.net.Uri)`

### buildSearchDocumentsUri

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildSearchDocumentsUri (String authority, 
                String rootId, 
                String query)
```

Build URI representing a search for matching documents under a specific
root in a document provider. When queried, a provider will return zero or
more rows with columns defined by `https://developer.android.com/reference/android/provider/DocumentsContract.Document`.

<br />

| Parameters ||
|---|---|
| `authority` | `String` <br /> |
| `rootId` | `String` <br /> |
| `query` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#querySearchDocuments(java.lang.String,%20java.lang.String,%20java.lang.String[])`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getRootId(android.net.Uri)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getSearchDocumentsQuery(android.net.Uri)`

### buildTrashDocumentsUri

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildTrashDocumentsUri (String authority, 
                String rootId)
```

Returns URI representing the query trash documents of a specific document provider.

<br />

| Parameters ||
|---|---|
| `authority` | `String`: This value cannot be `null`. <br /> |
| `rootId` | `String`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#queryTrashDocuments(java.lang.String,%20java.lang.String[],%20android.os.Bundle,%20android.os.CancellationSignal)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getRootId(android.net.Uri)`

### buildTreeDocumentUri

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri buildTreeDocumentUri (String authority, 
                String documentId)
```

Build URI representing access to descendant documents of the given
`https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID`.

<br />

| Parameters ||
|---|---|
| `authority` | `String` <br /> |
| `documentId` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#getTreeDocumentId(android.net.Uri)`

### copyDocument

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri copyDocument (ContentResolver content, 
                Uri sourceDocumentUri, 
                Uri targetParentDocumentUri)
```

Copies the given document.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `sourceDocumentUri` | `Uri`: document with `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_COPY` This value cannot be `null`. <br /> |
| `targetParentDocumentUri` | `Uri`: document which will become a parent of the source document's copy. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | the copied document, or `null` if failed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

### createDocument

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri createDocument (ContentResolver content, 
                Uri parentDocumentUri, 
                String mimeType, 
                String displayName)
```

Create a new document with given MIME type and display name.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `parentDocumentUri` | `Uri`: directory with `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_DIR_SUPPORTS_CREATE` This value cannot be `null`. <br /> |
| `mimeType` | `String`: MIME type of new document. This value cannot be `null`. <br /> |
| `displayName` | `String`: name of new document. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | newly created document, or `null` if failed <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

### createWebLinkIntent

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static IntentSender createWebLinkIntent (ContentResolver content, 
                Uri uri, 
                Bundle options)
```

Creates an intent for obtaining a web link for the specified document.

Note, that due to internal limitations, if there is already a web link
intent created for the specified document but with different options,
then it may be overridden.

Providers are required to show confirmation UI for all new permissions granted
for the linked document.

If list of recipients is known, then it should be passed in options as
`https://developer.android.com/reference/android/content/Intent#EXTRA_EMAIL` as a list of email addresses. Note, that
this is just a hint for the provider, which can ignore the list. In either
case the provider is required to show a UI for letting the user confirm
any new permission grants.

Note, that the entire `options` bundle will be sent to the provider
backing the passed `uri`. Make sure that you trust the provider
before passing any sensitive information.

Since this API may show a UI, it cannot be called from background.

In order to obtain the Web Link use code like this:


     void onSomethingHappened() {
       IntentSender sender = DocumentsContract.createWebLinkIntent(*...*);
       if (sender != null) {
         startIntentSenderForResult(
             sender,
             WEB_LINK_REQUEST_CODE,
             null, 0, 0, 0, null);
       }
     }

     *(...)*

     void onActivityResult(int requestCode, int resultCode, Intent data) {
       if (requestCode == WEB_LINK_REQUEST_CODE && resultCode == RESULT_OK) {
         Uri weblinkUri = data.getData();
         *...*
       }
     }
     
<br />

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `uri` | `Uri`: uri for the document to create a link to. This value cannot be `null`. <br /> |
| `options` | `Bundle`: Extra information for generating the link. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/IntentSender` | an intent sender to obtain the web link, or null if the document is not linkable, or creating the intent sender failed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#createWebLinkIntent(java.lang.String,%20android.os.Bundle)`
- `https://developer.android.com/reference/android/content/Intent#EXTRA_EMAIL`

### deleteDocument

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean deleteDocument (ContentResolver content, 
                Uri documentUri)
```

Delete the given document.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `documentUri` | `Uri`: document with `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_DELETE` This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | if the document was deleted successfully. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

### ejectRoot

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void ejectRoot (ContentResolver content, 
                Uri rootUri)
```

Ejects the given root. It throws `https://developer.android.com/reference/java/lang/IllegalStateException` when ejection failed.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `rootUri` | `Uri`: root with `https://developer.android.com/reference/android/provider/DocumentsContract.Root#FLAG_SUPPORTS_EJECT` to be ejected. This value cannot be `null`. <br /> |

### findDocumentPath

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static DocumentsContract.Path findDocumentPath (ContentResolver content, 
                Uri treeUri)
```

Finds the canonical path from the top of the document tree.

The `https://developer.android.com/reference/android/provider/DocumentsContract.Path#getPath()` of the return value contains the document ID
of all documents along the path from the top the document tree to the
requested document, both inclusive.

The `https://developer.android.com/reference/android/provider/DocumentsContract.Path#getRootId()` of the return value returns `null`.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `treeUri` | `Uri`: treeUri of the document which path is requested. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/provider/DocumentsContract.Path` | the path of the document, or `null` if failed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#findDocumentPath(java.lang.String,%20java.lang.String)`

### getDocumentId

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getDocumentId (Uri documentUri)
```

Extract the `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` from the given URI.

<br />

| Parameters ||
|---|---|
| `documentUri` | `Uri` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#isDocumentUri(android.content.Context,%20android.net.Uri)`

### getDocumentMetadata

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bundle getDocumentMetadata (ContentResolver content, 
                Uri documentUri)
```

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 `https://developer.android.com/reference/android/os/Bundle` will contain zero or more entries depending
on the type of data supported by the document provider.

1. A `https://developer.android.com/reference/android/provider/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 `https://developer.android.com/reference/android/os/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.

Example:

<br />


         Bundle metadata = DocumentsContract.getDocumentMetadata(client, imageDocUri, tags);
         if (metadata.containsKey(DocumentsContract.METADATA_EXIF)) {
             Bundle exif = metadata.getBundle(DocumentsContract.METADATA_EXIF);
             int imageLength = exif.getInt(ExifInterface.TAG_IMAGE_LENGTH);
         }
     
<br />

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `documentUri` | `Uri`: a Document URI. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle of Bundles. This value may be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

### getDocumentThumbnail

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap getDocumentThumbnail (ContentResolver content, 
                Uri documentUri, 
                Point size, 
                CancellationSignal signal)
```

Return thumbnail representing the document at the given URI. Callers are
responsible for their own in-memory caching.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `documentUri` | `Uri`: document to return thumbnail for, which must have `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_THUMBNAIL` set. This value cannot be `null`. <br /> |
| `size` | `Point`: optimal thumbnail size desired. A provider may return a thumbnail of a different size, but never more than double the requested size. This value cannot be `null`. <br /> |
| `signal` | `CancellationSignal`: signal used to indicate if caller is no longer interested in the thumbnail. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | decoded thumbnail, or `null` if problem was encountered. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsProvider#openDocumentThumbnail(java.lang.String,%20android.graphics.Point,%20android.os.CancellationSignal)`

### getRootId

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getRootId (Uri rootUri)
```

Extract the `https://developer.android.com/reference/android/provider/DocumentsContract.Root#COLUMN_ROOT_ID` from the given URI.

<br />

| Parameters ||
|---|---|
| `rootUri` | `Uri` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getSearchDocumentsQuery

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getSearchDocumentsQuery (Uri searchDocumentsUri)
```

Extract the search query from a URI built by
`https://developer.android.com/reference/android/provider/DocumentsContract#buildSearchDocumentsUri(java.lang.String,%20java.lang.String,%20java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `searchDocumentsUri` | `Uri` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getTreeDocumentId

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getTreeDocumentId (Uri documentUri)
```

Extract the via `https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` from the given URI.

<br />

| Parameters ||
|---|---|
| `documentUri` | `Uri` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### isChildDocument

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isChildDocument (ContentResolver content, 
                Uri parentDocumentUri, 
                Uri childDocumentUri)
```

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

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `parentDocumentUri` | `Uri`: parent to verify against. This value cannot be `null`. <br /> |
| `childDocumentUri` | `Uri`: child to verify. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | if given document is a descendant of the given parent. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract.Root#FLAG_SUPPORTS_IS_CHILD`

### isDocumentUri

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isDocumentUri (Context context, 
                Uri uri)
```

Test if the given URI represents a `https://developer.android.com/reference/android/provider/DocumentsContract.Document` backed by a
`https://developer.android.com/reference/android/provider/DocumentsProvider`.

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |
| `uri` | `Uri`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#buildDocumentUri(java.lang.String,%20java.lang.String)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#buildDocumentUriUsingTree(android.net.Uri,%20java.lang.String)`

### isRootUri

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isRootUri (Context context, 
                Uri uri)
```

Test if the given URI represents specific root backed by `https://developer.android.com/reference/android/provider/DocumentsProvider`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: This value cannot be `null`. <br /> |
| `uri` | `Uri`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#buildRootUri(java.lang.String,%20java.lang.String)`

### isRootsUri

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isRootsUri (Context context, 
                Uri uri)
```

Test if the given URI represents all roots of the authority
backed by `https://developer.android.com/reference/android/provider/DocumentsProvider`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: This value cannot be `null`. <br /> |
| `uri` | `Uri`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#buildRootsUri(java.lang.String)`

### isTreeUri

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isTreeUri (Uri uri)
```

Test if the given URI represents a `https://developer.android.com/reference/android/provider/DocumentsContract.Document` tree.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/DocumentsContract#buildTreeDocumentUri(java.lang.String,%20java.lang.String)`
- `https://developer.android.com/reference/android/provider/DocumentsContract#getTreeDocumentId(android.net.Uri)`

### moveDocument

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri moveDocument (ContentResolver content, 
                Uri sourceDocumentUri, 
                Uri sourceParentDocumentUri, 
                Uri targetParentDocumentUri)
```

Moves the given document under a new parent.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `sourceDocumentUri` | `Uri`: document with `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_MOVE` This value cannot be `null`. <br /> |
| `sourceParentDocumentUri` | `Uri`: parent document of the document to move. This value cannot be `null`. <br /> |
| `targetParentDocumentUri` | `Uri`: document which will become a new parent of the source document. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | the moved document, or `null` if failed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

### removeDocument

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean removeDocument (ContentResolver content, 
                Uri documentUri, 
                Uri parentDocumentUri)
```

Removes the given document from a parent directory.

In contrast to `https://developer.android.com/reference/android/provider/DocumentsContract#deleteDocument(android.content.ContentResolver,%20android.net.Uri)` it requires specifying the parent.
This method is especially useful if the document can be in multiple parents.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `documentUri` | `Uri`: document with `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_REMOVE` This value cannot be `null`. <br /> |
| `parentDocumentUri` | `Uri`: parent document of the document to remove. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the document was removed successfully. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

### renameDocument

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri renameDocument (ContentResolver content, 
                Uri documentUri, 
                String displayName)
```

Change the display name of an existing document.


If the underlying provider needs to create a new
`https://developer.android.com/reference/android/provider/DocumentsContract.Document#COLUMN_DOCUMENT_ID` to represent the updated display
name, that new document is returned and the original document is no
longer valid. Otherwise, the original document is returned.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `documentUri` | `Uri`: document with `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_RENAME` This value cannot be `null`. <br /> |
| `displayName` | `String`: updated name for document. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | the existing or new document after the rename, or `null` if failed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

### restoreDocumentFromTrash

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri restoreDocumentFromTrash (ContentResolver content, 
                Uri sourceDocumentUri, 
                Uri targetParentDocumentUri)
```

Restores a document from the trash.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `sourceDocumentUri` | `Uri`: trashed document to restore. This value cannot be `null`. <br /> |
| `targetParentDocumentUri` | `Uri`: parent document to restore the document to. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | the restored document, or `null` if failed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` | if the `sourceDocumentUri` does not exist or the `targetParentDocumentUri` does not exist. |
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the document cannot be restored (e.g., already restored, or original parent is invalid). |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if the document provider does not support restoring. |

### trashDocument

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri trashDocument (ContentResolver content, 
                Uri documentUri)
```

Trashes the given document.

<br />

| Parameters ||
|---|---|
| `content` | `ContentResolver`: This value cannot be `null`. <br /> |
| `documentUri` | `Uri`: document with `https://developer.android.com/reference/android/provider/DocumentsContract.Document#FLAG_SUPPORTS_TRASH` This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | the trashed document, or `null` if failed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` | if the documentUri does not exist. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the document does not support trashing. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if the document provider does not support trashing. |