SAF Restrictions

Since the beginning, the Storage Access Framework has been billed as the way for the app to get access to whatever content the user wants to work with.

In Android 11, that is no longer the case, as the OS will prevent the user from accessing the user’s content in scenarios that Google does not like.

ACTION_OPEN_DOCUMENT_TREE

In the Android 11 version of this UI, the user can navigate into a directory and click a “Use this folder” button at the bottom to choose it:

SAF UI, Showing Use this folder Button
SAF UI, Showing “Use this folder” Button

However, that button will be grayed out in some situations.

Overall External Storage Root

The user cannot grant an app rights to work with the root of external storage, precluding apps from placing new directories there:

SAF UI, Showing Disabled Use this folder Button for External Storage Root
SAF UI, Showing Disabled “Use this folder” Button for External Storage Root

Download/

The same holds true for Download/:

SAF UI, Showing Disabled Use this folder Button for Download/
SAF UI, Showing Disabled “Use this folder” Button for Download/

However, if the user creates a subdirectory of Download/, such as via their USB cable or the stock Files app, they can choose that subdirectory.

Stuff in Android/

While the user can choose the Android/ directory on external or removable storage, the user cannot access anything inside of it. In the other cases, the user could see directories that could not be selected, but in this case, the contents simply do not show up:

SAF UI, Showing Empty Android/ Directory
SAF UI, Showing “Empty” Android/ Directory

The Other SAF Actions

ACTION_OPEN_DOCUMENT and ACTION_CREATE_DOCUMENT share the last restriction of ACTION_OPEN_DOCUMENT_TREE: the user cannot choose or create a file within getExternalFilesDir() and kin of some other app. Otherwise, these actions seem unaffected.

Unfortunately, the ACTION_OPEN_DOCUMENT limitation means that an app’s files are inaccessible by the user except through that app or by copying the files elsewhere using a device-supplied file manager.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.