Page 1 of 1

Shell - write file to external storage - permission denied

Posted: 2021-12-10, 22:15 UTC
by Lee321987
Hello.
Is there any way to allow a shell command to write files to external storage?
I have a button that runs this command:

Code: Select all

sh ls > filelist.txt
It works on internal storage, but on external storage I get "permission denied" in every dir except:
/Android/data/com.ghisler.android.TotalCommander

I am not rooted.
Running Android version 7.
Total Commander has been granted "Storage" permission in Android settings.

Re: Shell - write file to external storage - permission denied

Posted: 2021-12-13, 17:08 UTC
by ghisler(Author)
On Android 11 and newer, all folders under /Android/data are restricted to the respective app. The Total Commander app internal name is com.ghisler.android.TotalCommander, so its access is restricted to /storage/emulated/0/Android/data/com.ghisler.android.TotalCommander.

The folders of other apps can only be accessed via virtual folders (scoped storage) which isn't available via shell commands.
I recommend putting the files in /Android/media instead, they are the public folders of an app now.