Added in API level 19

Document


class Document
kotlin.Any
   ↳ 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
static String

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

static String

Unique ID of a document.

static String

Flags that apply to a document.

static String

Specific icon resource ID for a document.

static String

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

static String

Concrete MIME type of a document.

static String

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

static String

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

static Int

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.

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

Flag indicating that a document is deletable.

static Int

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

static Int

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

static Int

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

static Int

Flag indicating that a document can be renamed.

static Int

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

static Int

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

static Int

Flag indicating that a document supports writing.

static Int

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

static Int

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

static String

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

Constants

COLUMN_DISPLAY_NAME

Added in API level 19
static val COLUMN_DISPLAY_NAME: String

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

Type: STRING

Value: "_display_name"

COLUMN_DOCUMENT_ID

Added in API level 19
static val COLUMN_DOCUMENT_ID: String

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

Value: "document_id"

COLUMN_ICON

Added in API level 19
static val COLUMN_ICON: String

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)

Value: "icon"

COLUMN_LAST_MODIFIED

Added in API level 19
static val COLUMN_LAST_MODIFIED: String

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)

Value: "last_modified"

COLUMN_MIME_TYPE

Added in API level 19
static val COLUMN_MIME_TYPE: String

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

Value: "mime_type"

See Also

COLUMN_SIZE

Added in API level 19
static val COLUMN_SIZE: String

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

Type: INTEGER (long)

Value: "_size"

COLUMN_SUMMARY

Added in API level 19
static val COLUMN_SUMMARY: String

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

Type: STRING

Value: "summary"

FLAG_DIR_BLOCKS_OPEN_DOCUMENT_TREE

Added in API level 30
static val FLAG_DIR_BLOCKS_OPEN_DOCUMENT_TREE: Int

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.

Value: 32768

FLAG_DIR_PREFERS_GRID

Added in API level 19
static val FLAG_DIR_PREFERS_GRID: Int

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.

Value: 16

See Also

FLAG_DIR_PREFERS_LAST_MODIFIED

Added in API level 19
static val FLAG_DIR_PREFERS_LAST_MODIFIED: Int

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

Value: 32

See Also

FLAG_DIR_SUPPORTS_CREATE

Added in API level 19
static val FLAG_DIR_SUPPORTS_CREATE: Int

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.

Value: 8

FLAG_PARTIAL

Added in API level 29
static val FLAG_PARTIAL: Int

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.

Value: 8192

See Also

FLAG_SUPPORTS_COPY

Added in API level 24
static val FLAG_SUPPORTS_COPY: Int

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

Value: 128

FLAG_SUPPORTS_DELETE

Added in API level 19
static val FLAG_SUPPORTS_DELETE: Int

Flag indicating that a document is deletable.

Value: 4

FLAG_SUPPORTS_METADATA

Added in API level 29
static val FLAG_SUPPORTS_METADATA: Int

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

Value: 16384

FLAG_SUPPORTS_MOVE

Added in API level 24
static val FLAG_SUPPORTS_MOVE: Int

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

Value: 256

FLAG_SUPPORTS_REMOVE

Added in API level 24
static val FLAG_SUPPORTS_REMOVE: Int

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

Value: 1024

FLAG_SUPPORTS_RENAME

Added in API level 21
static val FLAG_SUPPORTS_RENAME: Int

Flag indicating that a document can be renamed.

Value: 64

FLAG_SUPPORTS_SETTINGS

Added in API level 26
static val FLAG_SUPPORTS_SETTINGS: Int

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

Value: 2048

FLAG_SUPPORTS_THUMBNAIL

Added in API level 19
static val FLAG_SUPPORTS_THUMBNAIL: Int

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

Value: 1

FLAG_SUPPORTS_WRITE

Added in API level 19
static val FLAG_SUPPORTS_WRITE: Int

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.

Value: 2

See Also

FLAG_VIRTUAL_DOCUMENT

Added in API level 24
static val FLAG_VIRTUAL_DOCUMENT: Int

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

Value: 512

FLAG_WEB_LINKABLE

Added in API level 26
static val FLAG_WEB_LINKABLE: Int

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

Value: 4096

MIME_TYPE_DIR

Added in API level 19
static val MIME_TYPE_DIR: String

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

Value: "vnd.android.document/directory"