Can we write data to external storage without adding write permission in the manifest ? Does Storage access Framework or Download manager gives any support for this?
-
1You can use the "Storage Access Framework", available on Android 4.4 and above. Detailed tutorial is here: https://jayrambhia.com/blog/android-fileprovider-ecosystem – Mr-IDE Apr 03 '21 at 09:05
-
I saw this comment after making bounty, but it seems like a good answer. @Mr-IDE – Shamshirsaz.Navid Feb 25 '22 at 17:49
3 Answers
It depends where you want to write the files and what SDK(s) you are targeting. If you want to write the files in your app's external directories (getExternalFilesDir(String)
and getExternalCacheDir()
) and you are targeting SDK19+, then the permission is not required. If you want to write in other areas or targeting SDK<19, then you need the permission. HOWEVER, based on my experience, there is a bug in some Lollipop versions out there that is causing the permission to still be required. So I usually put <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22"/>
in my manifest.

- 2,601
- 1
- 14
- 20
Maybe FileProvider
is what you are looking for.
FileProvider is part of Support Library
, available for all Android versions starting 2.3. The main goal of this API is to temporary open a private file to some targeted apps
: you keep the file in your private folder, and let some other apps read or even write it via a secured ContentProvider
. Permissions are revoked when your activity is destroyed.

- 16,677
- 10
- 70
- 117
-
Yes, this is the safest way. Share the file with another app using a content URI of your FileProvider. Use a scheme which lists any app is willing to take. Your user picks an app e.g internal file-manger, from the list. With any luck, the app will have SaveAs a file to another location. – Humpity Mar 04 '22 at 17:47
Short answer: no. If there was an easy way to bypass required permissions they'd be pretty pointless. See the documentation below:
https://developer.android.com/training/basics/data-storage/files.html
To write to external storage, you need permission to write to external storage.
Why would you want to take an action you haven't received permission for anyway?

- 11,977
- 56
- 49
- 78
-
7I can't speak for other downvoters, but it's not true that to write to external storage, you always need explicit permission to write to external storage. The rules are much more complicated. Also, the OP didn't ask for a way to bypass required permissions. He asked for a way to write data to external storage without adding write permission in the manifest. That is a reasonable question, and in fact it's possible if you write to the right directories. – LarsH Nov 18 '16 at 20:42