Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User settings saved in SharedPreferences removed or lost between reloads of app

My app stores simple settings in SharedPreferences it works fine. However for one person who's downloaded my app is having problems. The settings in the SharedPreferences are getting lost between closing and reloading the app.

Could he have a permissions problem somewhere on his phone that's preventing the data from being saved between sessions?

Has anyone experienced this or know of any reason why this could be happening? I'm having a pretty hard time debugging it, I don't know where to start.

// I'm using SharedPreferences Like so:
prefs = getSharedPreferences(this.getString(R.string.prefs_name), 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("accounts", accounts);
editor.commit();

//retrieving stored information like:
SharedPreferences prefs = getSharedPreferences(this.getString(R.string.prefs_name), 0);
String accounts = prefs.getString("accounts","[]");
like image 863
Rob Avatar asked May 10 '11 20:05

Rob


1 Answers

We are experienced same problems with our Android apps. Our userbase is pretty big (several million users) and by our statistics subjected problems occured for about 0,2% - 0,3% of users. It seems to be not so much, but with our userbase it thousands of users.

After long search for fixes of this problem, we've made a decision to stop using SharedPreferences for our projects. We are using simple SQLiteDatabase instead, and it works very well.

like image 72
HitOdessit Avatar answered Sep 30 '22 17:09

HitOdessit