DocumentsContractCompat

Added in 1.7.0

class DocumentsContractCompat


Helper for accessing features in DocumentsContract.

Summary

Nested types

Helper for accessing features in DocumentsContract.Document.

Public functions

java-static Uri?
buildChildDocumentsUri(authority: String, parentDocumentId: String?)

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

java-static Uri?
buildChildDocumentsUriUsingTree(treeUri: Uri, parentDocumentId: String)

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

java-static Uri?
buildDocumentUri(authority: String, documentId: String)

Build URI representing the target COLUMN_DOCUMENT_ID in a document provider.

java-static Uri?
buildDocumentUriUsingTree(treeUri: Uri, documentId: String)

Build URI representing the target COLUMN_DOCUMENT_ID in a document provider.

java-static Uri?
buildTreeDocumentUri(authority: String, documentId: String)

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

java-static Uri?
createDocument(
    content: ContentResolver,
    parentDocumentUri: Uri,
    mimeType: String,
    displayName: String
)

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

java-static String?
getDocumentId(documentUri: Uri)

Extract the COLUMN_DOCUMENT_ID from the given URI.

java-static String?
getTreeDocumentId(documentUri: Uri)

Extract the via COLUMN_DOCUMENT_ID from the given URI.

java-static Boolean
isDocumentUri(context: Context, uri: Uri?)

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

java-static Boolean
isTreeUri(uri: Uri)

Checks if the given URI represents a Document tree.

java-static Boolean
removeDocument(
    content: ContentResolver,
    documentUri: Uri,
    parentDocumentUri: Uri
)

Removes the given document from a parent directory.

java-static Uri?
renameDocument(
    content: ContentResolver,
    documentUri: Uri,
    displayName: String
)

Change the display name of an existing document.

Public functions

buildChildDocumentsUri

Added in 1.7.0
java-static fun buildChildDocumentsUri(authority: String, parentDocumentId: String?): Uri?

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.

buildChildDocumentsUriUsingTree

Added in 1.7.0
java-static fun buildChildDocumentsUriUsingTree(treeUri: Uri, parentDocumentId: String): Uri?

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.

buildDocumentUri

Added in 1.7.0
java-static fun buildDocumentUri(authority: String, documentId: String): Uri?

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

See also
buildDocumentUri

buildDocumentUriUsingTree

Added in 1.7.0
java-static fun buildDocumentUriUsingTree(treeUri: Uri, documentId: String): Uri?

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

buildTreeDocumentUri

Added in 1.7.0
java-static fun buildTreeDocumentUri(authority: String, documentId: String): Uri?

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

createDocument

Added in 1.7.0
java-static fun createDocument(
    content: ContentResolver,
    parentDocumentUri: Uri,
    mimeType: String,
    displayName: String
): Uri?

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

Parameters
content: ContentResolver

the resolver to use to create the document.

parentDocumentUri: Uri

directory with FLAG_DIR_SUPPORTS_CREATE

mimeType: String

MIME type of new document

displayName: String

name of new document

Returns
Uri?

newly created document, or null if failed

getDocumentId

Added in 1.7.0
java-static fun getDocumentId(documentUri: Uri): String?

Extract the COLUMN_DOCUMENT_ID from the given URI.

See also
getDocumentId

getTreeDocumentId

Added in 1.7.0
java-static fun getTreeDocumentId(documentUri: Uri): String?

Extract the via COLUMN_DOCUMENT_ID from the given URI.

isDocumentUri

Added in 1.7.0
java-static fun isDocumentUri(context: Context, uri: Uri?): Boolean

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

See also
isDocumentUri

isTreeUri

Added in 1.7.0
java-static fun isTreeUri(uri: Uri): Boolean

Checks if the given URI represents a Document tree.

See also
isTreeUri

removeDocument

Added in 1.7.0
java-static fun removeDocument(
    content: ContentResolver,
    documentUri: Uri,
    parentDocumentUri: Uri
): Boolean

Removes the given document from a parent directory. In contrast to deleteDocument it requires specifying the parent. This method is especially useful if the document can be in multiple parents. This method was only added in N. On versions prior to this, this method calls through to deleteDocument.

Parameters
content: ContentResolver

the resolver to use to remove the document.

documentUri: Uri

document with FLAG_SUPPORTS_REMOVE

parentDocumentUri: Uri

parent document of the document to remove.

Returns
Boolean

true if the document was removed successfully.

renameDocument

Added in 1.7.0
java-static fun renameDocument(
    content: ContentResolver,
    documentUri: Uri,
    displayName: String
): Uri?

Change the display name of an existing document.

See also
renameDocument