DocumentsContract


public final class DocumentsContract
extends Object

java.lang.Object
   ↳ android.provider.DocumentsContract


Defines the contract between a documents provider and the platform.

To create a document provider, extend 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 Intent.ACTION_OPEN_DOCUMENT, Intent.ACTION_CREATE_DOCUMENT, or Intent.ACTION_OPEN_DOCUMENT_TREE.

See also:

Summary

Nested classes

class DocumentsContract.Document

Constants related to a document, including Cursor column names and flags. 

class DocumentsContract.Path

Holds a path from a document to a particular document under it. 

class DocumentsContract.Root

Constants related to a root of documents, including Cursor column names and flags. 

Constants

String ACTION_DOCUMENT_SETTINGS

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

String EXTRA_ERROR

Optional string included in a directory Cursor.getExtras() providing an error message that should be shown to a user.

String EXTRA_EXCLUDE_SELF

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

String EXTRA_INFO

Optional string included in a directory Cursor.getExtras() providing an informational message that should be shown to a user.

String EXTRA_INITIAL_URI

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

String EXTRA_LOADING

Optional boolean flag included in a directory Cursor.getExtras() indicating that a document provider is still loading data.

String EXTRA_ORIENTATION

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

String EXTRA_PROMPT

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

String METADATA_EXIF

Get Exif information using DocumentsContract#getDocumentMetadata.

String METADATA_TREE_COUNT

Get total count of all documents currently stored under the given directory tree.

String METADATA_TREE_SIZE

Get total size of all documents currently stored under the given directory tree.

String METADATA_TYPES

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

String PROVIDER_INTERFACE

Intent action used to identify DocumentsProvider instances.

String QUERY_ARG_DISPLAY_NAME

Key for DocumentsProvider to query display name is matched.

String QUERY_ARG_EXCLUDE_MEDIA

Key for DocumentsProvider to decide whether the files that have been added to MediaStore should be excluded.

String QUERY_ARG_FILE_SIZE_OVER

Key for DocumentsProvider to query the file size in bytes is larger than the value.

String QUERY_ARG_LAST_MODIFIED_AFTER

Key for DocumentsProvider to query the last modified time is newer than the value.

String QUERY_ARG_MIME_TYPES

Key for DocumentsProvider to query mime types is matched.

Public methods

static Uri buildChildDocumentsUri(String authority, String parentDocumentId)

Build URI representing the children of the target directory in a document provider.

static Uri buildChildDocumentsUriUsingTree(Uri treeUri, String parentDocumentId)

Build URI representing the children of the target directory in a document provider.

static Uri buildDocumentUri(String authority, String documentId)

Build URI representing the target Document.COLUMN_DOCUMENT_ID in a document provider.

static Uri buildDocumentUriUsingTree(Uri treeUri, String documentId)

Build URI representing the target Document.COLUMN_DOCUMENT_ID in a document provider.

static Uri buildRecentDocumentsUri(String authority, String rootId)

Build URI representing the recently modified documents of a specific root in a document provider.

static Uri buildRootUri(String authority, String rootId)

Build URI representing the given Root.COLUMN_ROOT_ID in a document provider.

static Uri buildRootsUri(String authority)

Build URI representing the roots of a document provider.

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.

static Uri buildTreeDocumentUri(String authority, String documentId)

Build URI representing access to descendant documents of the given Document.COLUMN_DOCUMENT_ID.

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

Copies the given document.

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

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

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

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

static boolean deleteDocument(ContentResolver content, Uri documentUri)

Delete the given document.

static void ejectRoot(ContentResolver content, Uri rootUri)

Ejects the given root.

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

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

static String getDocumentId(Uri documentUri)

Extract the Document.COLUMN_DOCUMENT_ID from the given URI.

static Bundle getDocumentMetadata(ContentResolver content, Uri documentUri)

Returns metadata associated with the document.

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

Return thumbnail representing the document at the given URI.

static String getRootId(Uri rootUri)

Extract the Root.COLUMN_ROOT_ID from the given URI.

static String getSearchDocumentsQuery(Uri searchDocumentsUri)

Extract the search query from a URI built by buildSearchDocumentsUri(java.lang.String, java.lang.String, java.lang.String).

static String getTreeDocumentId(Uri documentUri)

Extract the via Document.COLUMN_DOCUMENT_ID from the given URI.

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

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

static boolean isDocumentUri(Context context, Uri uri)

Test if the given URI represents a Document backed by a DocumentsProvider.

static boolean isRootUri(Context context, Uri uri)

Test if the given URI represents specific root backed by DocumentsProvider.

static boolean isRootsUri(Context context, Uri uri)

Test if the given URI represents all roots of the authority backed by DocumentsProvider.

static boolean isTreeUri(Uri uri)

