使用GET preferece()设置第一次运行标志 [英] using getPreferece() to set a first time run flag

查看:133
本文介绍了使用GET preferece()设置第一次运行标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的code应该阅读在第一次运行一个未设置preference:

I have this code that should read an unset preference on the first run:

protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    SharedPreferences settings = getPreferences(MODE_PRIVATE);
    firstTime = settings.getBoolean("firstTime", true);
    Log.d("mything", "firstTime returns as: " + firstTime);
    SharedPreferences.Editor editor = settings.edit();
    editor.putBoolean("firstTime", false);
    editor.commit();

变量firstTime始终是返回假。
我卸载我的应用程序,并重新加载它。

the variable "firstTime" is always returned as false. I am uninstalling my app and loading it afresh.

有人能解释一下吗?

在此先感谢

推荐答案

您使用三星Galaxy S采用2.2.1的固件?还有就是如果共享卸载应用程序不会被删除preferences已知的bug。例如在这里看到评论

Are you using Samsung Galaxy S with 2.2.1 firmware? There is known bug that shared preferences are not being removed if application is uninstalled. For example see comments here

这篇关于使用GET preferece()设置第一次运行标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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