PreferenceManager getDefaultSharedPreferences deprecated in Android Q

Martynas B picture Martynas B · Jul 1, 2019 · Viewed 32.9k times · Source

PreferenceManager getDefaultSharedPreferences is deprecated in Android Q, how do I replace it?

Answer

laalto picture laalto · Jul 1, 2019

You can use AndroidX 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'