问题描述
说我正在制作一个健身应用程序,您可以在其中进行锻炼.配置锻炼后,您将要保存它.如何添加此功能,以便当他退出应用程序并再次打开它时,他可以查看他的锻炼情况?
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
如果由于某种原因该方法不起作用,自己使用Pickle/cPickle怎么办?如果您不知道这些是什么,请立即将其搜索.然后,您可以将用户设置或锻炼内容存储在字典中,然后对该字典进行腌制,保存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 theinfo to the sdcard as a simple text file, which shouldn't take up much space at all.
据我所知,由于使用C或可能的Cython编写,因此cPickle是Pickle的更快实现,我不确定.希望对您有所帮助.
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格式保存应用程序数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!