DocumentsContractCompat
public final class DocumentsContractCompat
Helper for accessing features in DocumentsContract.
Summary
Nested types |
|---|
public final class DocumentsContractCompat.DocumentCompatHelper for accessing features in |
Public methods |
|
|---|---|
static @Nullable Uri |
buildChildDocumentsUri(Build URI representing the children of the target directory in a document provider. |
static @Nullable Uri |
buildChildDocumentsUriUsingTree(Build URI representing the children of the target directory in a document provider. |
static @Nullable Uri |
buildDocumentUri(@NonNull String authority, @NonNull String documentId)Build URI representing the target |
static @Nullable Uri |
buildDocumentUriUsingTree(@NonNull Uri treeUri, @NonNull String documentId)Build URI representing the target |
static @Nullable Uri |
buildTreeDocumentUri(@NonNull String authority, @NonNull String documentId)Build URI representing access to descendant documents of the given |
static @Nullable Uri |
createDocument(Create a new document with given MIME type and display name. |
static @Nullable String |
getDocumentId(@NonNull Uri documentUri)Extract the |
static @Nullable String |
getTreeDocumentId(@NonNull Uri documentUri)Extract the via |
static boolean |
isDocumentUri(@NonNull Context context, @Nullable Uri uri)Checks if the given URI represents a |
static boolean |
Checks if the given URI represents a |
static boolean |
removeDocument(Removes the given document from a parent directory. |
static @Nullable Uri |
renameDocument(Change the display name of an existing document. |
Public methods
buildChildDocumentsUri
public static @Nullable Uri buildChildDocumentsUri(
@NonNull String authority,
@Nullable 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.
| See also | |
|---|---|
buildChildDocumentsUri |
buildChildDocumentsUriUsingTree
public static @Nullable Uri buildChildDocumentsUriUsingTree(
@NonNull Uri treeUri,
@NonNull 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.
| See also | |
|---|---|
buildChildDocumentsUriUsingTree |
buildDocumentUri
public static @Nullable Uri buildDocumentUri(@NonNull String authority, @NonNull String documentId)
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
public static @Nullable Uri buildDocumentUriUsingTree(@NonNull Uri treeUri, @NonNull String documentId)
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
public static @Nullable Uri buildTreeDocumentUri(@NonNull String authority, @NonNull String documentId)
Build URI representing access to descendant documents of the given COLUMN_DOCUMENT_ID.
| See also | |
|---|---|
buildTreeDocumentUri |
createDocument
public static @Nullable Uri createDocument(
@NonNull ContentResolver content,
@NonNull Uri parentDocumentUri,
@NonNull String mimeType,
@NonNull String displayName
)
Create a new document with given MIME type and display name.
| Parameters | |
|---|---|
@NonNull ContentResolver content |
the resolver to use to create the document. |
@NonNull Uri parentDocumentUri |
directory with |
@NonNull String mimeType |
MIME type of new document |
@NonNull String displayName |
name of new document |
getDocumentId
public static @Nullable String getDocumentId(@NonNull Uri documentUri)
Extract the COLUMN_DOCUMENT_ID from the given URI.
| See also | |
|---|---|
getDocumentId |
getTreeDocumentId
public static @Nullable String getTreeDocumentId(@NonNull Uri documentUri)
Extract the via COLUMN_DOCUMENT_ID from the given URI.
| See also | |
|---|---|
getTreeDocumentId |
isDocumentUri
public static boolean isDocumentUri(@NonNull Context context, @Nullable Uri uri)
Checks if the given URI represents a Document backed by a DocumentsProvider.
| See also | |
|---|---|
isDocumentUri |
isTreeUri
public static boolean isTreeUri(@NonNull Uri uri)
Checks if the given URI represents a Document tree.
| See also | |
|---|---|
isTreeUri |
removeDocument
public static boolean removeDocument(
@NonNull ContentResolver content,
@NonNull Uri documentUri,
@NonNull Uri parentDocumentUri
)
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 | |
|---|---|
@NonNull ContentResolver content |
the resolver to use to remove the document. |
@NonNull Uri documentUri |
document with |
@NonNull Uri parentDocumentUri |
parent document of the document to remove. |
| Returns | |
|---|---|
boolean |
true if the document was removed successfully. |
renameDocument
public static @Nullable Uri renameDocument(
@NonNull ContentResolver content,
@NonNull Uri documentUri,
@NonNull String displayName
)
Change the display name of an existing document.
| See also | |
|---|---|
renameDocument |