Test if the given URI represents a Document tree.

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

Moves the given document under a new parent.

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

Removes the given document from a parent directory.

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

Change the display name of an existing document.

Inherited methods

Constants

ACTION_DOCUMENT_SETTINGS

Added in API level 26
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 DocumentsProvider.queryChildDocuments, include Document.FLAG_SUPPORTS_SETTINGS in the flags for each document that supports settings.

    Constant Value: "android.provider.action.DOCUMENT_SETTINGS"

  • EXTRA_ERROR

    Added in API level 19
    public static final String EXTRA_ERROR

    Optional string included in a directory 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.

    Constant Value: "error"

    EXTRA_EXCLUDE_SELF

    Added in API level 23
    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.

    Constant Value: "android.provider.extra.EXCLUDE_SELF"

    EXTRA_INFO

    Added in API level 19
    public static final String EXTRA_INFO

    Optional string included in a directory 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.

    Constant Value: "info"

    EXTRA_INITIAL_URI

    Added in API level 26
    public static final String EXTRA_INITIAL_URI

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

    Applicable to Intent with actions:

    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.

    Constant Value: "android.provider.extra.INITIAL_URI"

    EXTRA_LOADING

    Added in API level 19
    public static final String EXTRA_LOADING

    Optional boolean flag included in a directory 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.

    Constant Value: "loading"

    EXTRA_ORIENTATION

    Added in API level 24
    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.

    Constant Value: "android.provider.extra.ORIENTATION"

    EXTRA_PROMPT

    Added in API level 23
    public static final String EXTRA_PROMPT

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

    Constant Value: "android.provider.extra.PROMPT"

    METADATA_EXIF

    Added in API level 29
    public static final String METADATA_EXIF

    Get Exif information using DocumentsContract#getDocumentMetadata.

    Constant Value: "android:documentExif"

    METADATA_TREE_COUNT

    Added in API level 29
    public static final String METADATA_TREE_COUNT

    Get total count of all documents currently stored under the given directory tree. Only valid for Document.MIME_TYPE_DIR documents.

    Constant Value: "android:metadataTreeCount"

    METADATA_TREE_SIZE

    Added in API level 29
    public static final String METADATA_TREE_SIZE

    Get total size of all documents currently stored under the given directory tree. Only valid for Document.MIME_TYPE_DIR documents.

    Constant Value: "android:metadataTreeSize"

    METADATA_TYPES

    Added in API level 29
    public static final String METADATA_TYPES

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

    Constant Value: "android:documentMetadataTypes"

    PROVIDER_INTERFACE

    Added in API level 19
    public static final String PROVIDER_INTERFACE

    Intent action used to identify DocumentsProvider instances. This is used in the <intent-filter> of a <provider>.

    Constant Value: "android.content.action.DOCUMENTS_PROVIDER"

    QUERY_ARG_DISPLAY_NAME

    Added in API level 29
    public static final String QUERY_ARG_DISPLAY_NAME

    Key for 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".

    Constant Value: "android:query-arg-display-name"

    QUERY_ARG_EXCLUDE_MEDIA

    Added in API level 29
    public static final String QUERY_ARG_EXCLUDE_MEDIA

    Key for 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.

    Constant Value: "android:query-arg-exclude-media"

    QUERY_ARG_FILE_SIZE_OVER

    Added in API level 29
    public static final String QUERY_ARG_FILE_SIZE_OVER

    Key for DocumentsProvider to query the file size in bytes is larger than the value.

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

    QUERY_ARG_LAST_MODIFIED_AFTER

    Added in API level 29
    public static final String QUERY_ARG_LAST_MODIFIED_AFTER

    Key for 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.

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

    QUERY_ARG_MIME_TYPES

    Added in API level 29
    public static final String QUERY_ARG_MIME_TYPES

    Key for 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.

    Constant Value: "android:query-arg-mime-types"

    Public methods

    buildChildDocumentsUri

    Added in API level 19
    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 Document.

    Parameters
    authority String

    parentDocumentId String: the document to return children for, which must be a directory with MIME type of Document.MIME_TYPE_DIR.

    Returns
    Uri

    buildChildDocumentsUriUsingTree

    Added in API level 21
    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 Document.

    However, instead of directly accessing the target directory, the returned URI will leverage access granted through a subtree URI, typically returned by 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.

    Parameters
    treeUri Uri: the subtree to leverage to gain access to the target document. The target directory must be a descendant of this subtree.

    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 Document.MIME_TYPE_DIR.

    Returns
    Uri

    buildDocumentUri

    Added in API level 19
    public static Uri buildDocumentUri (String authority, 
                    String documentId)

    Build URI representing the target Document.COLUMN_DOCUMENT_ID in a document provider. When queried, a provider will return a single row with columns defined by Document.

    Parameters
    authority String

    documentId String

    Returns
    Uri

    buildDocumentUriUsingTree

    Added in API level 21
    public static Uri buildDocumentUriUsingTree (Uri treeUri, 
                    String documentId)

    Build URI representing the target Document.COLUMN_DOCUMENT_ID in a document provider. When queried, a provider will return a single row with columns defined by Document.

    However, instead of directly accessing the target document, the returned URI will leverage access granted through a subtree URI, typically returned by 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.

    Parameters
    treeUri Uri: the subtree to leverage to gain access to the target document. The target directory must be a descendant of this subtree.

    documentId String: the target document, which the caller may not have direct access to.

    Returns
    Uri

    buildRecentDocumentsUri

    Added in API level 19
    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 Document.

    Parameters
    authority String

    rootId String

    Returns
    Uri

    buildRootUri

    Added in API level 19
    public static Uri buildRootUri (String authority, 
                    String rootId)

    Build URI representing the given Root.COLUMN_ROOT_ID in a document provider.

    Parameters
    authority String

    rootId String

    Returns
    Uri

    See also:

    buildRootsUri

    Added in API level 19
    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 Root.

    Parameters
    authority String

    Returns
    Uri

    buildSearchDocumentsUri

    Added in API level 19
    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 Document.

    Parameters
    authority String

    rootId String

    query String

    Returns
    Uri

    buildTreeDocumentUri

    Added in API level 21
    public static Uri buildTreeDocumentUri (String authority, 
                    String documentId)

    Build URI representing access to descendant documents of the given Document.COLUMN_DOCUMENT_ID.

    Parameters
    authority String

    documentId String

    Returns
    Uri

    copyDocument

    Added in API level 24
    public static Uri copyDocument (ContentResolver content, 
                    Uri sourceDocumentUri, 
                    Uri targetParentDocumentUri)

    Copies the given document.

    Parameters
    content ContentResolver: This value cannot be null.

    sourceDocumentUri Uri: document with Document.FLAG_SUPPORTS_COPY This value cannot be null.

    targetParentDocumentUri Uri: document which will become a parent of the source document's copy. This value cannot be null.

    Returns
    Uri the copied document, or null if failed.

    Throws
    FileNotFoundException

    createDocument

    Added in API level 21
    public static Uri createDocument (ContentResolver content, 
                    Uri parentDocumentUri, 
                    String mimeType, 
                    String displayName)

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

    Parameters
    content ContentResolver: This value cannot be null.

    parentDocumentUri Uri: directory with Document.FLAG_DIR_SUPPORTS_CREATE This value cannot be null.

    mimeType String: MIME type of new document This value cannot be null.

    displayName String: name of new document This value cannot be null.

    Returns
    Uri newly created document, or null if failed

    Throws
    FileNotFoundException

    createWebLinkIntent

    Added in API level 26
    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 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();
         ...
       }
     }
     

    Parameters
    content ContentResolver: This value cannot be null.

    uri Uri: uri for the document to create a link to. This value cannot be null.

    options Bundle: Extra information for generating the link. This value may be null.

    Returns
    IntentSender an intent sender to obtain the web link, or null if the document is not linkable, or creating the intent sender failed.

    Throws
    FileNotFoundException

    deleteDocument

    Added in API level 19
    public static boolean deleteDocument (ContentResolver content, 
                    Uri documentUri)

    Delete the given document.

    Parameters
    content ContentResolver: This value cannot be null.

    documentUri Uri: document with Document.FLAG_SUPPORTS_DELETE This value cannot be null.

    Returns
    boolean if the document was deleted successfully.

    Throws
    FileNotFoundException

    ejectRoot

    Added in API level 26
    public static void ejectRoot (ContentResolver content, 
                    Uri rootUri)

    Ejects the given root. It throws IllegalStateException when ejection failed.

    Parameters
    content ContentResolver: This value cannot be null.

    rootUri Uri: root with Root.FLAG_SUPPORTS_EJECT to be ejected This value cannot be null.

    findDocumentPath

    Added in API level 26
    public static DocumentsContract.Path findDocumentPath (ContentResolver content, 
                    Uri treeUri)

    Finds the canonical path from the top of the document tree. The 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 Path.getRootId() of the return value returns null.

    Parameters
    content ContentResolver: This value cannot be null.

    treeUri Uri: treeUri of the document which path is requested. This value cannot be null.

    Returns
    DocumentsContract.Path the path of the document, or null if failed.

    Throws
    FileNotFoundException

    getDocumentId

    Added in API level 19
    public static String getDocumentId (Uri documentUri)

    Extract the Document.COLUMN_DOCUMENT_ID from the given URI.

    Parameters
    documentUri Uri

    Returns
    String

    getDocumentMetadata

    Added in API level 29
    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 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.

    Example:

    
         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);
         }
     

    Parameters
    content ContentResolver: This value cannot be null.

    documentUri Uri: a Document URI This value cannot be null.

    Returns
    Bundle a Bundle of Bundles. This value may be null.

    Throws
    FileNotFoundException

    getDocumentThumbnail

    Added in API level 19
    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.

    Parameters
    content ContentResolver: This value cannot be null.

    documentUri Uri: document to return thumbnail for, which must have Document.FLAG_SUPPORTS_THUMBNAIL set. This value cannot be null.

    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.

    signal CancellationSignal: signal used to indicate if caller is no longer interested in the thumbnail. This value may be null.

    Returns
    Bitmap decoded thumbnail, or null if problem was encountered.

    Throws
    FileNotFoundException

    getRootId

    Added in API level 19
    public static String getRootId (Uri rootUri)

    Extract the Root.COLUMN_ROOT_ID from the given URI.

    Parameters
    rootUri Uri

    Returns
    String

    getSearchDocumentsQuery

    Added in API level 19
    public static String getSearchDocumentsQuery (Uri searchDocumentsUri)

    Extract the search query from a URI built by buildSearchDocumentsUri(java.lang.String, java.lang.String, java.lang.String).

    Parameters
    searchDocumentsUri Uri

    Returns
    String

    getTreeDocumentId

    Added in API level 21
    public static String getTreeDocumentId (Uri documentUri)

    Extract the via Document.COLUMN_DOCUMENT_ID from the given URI.

    Parameters
    documentUri Uri

    Returns
    String

    isChildDocument

    Added in API level 29
    public static boolean isChildDocument (ContentResolver content, 
                    Uri parentDocumentUri, 
                    Uri childDocumentUri)

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

    Parameters
    content ContentResolver: This value cannot be null.

    parentDocumentUri Uri: parent to verify against. This value cannot be null.

    childDocumentUri Uri: child to verify. This value cannot be null.

    Returns
    boolean if given document is a descendant of the given parent.

    Throws
    FileNotFoundException

    isDocumentUri

    Added in API level 19
    public static boolean isDocumentUri (Context context, 
                    Uri uri)

    Test if the given URI represents a Document backed by a DocumentsProvider.

    Parameters
    context Context

    uri Uri: This value may be null.

    Returns
    boolean

    isRootUri

    Added in API level 29
    public static boolean isRootUri (Context context, 
                    Uri uri)

    Test if the given URI represents specific root backed by DocumentsProvider.

    Parameters
    context Context: This value cannot be null.

    uri Uri: This value may be null.

    Returns
    boolean

    isRootsUri

    Added in API level 29
    public static boolean isRootsUri (Context context, 
                    Uri uri)

    Test if the given URI represents all roots of the authority backed by DocumentsProvider.

    Parameters
    context Context: This value cannot be null.

    uri Uri: This value may be null.

    Returns
    boolean

    isTreeUri

    Added in API level 24
    public static boolean isTreeUri (Uri uri)

    Test if the given URI represents a Document tree.

    Parameters
    uri Uri

    Returns
    boolean

    moveDocument

    Added in API level 24
    public static Uri moveDocument (ContentResolver content, 
                    Uri sourceDocumentUri, 
                    Uri sourceParentDocumentUri, 
                    Uri targetParentDocumentUri)

    Moves the given document under a new parent.

    Parameters
    content ContentResolver: This value cannot be null.

    sourceDocumentUri Uri: document with Document.FLAG_SUPPORTS_MOVE This value cannot be null.

    sourceParentDocumentUri Uri: parent document of the document to move. This value cannot be null.

    targetParentDocumentUri Uri: document which will become a new parent of the source document. This value cannot be null.

    Returns
    Uri the moved document, or null if failed.

    Throws
    FileNotFoundException

    removeDocument

    Added in API level 24
    public static boolean removeDocument (ContentResolver content, 
                    Uri documentUri, 
                    Uri parentDocumentUri)

    Removes the given document from a parent directory.

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

    Parameters
    content ContentResolver: This value cannot be null.

    documentUri Uri: document with Document.FLAG_SUPPORTS_REMOVE This value cannot be null.

    parentDocumentUri Uri: parent document of the document to remove. This value cannot be null.

    Returns
    boolean true if the document was removed successfully.

    Throws
    FileNotFoundException

    renameDocument

    Added in API level 21
    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 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.

    Parameters
    content ContentResolver: This value cannot be null.

    documentUri Uri: document with Document.FLAG_SUPPORTS_RENAME This value cannot be null.

    displayName String: updated name for document This value cannot be null.

    Returns
    Uri the existing or new document after the rename, or null if failed.

    Throws
    FileNotFoundException