This question is more academic than procedural. My preference screen displays and works fine, but while looking up various examples of the proper implementation of AppCompatPreferenceActivity, I discovered people handle loading the XML setting's resource differently in their sample code.
I am only using a single, simple settings setup, all within a single PreferenceScreen and category, but PreferenceFragmentCompat seems to still be the most appropriate and versatile way to go, leaving more options open for the future. I may or may not add more settings and or categories later.
My question is just this, given the parameters above, are there any benefits or disadvantages in using one call over the other (setPreferencesFromResource vs addPreferencesFromResource).
I've have tried both:
public class PreferenceFragmentCustom extends PreferenceFragmentCompat
{
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey)
{
setPreferencesFromResource(R.xml.app_preferences, rootKey);
}
}
and
public class PreferenceFragmentCustom extends PreferenceFragmentCompat
{
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey)
{
addPreferencesFromResource(R.xml.app_preferences);
}
}
but, they both seem to work the same (remember, I am not swapping different preference fragments in and out and may or may not in the future).
Again, given the circumstances cited above, I'm asking if there is any reason to choose one method of loading the XML setting's resource over the other (setPreferencesFromResource vs addPreferencesFromResource).
Thank you in advance.