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

Column indicating the synchronization state of the document's contents represented as a bitmask, null if not provided.

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

The relative path of the original location of a trashed 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 can be restored.

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 can be trashed.

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.

static Int

Flag indicating that the document's contents are available locally.

static Int

Flag indicating that the last download attempt resulted in an error.

static Int

Flag indicating that a download of remote changes is currently in progress.

static Int

Flag indicating that the local version of the document has changes that require an upload.

static Int

Flag indicating that the last upload attempt resulted in an error.

static Int

Flag indicating that an upload of local changes is currently in progress.

Constants

COLUMN_CONTENT_SYNC_STATE_FLAGS

Added in API level 19
static val COLUMN_CONTENT_SYNC_STATE_FLAGS: String

Column indicating the synchronization state of the document's contents represented as a bitmask, null if not provided. This is an optional column. Type: Integer (int)

Value: "content_sync_state_flags"

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_ORIGINAL_RELATIVE_PATH

Added in API level 19
static val COLUMN_ORIGINAL_RELATIVE_PATH: String

The relative path of the original location of a trashed document. This column is only valid for trashed documents.

Type: STRING

Value: "original_relative_path"

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_RESTORE

Added in API level 19
static val FLAG_SUPPORTS_RESTORE: Int

Flag indicating that a document can be restored. Only trashed documents can be restored

Value: 131072

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_TRASH

Added in API level 19
static val FLAG_SUPPORTS_TRASH: Int

Flag indicating that a document can be trashed.

Value: 65536

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"

SYNC_STATE_FLAG_AVAILABLE_LOCALLY

Added in API level 19
static val SYNC_STATE_FLAG_AVAILABLE_LOCALLY: Int

Flag indicating that the document's contents are available locally. When the device does not have internet connection, certain document operations may be disabled, see Root.FLAG_LIMITED_FUNCTIONALITY_WHEN_OFFLINE for more details.

Value: 1

SYNC_STATE_FLAG_DOWNLOAD_ERROR

Added in API level 19
static val SYNC_STATE_FLAG_DOWNLOAD_ERROR: Int

Flag indicating that the last download attempt resulted in an error.

Value: 32

SYNC_STATE_FLAG_DOWNLOAD_PROGRESS

Added in API level 19
static val SYNC_STATE_FLAG_DOWNLOAD_PROGRESS: Int

Flag indicating that a download of remote changes is currently in progress.

Value: 8

SYNC_STATE_FLAG_LOCAL_CHANGES

Added in API level 19
static val SYNC_STATE_FLAG_LOCAL_CHANGES: Int

Flag indicating that the local version of the document has changes that require an upload. This flag is only meaningful if SYNC_STATE_FLAG_AVAILABLE_LOCALLY is also set.

Value: 2

SYNC_STATE_FLAG_UPLOAD_ERROR

Added in API level 19
static val SYNC_STATE_FLAG_UPLOAD_ERROR: Int

Flag indicating that the last upload attempt resulted in an error. This flag typically implies SYNC_STATE_FLAG_AVAILABLE_LOCALLY and SYNC_STATE_FLAG_LOCAL_CHANGES are also set.

Value: 16

SYNC_STATE_FLAG_UPLOAD_PROGRESS

Added in API level 19
static val SYNC_STATE_FLAG_UPLOAD_PROGRESS: Int

Flag indicating that an upload of local changes is currently in progress. This flag typically implies SYNC_STATE_FLAG_AVAILABLE_LOCALLY and SYNC_STATE_FLAG_LOCAL_CHANGES are also set.

Value: 4