pythonkivybuildozerfile-writing

How to write into files with Kivy App on Android 10?


I made a Kivy App with a button to download files from the internet. However, every time I click the button there is an error: [Errno 13] Permission denied: sdcard/file.txt

I tried making changes in the AndroidManfest.xml file and the buildozer.spec file but without any luck. After a quick research I found out that the Android storage system completely changed on Android 10 or later. After more research I found out that I have to write something not the Manifest file, but I can‘t because I am not able to open it to actually read it. (It is a mess of letters) So my question is, can I do the changes with buildozer or something? Is there another way to access the storage? Also, how can I fix my code so that it tries to access the internal storage?

Here are my systems: Phone to have app on it: Android 10 Packaging: GitHub Actions; ubuntu-20.04 (Apps are working, but only if they don‘t have to access storage) Additional Computer I could use if necessary: Windows 10


Solution

  • So I actually found a solution here; thanks to John Andersohn‘s comment. Just go through the code and use it how you need it. (Don‘t forget the credit!) Also you need to add READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE to buildozer.spec It should work on every android version. (antorix tested it on Android 6, 10, 12; I tested it on Android 10)

    Thanks again.