DocumentsContract.Document


public static final class DocumentsContract.Document
extends Object

java.lang.Object
   ↳ android.provider.DocumentsContract.Document


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

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

All columns are read-only to client applications.

Summary

Constants

String COLUMN_DISPLAY_NAME

Display name of a document, used as the primary title displayed to a user.

String COLUMN_DOCUMENT_ID

Unique ID of a document.

String COLUMN_FLAGS

Flags that apply to a document.

String COLUMN_ICON

Specific icon resource ID for a document.

String COLUMN_LAST_MODIFIED

Timestamp when a document was last modified, in milliseconds since January 1, 1970 00:00:00.0 UTC.

String COLUMN_MIME_TYPE

Concrete MIME type of a document.

String COLUMN_SIZE

Size of a document, in bytes, or null if unknown.

String COLUMN_SUMMARY

Summary of a document, which may be shown to a user.

int FLAG_DIR_BLOCKS_OPEN_DOCUMENT_TREE

Flag indicating that a document is a directory that wants to block itself from being selected when the user launches an Intent.ACTION_OPEN_DOCUMENT_TREE intent.

int FLAG_DIR_PREFERS_GRID

Flag indicating that a directory prefers its contents be shown in a larger format grid.

int FLAG_DIR_PREFERS_LAST_MODIFIED

Flag indicating that a directory prefers its contents be sorted by COLUMN_LAST_MODIFIED.

int FLAG_DIR_SUPPORTS_CREATE

Flag indicating that a document is a directory that supports creation of new files within it.

int FLAG_PARTIAL

Flag indicating that a document is not complete, likely its contents are being downloaded.

int FLAG_SUPPORTS_COPY

Flag indicating that a document can be copied to another location within the same document provider.

int FLAG_SUPPORTS_DELETE

Flag indicating that a document is deletable.

int FLAG_SUPPORTS_METADATA

Flag indicating that a document has available metadata that can be read using DocumentsContract#getDocumentMetadata

int FLAG_SUPPORTS_MOVE

Flag indicating that a document can be moved to another location within the same document provider.

int FLAG_SUPPORTS_REMOVE

Flag indicating that a document can be removed from a parent.

int FLAG_SUPPORTS_RENAME

Flag indicating that a document can be renamed.

int FLAG_SUPPORTS_SETTINGS

Flag indicating that a document has settings that can be configured by user.

int FLAG_SUPPORTS_THUMBNAIL

Flag indicating that a document can be represented as a thumbnail.

int FLAG_SUPPORTS_WRITE

Flag indicating that a document supports writing.

int FLAG_VIRTUAL_DOCUMENT

Flag indicating that a document is virtual, and doesn't have byte representation in the MIME type specified as COLUMN_MIME_TYPE.

int FLAG_WEB_LINKABLE

Flag indicating that a Web link can be obtained for the document.

String MIME_TYPE_DIR

MIME type of a document which is a directory that may contain additional documents.

Inherited methods

Constants

COLUMN_DISPLAY_NAME

Added in API level 19
public static final String COLUMN_DISPLAY_NAME

Display name of a document, used as the primary title displayed to a user. This column is required.

Type: STRING

Constant Value: "_display_name"

COLUMN_DOCUMENT_ID

Added in API level 19
public static final String COLUMN_DOCUMENT_ID

Unique ID of a document. This ID is both provided by and interpreted by a DocumentsProvider, and should be treated as an opaque value by client applications. This column is required.

Each document must have a unique ID within a provider, but that single document may be included as a child of multiple directories.

A provider must always return durable IDs, since they will be used to issue long-term URI permission grants when an application interacts with Intent.ACTION_OPEN_DOCUMENT and Intent.ACTION_CREATE_DOCUMENT.

Type: STRING

Constant Value: "document_id"

COLUMN_ICON

Added in API level 19
public static final String COLUMN_ICON

Specific icon resource ID for a document. This column is optional, and may be null to use a platform-provided default icon based on COLUMN_MIME_TYPE.

Type: INTEGER (int)

Constant Value: "icon"

COLUMN_LAST_MODIFIED

Added in API level 19
public static final String COLUMN_LAST_MODIFIED

Timestamp when a document was last modified, in milliseconds since January 1, 1970 00:00:00.0 UTC. This column is required, and may be null if unknown. A DocumentsProvider can update this field using events from OnCloseListener or other reliable ParcelFileDescriptor transports.

Type: INTEGER (long)

Constant Value: "last_modified"

COLUMN_MIME_TYPE

Added in API level 19
public static final String COLUMN_MIME_TYPE

Concrete MIME type of a document. For example, "image/png" or "application/pdf" for openable files. A document can also be a directory containing additional documents, which is represented with the MIME_TYPE_DIR MIME type. This column is required.

Type: STRING

See also:

Constant Value: "mime_type"

COLUMN_SIZE

Added in API level 19
public static final String COLUMN_SIZE

Size of a document, in bytes, or null if unknown. This column is required.

Type: INTEGER (long)

Constant Value: "_size"

COLUMN_SUMMARY

Added in API level 19
public static final String COLUMN_SUMMARY

Summary of a document, which may be shown to a user. This column is optional, and may be null.

Type: STRING

Constant Value: "summary"

FLAG_DIR_BLOCKS_OPEN_DOCUMENT_TREE

Added in API level 30
public static final int FLAG_DIR_BLOCKS_OPEN_DOCUMENT_TREE

