How can a PreferenceActivity use a custom preference file

前端 未结 3 1380
谎友^
谎友^ 2021-02-05 06:43

My first attempt at preferences was without knowledge of PreferenceActivity. So now I have an app that stores all user preferences in a specific preference file.

3条回答
  •  孤街浪徒
    2021-02-05 06:54

    You could read all the preferences at the beginning of your app, and then store them in the Preferences using

    Editor e = PreferenceManager.getDefaultSharedPreferences(getBaseContext()).edit();
    e.putBoolean("yourPreference", true);
    e.putString("yourOtherPreference", "This is the Value");
    ...
    e.commit();
    

    I hope that helps

提交回复
热议问题