Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
763 views
in Technique[技术] by (71.8m points)

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...