1

I'm trying to understand the permission needed when using (SAF) Storage Access Framework to access files (in my case it's Internal storage, files which are not lying on External SD Card). From the documentation, I understand client is suppose to request permission to interact with files.

In the SAF, providers and clients don't interact directly. A client requests permission to interact with files (that is, to read, edit, create, or delete files).

However, I have also been reading a few articles (Link 1) (Link 2) which mentioned as below: (In my own words: Accessing storage without having user granting READ/WRITE permission)

  • get away with READ/WRITE permissions on Android
  • Accessing Storage Volume without Storage Permissions

In my case:

I use react-native-document-picker for choosing a file (operation does not perform any file changes, only READ), when the application on ANDROID deny the storage permission. I'm getting java.io.IOException: Permission denied.

Issue goes away when (storage permission is allowed && Gallery was opened at least once in app). Meaning, if the user allow storage permission and continue opening Files. I will still get java.io.IOException: Permission denied, unless both conditions are met.

Hence I'm confused if (SAF) really do not required READ/WRITE storage permission?

1 Answer 1

0

No you need not any permission.

If you let the user pick a file or directory with SAF you automatically get read and write permission for them.

The permissions do not last long unless you make them permanent which can be done with one line of code.

4
  • Sorry, to re-edit my response. But how would the quoted statement in my question? A client requests permission to interact with files. I ended up with requesting WRITE permission and things work as expected. Dec 18, 2019 at 10:38
  • Neglect it. All goes automatically. YOU dont have to do anything except for that what i mentioined. (The request is done by the 'saf file or direcory picking').
    – blackapps
    Dec 18, 2019 at 11:05
  • The react-native-document-picker uses ACTION_OPEN_DOCUMENT and ACTION_PICK. The latter is not really SAF. Maybe its because of the latter or other things the picker does. I dont know.
    – blackapps
    Dec 18, 2019 at 11:09
  • Picking a file means a request to read or write the file. Thats all.
    – blackapps
    Dec 18, 2019 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.