Working example of how to load and save to/from the file system using Python/Kivy

179 views
Skip to first unread message

Anton Chivchalov

unread,
Nov 23, 2023, 12:28:14 PM11/23/23
to Kivy users support

Many people have been struggling recently to load or save anything to/from regular folders on latest Android versions using Kivy. Some even start thinking Kivy can't do it anymore. I myself did. But I finally cracked this problem. And I decided to publish a quick example to demonstrate how to do it, just for the community. I myself experienced a great need of such examples, I haven't found anything of the kind when I needed them. Now I want to fill this need.

Find it on Github along with the Buildozer.spec file, and there are my comments right in the code. You can build everything out of box. It's a single 100-line file without any complicated dependencies. You only need to import androidstorage4kivy module which can be installed by pip and merely added to the requirements in Buildozer.

The app allows to open any text file from anywhere in your device memory (or connected cloud services) and see its content in the text input field. You can also input any text yourself and save it as a new text file in the Documents folder on your device. In parallel, just for demonstration purposes, an .mp3 file is created and placed in the Music folder.

This was tested on Android 12, 10, and even 6, and it works smoothly on all of them, including an ancient 8-year-old tablet. A single piece of code covers all versions.

Any comments are welcome, and especially if something doesn't work in your case.

Elliot Garbus

unread,
Nov 23, 2023, 8:12:34 PM11/23/23
to kivy-...@googlegroups.com
Thanks for sharing!


Sent from my iPhone

On Nov 23, 2023, at 10:28 AM, Anton Chivchalov <ant...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/49cb0576-3d38-4a6e-aa3a-663226b5db85n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages