For creating settings page I used PreferenceFragment in my older project. But PreferenceFragment is deprecated in Android API level 28.
What will be alternative of PreferenceFragment now?
Instead of using PreferenceFragment now we have to use PreferenceFragmentCompat
Implementation example inside Fragment:
public static class DemoFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
// Load the preferences from an XML resource
setPreferencesFromResource(R.xml.preferences, rootKey);
}
}
Please see official documentation of PreferenceFragmentCompat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With