PreferenceManager getDefaultSharedPreferences deprecated in Android Q
Package preference
provides the androidx
PreferenceManager:
Java: implementation "androidx.preference:preference:1.1.1"
Kotlin: implementation "androidx.preference:preference-ktx:1.1.1"
i.e.
change android.preference.PreferenceManager
to androidx.preference.PreferenceManager
Also see PreferenceFragmentCompat, which is the current PreferenceFragment
class to use.
You can use the Android 10 support library version of PreferenceManager
, i.e., androidx.preference.PreferenceManager
and not android.preference.PreferenceManager
.
Remember to add the following to your build.gradle:
implementation 'androidx.preference:preference:1.1.1'