Create a custom document provider

If you're developing an app that provides storage services for files (such as a cloud save service), you can make your files available through the Storage Access Framework (SAF) by writing a custom document provider. This page describes how to create a custom document provider.

For more information about how the Storage Access Framework works, see the Storage Access Framework overview.

Manifest

To implement a custom document provider, add the following to your application's manifest:

  • A target of API level 19 or higher.
  • A <provider> element that declares your custom storage provider.
  • The attribute android:name set to the name of your DocumentsProvider subclass, which is its class name, including package name:

    com.example.android.storageprovider.MyCloudProvider.

  • The attribute android:authority attribute, which is your package name (in this example, com.example.android.storageprovider) plus the type of content provider (documents).
  • The attribute android:exported set to "true". You must export your provider so that other apps can see it.
  • The attribute android:grantUriPermissions set to "true". This setting allows the system to grant other apps access to content in your provider. For a discussion about how these