在 Shared Preferences 中设置一些默认值通常会很好。有没有一种从 xml 文件或属性文件初始化它们的好方法?寻找最好的方法来做到这一点。谢谢。
问问题
9481 次
2 回答
8
阅读这个问题的答案:
于 2011-02-09T06:30:49.253 回答
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);
}
于 2017-03-01T12:31:35.617 回答