qpython icon indicating copy to clipboard operation
qpython copied to clipboard

Permission denied on write to external SD card

Open clach04 opened this issue 7 years ago • 1 comments

os.mkdir('/storage/YOUR_CARD_HERE/some_dir')

Fails with permission denied.

os.mkdir('/sdcard/some_dir')

Works fine. Permissions are granted for SD card, maybe manifest does not include external SD card?

clach04 avatar Jul 20 '18 05:07 clach04

On Android 4.4 <= version < 5, this requires a rooted device. (Because the permission is only granted for system applications.) On Android >= 5, QPython has to specify

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

https://stackoverflow.com/questions/48172519/oreo-write-external-storage-permission This seems to be already done in QPython.

Additionally, the user has to manually grant individual access to removable storage using a system file chooser once per app and medium. See also https://metactrl.com/docs/sdcard-on-lollipop/

So QPython needs an option to bring up such a file chooser. Then the system grants permanent access, after the user chose the SD card root directory.

luziferius avatar Nov 15 '18 18:11 luziferius