Reference

Storage Access Framework

The Storage Access Framework (SAF) is an Android system for browsing and accessing files and directories through a document provider model. Apps use intents like ACTION_OPEN_DOCUMENT and ACTION_OPEN_DOCUMENT_TREE to let the user pick files or a whole folder, and receive a persistable URI instead of a raw file path.

Android developmentAndroid

Storage Access Framework

Also known as: SAF android, document picker

The Storage Access Framework (SAF) is an Android system for browsing and accessing files and directories through a document provider model. Apps use intents like ACTION_OPEN_DOCUMENT and ACTION_OPEN_DOCUMENT_TREE to let the user pick files or a whole folder, and receive a persistable URI instead of a raw file path.

  • SAF returns content:// URIs accessed via ContentResolver, not raw file paths.
  • ACTION_OPEN_DOCUMENT_TREE grants access to an entire user-chosen directory subtree.
  • takePersistableUriPermission keeps a granted URI valid across device reboots.

How SAF works

SAF decouples an app from raw file paths. Instead of touching the filesystem directly, an app fires a system intent such as ACTION_OPEN_DOCUMENT (pick one or more files), ACTION_CREATE_DOCUMENT (create a new file), or ACTION_OPEN_DOCUMENT_TREE (grant access to a directory subtree). Android shows the system document picker UI, backed by registered DocumentsProvider implementations including local storage, Downloads, and cloud providers like Google Drive.

The user's selection returns a content:// URI rather than a `java.io.File` path. The app reads and writes through ContentResolver, calling `openInputStream`, `openFileDescriptor`, or querying the DocumentsContract columns (display name, size, MIME type). For tree access, `DocumentFile.fromTreeUri` exposes child enumeration over the granted subtree.

Persistable permissions and why a cleaner uses SAF

A URI grant is normally tied to the lifetime of the activity. To keep access across reboots, the app calls `ContentResolver.takePersistableUriPermission` with the FLAG_GRANT_READ_URI_PERMISSION (and write) flags captured from the result intent. The granted permissions survive until the user revokes them or the app is uninstalled.

Because scoped storage restricts broad filesystem access, a cleaner app uses ACTION_OPEN_DOCUMENT_TREE to let the user explicitly grant a folder (for example a Downloads or WhatsApp media directory) so it can enumerate, size, and delete files there without the all-files MANAGE_EXTERNAL_STORAGE permission. SAF is the user-consent path for browsing files outside the app's own sandbox.

Related terms

Keep reading the reference.

Act on it

Guides and tools for this topic.