Ad

PreferenceManager GetDefaultSharedPreferences Deprecated In Android Q

PreferenceManager getDefaultSharedPreferences is deprecated in Android 10. How do I replace it?

Ad

Answer

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'
Ad
source: stackoverflow.com
Ad