安卓共享首选项初始化

7

通常情况下,共享首选项中可以设置一些默认值。有没有一种好的方式可以从xml文件或属性文件初始化它们?正在寻找最佳方法。谢谢。


2个回答


0
 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Make sure default values are applied.  In a real app, you would
        // want this in a shared function that is used to retrieve the
        // SharedPreferences wherever they are needed.
        PreferenceManager.setDefaultValues(getActivity(),
                R.xml.advanced_preferences, false);

}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接