I want to store some basic data like players_name,levels_completed,fastest_speed,fastest_time and bring it up each time the player starts a silly little game I am making… which is the perffered method to do this?
Sharedprefs or internal storage?
I am at http://developer.android.com/guide/topics/data/data-storage.html
and have just gotten confused as to which to use as both look good and easy enough to do.
Advise?
Thanks!
This is pretty much taken from one of the Facebook sdks examples (it allows you to save the FB session so the user doesn’t have to login each time)… I’ll modify it a bit for you though
}
I think you get the basic idea…
some points: I use “KEY + player_name” in case different players play on the same phone (if it was static you would overwrite the data of one player with anothers data).
Also, when you do
pName = savedSession.getString(PLAYER_NAME,"NO_NAME!");if nothing exists in the shared preferences it defaults to the value “NO_NAME!” and likewise for the getInts (which in this case I have them default to 0)in the program you would do
SessionStore.saveSession("Alex",50000,50000);to save the session, etc. Hope this gives a good gist of how to use it… Also keep in mind I’m an android newb – this works great for me but I’m no expert 😀