Android.Provider.DocumentsProvider Class
Base class for a document provider.

See Also: DocumentsProvider Members

Syntax

[Android.Runtime.Register("android/provider/DocumentsProvider", DoNotGenerateAcw=true)]
public abstract class DocumentsProvider : Android.Content.ContentProvider

Remarks

Base class for a document provider. A document provider offers read and write access to durable files, such as files stored on a local disk, or files in a cloud storage service. To create a document provider, extend this class, implement the abstract methods, and add it to your manifest like this:

xml Example

<manifest>
    ...
    <application>
        ...
        <provider
            android:name="com.example.MyCloudProvider"
            android:authorities="com.example.mycloudprovider"
            android:exported="true"
            android:grantUriPermissions="true"
            android:permission="android.permission.MANAGE_DOCUMENTS"
            android:enabled="@bool/isAtLeastKitKat">
            <intent-filter>
                <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
            </intent-filter>
        </provider>
        ...
    </application>
</manifest>

Documents

Roots

When defining your provider, you must protect it with NoType:android/Manifest$permission;Href=../../../reference/android/Manifest.permission.html#MANAGE_DOCUMENTS, which is a permission only the system can obtain. Applications cannot use a documents provider directly; they must go through Android.Content.Intent.ActionOpenDocument or Android.Content.Intent.ActionCreateDocument which requires a user to actively navigate and select documents. When a user selects documents through that UI, the system issues narrow URI permission grants to the requesting application.

A document can be either an openable stream (with a specific MIME type), or a directory containing additional documents (with the NoType:android/provider/DocumentsContract$Document;Href=../../../reference/android/provider/DocumentsContract.Document.html#MIME_TYPE_DIR MIME type). Each directory represents the top of a subtree containing zero or more documents, which can recursively contain even more documents and directories.

Each document can have different capabilities, as described by NoType:android/provider/DocumentsContract$Document;Href=../../../reference/android/provider/DocumentsContract.Document.html#COLUMN_FLAGS. For example, if a document can be represented as a thumbnail, your provider can set NoType:android/provider/DocumentsContract$Document;Href=../../../reference/android/provider/DocumentsContract.Document.html#FLAG_SUPPORTS_THUMBNAIL and implement DocumentsProvider.OpenDocumentThumbnail(string, Android.Graphics.Point, Android.Graphics.Point) to return that thumbnail.

Each document under a provider is uniquely referenced by its NoType:android/provider/DocumentsContract$Document;Href=../../../reference/android/provider/DocumentsContract.Document.html#COLUMN_DOCUMENT_ID, which must not change once returned. A single document can be included in multiple directories when responding to DocumentsProvider.QueryChildDocuments(string, System.String[], System.String[]). For example, a provider might surface a single photo in multiple locations: once in a directory of geographic locations, and again in a directory of dates.

All documents are surfaced through one or more "roots." Each root represents the top of a document tree that a user can navigate. For example, a root could represent an account or a physical storage device. Similar to documents, each root can have capabilities expressed through NoType:android/provider/DocumentsContract$Root;Href=../../../reference/android/provider/DocumentsContract.Root.html#COLUMN_FLAGS.

See Also

[Android Documentation]

Requirements

Namespace: Android.Provider
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0