Flag indicating that a document is a directory that wants to block itself from being selected when the user launches an Intent.ACTION_OPEN_DOCUMENT_TREE intent. Individual files can still be selected when launched via other intents like Intent.ACTION_OPEN_DOCUMENT and Intent.ACTION_GET_CONTENT. Only valid when COLUMN_MIME_TYPE is MIME_TYPE_DIR.

Note that this flag only applies to the single directory to which it is applied. It does not block the user from selecting either a parent or child directory during an Intent.ACTION_OPEN_DOCUMENT_TREE request. In particular, the only way to guarantee that a specific directory can never be granted via an Intent.ACTION_OPEN_DOCUMENT_TREE request is to ensure that both it and all of its parent directories have set this flag.

Constant Value: 32768 (0x00008000)

FLAG_DIR_PREFERS_GRID

Added in API level 19
public static final int FLAG_DIR_PREFERS_GRID

Flag indicating that a directory prefers its contents be shown in a larger format grid. Usually suitable when a directory contains mostly pictures. Only valid when COLUMN_MIME_TYPE is MIME_TYPE_DIR.

See also:

Constant Value: 16 (0x00000010)

FLAG_DIR_PREFERS_LAST_MODIFIED

Added in API level 19
public static final int FLAG_DIR_PREFERS_LAST_MODIFIED

Flag indicating that a directory prefers its contents be sorted by COLUMN_LAST_MODIFIED. Only valid when COLUMN_MIME_TYPE is MIME_TYPE_DIR.

See also:

Constant Value: 32 (0x00000020)

FLAG_DIR_SUPPORTS_CREATE

Added in API level 19
public static final int FLAG_DIR_SUPPORTS_CREATE

Flag indicating that a document is a directory that supports creation of new files within it. Only valid when COLUMN_MIME_TYPE is MIME_TYPE_DIR.

Constant Value: 8 (0x00000008)

FLAG_PARTIAL

Added in API level 29
public static final int FLAG_PARTIAL

Flag indicating that a document is not complete, likely its contents are being downloaded. Partial files cannot be opened, copied, moved in the UI. But they can be deleted and retried if they represent a failed download.

See also:

Constant Value: 8192 (0x00002000)

FLAG_SUPPORTS_COPY

Added in API level 24
public static final int FLAG_SUPPORTS_COPY

Flag indicating that a document can be copied to another location within the same document provider.

Constant Value: 128 (0x00000080)

FLAG_SUPPORTS_DELETE

Added in API level 19
public static final int FLAG_SUPPORTS_DELETE

Flag indicating that a document is deletable.

Constant Value: 4 (0x00000004)

FLAG_SUPPORTS_METADATA

Added in API level 29
public static final int FLAG_SUPPORTS_METADATA

Flag indicating that a document has available metadata that can be read using DocumentsContract#getDocumentMetadata

Constant Value: 16384 (0x00004000)

FLAG_SUPPORTS_MOVE

Added in API level 24
public static final int FLAG_SUPPORTS_MOVE

Flag indicating that a document can be moved to another location within the same document provider.

Constant Value: 256 (0x00000100)

FLAG_SUPPORTS_REMOVE

Added in API level 24
public static final int FLAG_SUPPORTS_REMOVE

Flag indicating that a document can be removed from a parent.

Constant Value: 1024 (0x00000400)

FLAG_SUPPORTS_RENAME

Added in API level 21
public static final int FLAG_SUPPORTS_RENAME

Flag indicating that a document can be renamed.

Constant Value: 64 (0x00000040)

FLAG_SUPPORTS_SETTINGS

Added in API level 26
public static final int FLAG_SUPPORTS_SETTINGS

Flag indicating that a document has settings that can be configured by user.

Constant Value: 2048 (0x00000800)

FLAG_SUPPORTS_THUMBNAIL

Added in API level 19
public static final int FLAG_SUPPORTS_THUMBNAIL

Flag indicating that a document can be represented as a thumbnail.

Constant Value: 1 (0x00000001)

FLAG_SUPPORTS_WRITE

Added in API level 19
public static final int FLAG_SUPPORTS_WRITE

Flag indicating that a document supports writing.

When a document is opened with Intent.ACTION_OPEN_DOCUMENT, the calling application is granted both Intent.FLAG_GRANT_READ_URI_PERMISSION and Intent.FLAG_GRANT_WRITE_URI_PERMISSION. However, the actual writability of a document may change over time, for example due to remote access changes. This flag indicates that a document client can expect ContentResolver.openOutputStream(Uri) to succeed.

See also:

Constant Value: 2 (0x00000002)

FLAG_VIRTUAL_DOCUMENT

Added in API level 24
public static final int FLAG_VIRTUAL_DOCUMENT

Flag indicating that a document is virtual, and doesn't have byte representation in the MIME type specified as COLUMN_MIME_TYPE.

Virtual documents must have at least one alternative streamable format via DocumentsProvider.openTypedDocument

Constant Value: 512 (0x00000200)

FLAG_WEB_LINKABLE

Added in API level 26
public static final int FLAG_WEB_LINKABLE

Flag indicating that a Web link can be obtained for the document.

Constant Value: 4096 (0x00001000)

MIME_TYPE_DIR

Added in API level 19
public static final String MIME_TYPE_DIR

MIME type of a document which is a directory that may contain additional documents.

See also:

Constant Value: "vnd.android.document/directory"