PreferenceFragment - Difference between getPreferenceManager() and getPreferenceScreen()?

后端 未结 3 1231
情歌与酒
情歌与酒 2020-12-30 19:44

I\'ve implemented my own PreferenceFragment subclass (detailed here), and want to listen for preference changes within it. PreferenceFragment provides you with two ways of d

3条回答
  •  半阙折子戏
    2020-12-30 19:47

    The first one gets the shared preferences from the PreferenceManager. The second one, from the PreferenceScreen, that inherits this method from Preference class.

    I think this is not a functional difference, because both return probably the same instance of the SharedPreferences objects, but I think it's clearer to use the first one (using PreferenceManager instead of PreferenceScreen).

提交回复
热议问题