Compartilhar via


DocumentsProvider Class

Definition

Base class for a document provider.

[Android.Runtime.Register("android/provider/DocumentsProvider", DoNotGenerateAcw=true)]
public abstract class DocumentsProvider : Android.Content.ContentProvider
[<Android.Runtime.Register("android/provider/DocumentsProvider", DoNotGenerateAcw=true)>]
type DocumentsProvider = class
    inherit ContentProvider
Inheritance
DocumentsProvider
Attributes

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:

&lt;manifest&gt;
               ...
               &lt;application&gt;
                   ...
                   &lt;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"&gt;
                       &lt;intent-filter&gt;
                           &lt;action android:name="android.content.action.DOCUMENTS_PROVIDER" /&gt;
                       &lt;/intent-filter&gt;
                   &lt;/provider&gt;
                   ...
               &lt;/application&gt;
            &lt;/manifest&gt;

When defining your provider, you must protect it with android.Manifest.permission#MANAGE_DOCUMENTS, which is a permission only the system can obtain. Applications cannot use a documents provider directly; they must go through Intent#ACTION_OPEN_DOCUMENT or Intent#ACTION_CREATE_DOCUMENT 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.

<h3>Documents</h3>

A document can be either an openable stream (with a specific MIME type), or a directory containing additional documents (with the Document#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 Document#COLUMN_FLAGS. For example, if a document can be represented as a thumbnail, your provider can set Document#FLAG_SUPPORTS_THUMBNAIL and implement #openDocumentThumbnail(String, Point, CancellationSignal) to return that thumbnail.

Each document under a provider is uniquely referenced by its Document#COLUMN_DOCUMENT_ID, which must not change once returned. A single document can be included in multiple directories when responding to #queryChildDocuments(String, String[], 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.

<h3>Roots</h3>

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 Root#COLUMN_FLAGS.

Java documentation for android.provider.DocumentsProvider.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

DocumentsProvider()
DocumentsProvider(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

CallingAttributionSource

Gets the attribution source of the calling app.

(Inherited from ContentProvider)
CallingAttributionTag

Return the attribution tag of the caller that initiated the request being processed on the current thread.

(Inherited from ContentProvider)
CallingPackage

Return the package name of the caller that initiated the request being processed on the current thread.

(Inherited from ContentProvider)
CallingPackageUnchecked

Return the package name of the caller that initiated the request being processed on the current thread.

(Inherited from ContentProvider)
Class

Returns the runtime class of this Object.

(Inherited from Object)
Context

Retrieves the Context this provider is running in.

(Inherited from ContentProvider)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsTemporary

Returns true if this instance is a temporary content provider.

(Inherited from ContentProvider)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ReadPermission
Obsolete.

Return the name of the permission required for read-only access to this content provider. -or- Change the permission required to read data from the content provider.

(Inherited from ContentProvider)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

WritePermission
Obsolete.

Return the name of the permission required for read/write access to this content provider. -or- Change the permission required to read and write data in the content provider.

(Inherited from ContentProvider)

Methods

ApplyBatch(IList<ContentProviderOperation>)

Override this to handle requests to perform a batch of operations, or the default implementation will iterate over the operations and call ContentProviderOperation#apply on each of them.

(Inherited from ContentProvider)
ApplyBatch(String, IList<ContentProviderOperation>)

Override this to handle requests to perform a batch of operations, or the default implementation will iterate over the operations and call ContentProviderOperation#apply on each of them.

(Inherited from ContentProvider)
AttachInfo(Context, ProviderInfo)

After being instantiated, this is called to tell the content provider about itself.

(Inherited from ContentProvider)
BulkInsert(Uri, ContentValues[])

Override this to handle requests to insert a set of new rows, or the default implementation will iterate over the values and call #insert on each of them.

(Inherited from ContentProvider)
Call(String, String, Bundle)

Call a provider-defined method.

(Inherited from ContentProvider)
Call(String, String, String, Bundle)

Call a provider-defined method.

(Inherited from ContentProvider)
Canonicalize(Uri)

Implement this to support canonicalization of URIs that refer to your content provider.

(Inherited from ContentProvider)
ClearCallingIdentity()

Reset the identity of the incoming IPC on the current thread.

(Inherited from ContentProvider)
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CopyDocument(String, String)

Copy the requested document or a document tree.

CreateDocument(String, String, String)

Create a new document and return its newly generated Document#COLUMN_DOCUMENT_ID.

CreateWebLinkIntent(String, Bundle)

Creates an intent sender for a web link, if the document is web linkable.

Delete(Uri, Bundle)

Implement this to handle requests to delete one or more rows.

(Inherited from ContentProvider)
Delete(Uri, String, String[])

Implementation is provided by the parent class.

DeleteDocument(String)

Delete the requested document.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Dump(FileDescriptor, PrintWriter, String[])

Print the Provider's state into the given stream.

(Inherited from ContentProvider)
DumpAsync(FileDescriptor, PrintWriter, String[]) (Inherited from ContentProvider)
EjectRoot(String)

Ejects the root.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FindDocumentPath(String, String)

Finds the canonical path for the requested document.

GetDocumentMetadata(String)

Returns metadata associated with the document.

GetDocumentStreamTypes(String, String)

Return a list of streamable MIME types matching the filter, which can be passed to #openTypedDocument(String, String, Bundle, CancellationSignal).

GetDocumentType(String)

Return concrete MIME type of the requested document.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetPathPermissions()

Return the path-based permissions required for read and/or write access to this content provider.

(Inherited from ContentProvider)
GetStreamTypes(Uri, String)

Called by a client to determine the types of data streams that this content provider supports for the given URI.

(Inherited from ContentProvider)
GetType(Uri)

Implementation is provided by the parent class.

GetTypeAnonymous(Uri)

An unrestricted version of getType, which does not reveal sensitive information

GetTypeAnonymous(Uri)

Implement this to handle requests for MIME type of URIs, that does not need to reveal any internal information which should be protected by any permission.

(Inherited from ContentProvider)
Insert(Uri, ContentValues, Bundle)

Implement this to handle requests to insert a new row.

(Inherited from ContentProvider)
Insert(Uri, ContentValues)

Implementation is provided by the parent class.

IsChildDocument(String, String)

Test if a document is descendant (child, grandchild, etc) from the given parent.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
MoveDocument(String, String, String)

Move the requested document or a document tree.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
OnCallingPackageChanged()

Called whenever the value of #getCallingPackage() changes, giving the provider an opportunity to invalidate any security related caching it may be performing.

(Inherited from ContentProvider)
OnConfigurationChanged(Configuration)

To be added This method is always called on the application main thread, and must not perform lengthy operations.

(Inherited from ContentProvider)
OnCreate()

Implement this to initialize your content provider on startup.

(Inherited from ContentProvider)
OnLowMemory()

To be added This method is always called on the application main thread, and must not perform lengthy operations.

(Inherited from ContentProvider)
OnTrimMemory(TrimMemory)

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process.

(Inherited from ContentProvider)
OpenAssetFile(Uri, String, CancellationSignal)

Implementation is provided by the parent class.

OpenAssetFile(Uri, String)

Implementation is provided by the parent class.

OpenDocument(String, String, CancellationSignal)

Open and return the requested document.

OpenDocumentThumbnail(String, Point, CancellationSignal)

Open and return a thumbnail of the requested document.

OpenFile(Uri, String, CancellationSignal)

Implementation is provided by the parent class.

OpenFile(Uri, String)

Implementation is provided by the parent class.

OpenFileHelper(Uri, String)

Convenience for subclasses that wish to implement #openFile by looking up a column named "_data" at the given URI.

(Inherited from ContentProvider)
OpenPipeHelper(Uri, String, Bundle, Object, ContentProvider+IPipeDataWriter)

A helper function for implementing #openTypedAssetFile, for creating a data pipe and background thread allowing you to stream generated data back to the client.

(Inherited from ContentProvider)
OpenTypedAssetFile(Uri, String, Bundle, CancellationSignal)

Implementation is provided by the parent class.

OpenTypedAssetFile(Uri, String, Bundle)

Implementation is provided by the parent class.

OpenTypedDocument(String, String, Bundle, CancellationSignal)

Open and return the document in a format matching the specified MIME type filter.

Query(Uri, String[], Bundle, CancellationSignal)

Implementation is provided by the parent class.

Query(Uri, String[], String, String[], String, CancellationSignal)

Implement this to handle query requests from clients with support for cancellation.

(Inherited from ContentProvider)
Query(Uri, String[], String, String[], String)

Implementation is provided by the parent class.

QueryChildDocuments(String, String[], Bundle)

Override this method to return the children documents contained in the requested directory.

QueryChildDocuments(String, String[], String)

Return the children documents contained in the requested directory.

QueryDocument(String, String[])

Return metadata for the single requested document.

QueryRecentDocuments(String, String[], Bundle, CancellationSignal)

Return recently modified documents under the requested root.

QueryRecentDocuments(String, String[])

Return recently modified documents under the requested root.

QueryRoots(String[])

Return all roots currently provided.

QuerySearchDocuments(String, String, String[])

Return documents that match the given query under the requested root.

QuerySearchDocuments(String, String[], Bundle)

Return documents that match the given query under the requested root.

Refresh(Uri, Bundle, CancellationSignal)

Implement this to support refresh of content identified by uri.

(Inherited from ContentProvider)
RemoveDocument(String, String)

Removes the requested document or a document tree.

RenameDocument(String, String)

Rename an existing document.

RequireContext()

Retrieves a Non-Nullable Context this provider is running in, this is intended to be called after #onCreate.

(Inherited from ContentProvider)
RestoreCallingIdentity(ContentProvider+CallingIdentity)

Restore the identity of the incoming IPC on the current thread back to a previously identity that was returned by #clearCallingIdentity.

(Inherited from ContentProvider)
RevokeDocumentPermission(String)

Revoke any active permission grants for the given Document#COLUMN_DOCUMENT_ID, usually called when a document becomes invalid.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPathPermissions(PathPermission[])

Change the path-based permission required to read and/or write data in the content provider.

(Inherited from ContentProvider)
SetReadPermission(String) (Inherited from ContentProvider)
SetWritePermission(String) (Inherited from ContentProvider)
Shutdown()

Implement this to shut down the ContentProvider instance.

(Inherited from ContentProvider)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Uncanonicalize(Uri)

Remove canonicalization from canonical URIs previously returned by #canonicalize.

(Inherited from ContentProvider)
UnregisterFromRuntime() (Inherited from Object)
Update(Uri, ContentValues, Bundle)

Implement this to handle requests to update one or more rows.

(Inherited from ContentProvider)
Update(Uri, ContentValues, String, String[])

Implementation is provided by the parent class.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to