当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Save app data in kivy on Android

问题描述:

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?

I am working specifically on Android.

This could be used to save local game saves and data.

网友答案:

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

They appear to be using Pickle to store the data, according to this.

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.

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.

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: