假设我正在制作一个健身应用程序,您可以在其中进行锻炼.配置完锻炼后,您会想要保存它.如何添加此功能,以便当他退出应用程序并再次打开应用程序时,他可以查看他的锻炼情况?
Say I was making a fitness app where you can make your out workout. When you have configured the workout you would want to save it. How do I add this function so that when he exits the app and opens it again, he can view his workouts?
我专门在 Android 上工作.
I am working specifically on Android.
这可用于保存本地游戏存档和数据.
This could be used to save local game saves and data.
我相信 Kivy 有一个模块可以解决这个问题.虽然它仍然(在撰写本文时)是实验性的.看这里:http://kivy.org/docs/api-kivy.storage.html#module-kivy.storage
I believe Kivy has a module that deals with this. Though it is still(at the time of writing) experimental. Look here: http://kivy.org/docs/api-kivy.storage.html#module-kivy.storage
根据 this,他们似乎正在使用 Pickle 来存储数据.
如果由于某种原因这不起作用,自己使用 Pickle/cPickle 怎么样?如果您不知道这些是什么,请立即使用 Google 搜索.然后您可以将用户设置或锻炼存储在一个字典中并腌制该字典,保存info 作为一个简单的文本文件到 sdcard,它根本不应该占用太多空间.
If that doesn't work for some reason, what about using Pickle/cPickle yourself? If you don't know what those are, Google them now. Then you could store user settings or workouts in a dict and pickle that dict, saving the info to the sdcard as a simple text file, which shouldn't take up much space at all.
据我所知,cPickle 是一个更快的 Pickle 实现,因为它是用 C 或 Cython 编写的,我不确定.希望这对您有所帮助.
As far as I know, cPickle is a faster implementation of Pickle due to being written in C or possibly Cython, I am not sure. Hope any of this helps.
值得注意的是,可以将文本文件保存到 Android 设备.我最近使用 Kivy 制作了一个游戏,我就是这样做的,以纯文本形式存储高分.
It's worth noting that it's possible to save text files to the Android device. I recently made a game with Kivy where I was doing just that, storing high scores in plain text.
这篇关于在 Android 上的 kivy 中保存应用数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!