問題描述
我已經使用 kivy 為 Android 創(chuàng)建了一個原型應用程序.它已在 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 規(guī)范能夠接受它們.
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 等)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!