问题描述
我已经使用 kivy 为 Android 创建了一个原型应用程序.它已在 buildozer 中编译,我已上传到 Android 设备.
I've created a prototype application for Android using kivy. It has compiled in buildozer and I've uploaded in to an Android device.
但我不确定将应用程序相关文件(如 ini 文件、图像数据库等)放在哪里.
But I'm nor sure where to put app dependent files like the ini file, images database etc.
非常感谢任何帮助
当我问这个问题时(很多个月前),我对 kivy 和 buildozer 的整个想法都是新手.
When I asked this question (many moons ago) I was new to kivy and the whole idea of buildozer.
我没有意识到以及对于初学者来说不明显的事情(见证这个问题被查看的次数)以及 @inclement 的答案没有解决的问题是 Buildozer 将整个 python/kivy 项目包装到一个可以包含所有 static 数据的文件.因此,您只需要确保您的 buildozer 规范能够接受它们.
What I didn't realise and what isn't obvious to a beginner (witness the number of times this question has been viewed) and which @inclement's answer does not address, is that Buildozer wraps the whole python/kivy project into a single file which can include all of your static data. So you just need to make sure your buildozer spec picks them up.
推荐答案
您可以安排他们品尝 - 只要您告诉 buildozer 包含它们 apk(即通过设置要包含的文件类型、目录等)并访问它们在您的代码中具有相对路径,它们将在设备上以相同的方式工作.
You can arrange them to taste - as long as you tell buildozer to include them apk (i.e. by setting the file types, directories etc to be included) and access them with relative paths in your code, they will work the same way on the device.
ini 文件可能是一个例外,我不确定 kivy 尝试从哪里加载它(但它可能位于外部数据目录中的某个位置).如果将它放在与 main.py 相同的目录不起作用,也许您可以使用相对路径手动加载它,或者如果它只有几个值,那么您可以在 main.py 文件中设置它们.
The ini file may be an exception, I'm not sure offhand where kivy tries to load it from (but it may be somewhere in the external data dir). If putting it in the same directory as main.py doesn't work, maybe you could load it manually with a relative path, or if it has just a few values then you could set them in the main.py file.
这篇关于Android kivy 在哪里放置应用程序文件(ini、images db 等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!