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 :)
精彩评论