开发者

How to read and write a file to maintain a numeric value

I see a lot of examples how to write and read a file, but I wanted to maintain a integer type variable who will maintain score of a game either using XML or fileIO stream. Is this poss开发者_C百科ible?


You can make use of SharedPreferences, which is a customized XML in Android to share settings/configuration among applications.
Create a pair key/value write to 'pref' file, when you want to retrieve value, just call the approriate method, getInt(), getFloat(), getString()..

http://developer.android.com/reference/android/content/SharedPreferences.html
Pretty much easy for beginners :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