I do this for the AMAZING terminal app Termux which for reasons that I do not understand also does not request this permission.
The procedure is rather complicated, involving copying and editing an xml file manually, and puts you at risk of preventing your system from booting. You'll also need to do it again every time the app updates. I guess if you use an editor that has root access you wouldn't have to worry about the copying part. Hmm. Maybe I should do it that way too, actually.
The following are the steps I use to fix perms for Termux. You'll have to adapt them to work for your app. They should probably be the same except for the full app name.
If you're not familiar with XML you should be suuuper hesitant to try this as you'll probably render your phone unbootable if you make an error.
- Make sure you're not updating apps (turn off auto-update) or doing anything else which could result in modifications to the packages xml file while you're editing it.
- Start a session in Terminal Emulator.
su - in this session to give yourself root permissions.
ls -l packages.xml
- write down the permissions and ownership of
packages.xml. They will be essential later.
- When I did this ten minutes ago, these values were still
-rw-rw---- system:system as they have been for the however many years I've been doing this. Might be different on a different type of phone.
cp packages.xml packages.xml.orig to make a backup copy of this very important system file
cp packages.xml /storage/emulated/0/tmp, or some other location depending on how your phone's file system is laid out. If that directory doesn't exist, just create it.
Now edit the file whichever way you prefer (I use
Termux, but use whatever text editor) to make the following change:
- Find the second line containing
/name="com.termux"/. It should be a
shared-user tag (i.e. a line starting with
- For your app this might end up being a different line containing the full name of your app, depending on whether your app has an entry in the earlier section in this file. There might also not be a permissions entry for your app, in which case you'll have to make one from scratch, I guess. I would think this would probably be okay but I really don't know; you might cause system issues by doing so. Caveat emptor. But yeah if you find this node for Termux and copy it and paste the copy below Termux's entry that would probably work.
- Copy the last
<item ... /> line and paste it right underneath.
- Edit the pasted line to change the permission (currently mine has
WAKE_LOCK) to read
- so the last node within the
<perms> node should be
<item name="android.permission.WRITE_MEDIA_STORAGE" granted="true" flags="0" />
Save the file and exit your editor and go back to your Terminal window (where you still have a root session running in
cp /storage/emulated/0/tmp/packages.xml .
cp here and NOT
mv doesn't set the permissions correctly.
- VERIFY that the permissions are the same as they were when you started. This is VERY IMPORTANT because the phone won't boot if the perms are wrong. I did this once and managed to rescue it somehow, I forget how.
At this point you should be good to reboot. It's probably prudent to do a
diff packages.xml packages.xml.orig1 or whatever to verify that you made the change correctly.
After you reboot your app should have write access to the external SD card. Good luck!
If anyone is aware of a cleaner way to do this, please let me know! This is clunky AF and carries no small risk of having to spend another hour afterward fixing my phone.
androidmanifest.xmlfile that is stored under the
base.apkfile which can be found at
/data/app/<app's package name>