I developed a game on Android. I am currently saving most of the game stats in a Database. However the app does not utilize more than a single row in the DB. I am now intere
As mentioned in other answers, Shared Preferences is only really limited by phone storage and simplicity.
However, if you want your users to seamlessly enjoy Android's Auto Backup then all of your local data, including SQLite and Shared Preference data, needs to be <25MB total.
I dont know about any limitations but regarding your problem with everyones progress being wiped out. You can override the onUpgrade method in your SQLite class and then migrate everyones data over to the newer database.
DO NOT use shared preferences for game data. I can download your game and with the tool below hack it to pieces. If your money is stored there I'll just change it to 4.2 million gold and call it good.
https://www.kingoapp.com/root-tutorials/hack-app-game-cheat-droid.htm
What's stopping someone from editing their XML file with a shared preferences editor?
I can't believe nobody thought about this while answering your question. Your limitations are significant in a videogame setting. There is nothing stopping anybody from editing all of their shared preferences data to hack the bleep out of your game.
SharedPreferences are written to xml files, so the maximum size of a file on Android is how large a SharedPreferences xml file can be. I can safely say that 40 integer values will not be a problem.
The maximum size of a value in a SharedPreferences file is limited to the maximum size of the value you are attempting to store. (Meaning you can't put a String value that is longer than Strings can be in Java.)
The only thing I would suggest is making sure to batch the edits as much as possible (meaning don't .commit()
each change) and also don't create a new editor for each change. (These are just good practices.)
SharedPreferences settings = getSharedPreferences(PREFS_FILE_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("firstValue", mFirst);
editor.putInt("secondValue", mSecond);
editor.putInt("thirdValue", mThird);
// Commit the edits! (As infrequently as possible)
editor.commit();