保存在删除共享preferences或应用程序的重载之间丢失的用户设置 [英] User settings saved in SharedPreferences removed or lost between reloads of app

查看:164
本文介绍了保存在删除共享preferences或应用程序的重载之间丢失的用户设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序商店中的<一个简单的设置href="http://developer.android.com/reference/android/content/Shared$p$pferences.html"><$c$c>Shared$p$pferences它工作正常。 然而,对于一个人谁是下载了我的程序有问题。 在<一的设置href="http://developer.android.com/reference/android/content/Shared$p$pferences.html"><$c$c>Shared$p$pferences关闭和重新加载应用程序之间迷路。

他可以有一个权限问题某处他的电话这是$ P $被保存会话之间?pventing数据

有没有人经历过这样的任何理由或不知道这可能是为什么发生? 我有一个pretty的很难调试它,我不知道从哪里开始。

  //我使用的共享preferences像这样:
preFS = getShared preferences(this.getString(R.string prefs_name),0);
共享preferences.Editor编辑器= prefs.edit();
editor.putString(账户,账户);
editor.commit();

//检索像存储的信息:
共享preferences preFS = getShared preferences(this.getString(R.string prefs_name),0);
字符串帐户= prefs.getString(账户,[]);
 

解决方案

我们都经历过同样的问题,我们的Andr​​oid应用。我们的用户群是pretty的大(数百万用户),并通过我们的统计承受的问题发生约0.2% - 用户的0.3%。这似乎是没有这么多,但我们的用户群是数以千计的用户。

在漫长的寻找这个问题的补丁,我们已经做出决定,将停止使用共享preferences 为我们的项目。我们使用的是简单的 SQLiteDatabase ,而是和它工作得很好。

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","[]");

解决方案

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.

这篇关于保存在删除共享preferences或应用程序的重载之间丢失的用户设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