PreferenceManager getDefaultSharedPreferences
is deprecated in Android Q, how do I replace it?
If you're just saving and retrieving key-value pairs you can replace:
prefs = PreferenceManager.getDefaultSharedPreferences(this);
with:
prefs = getSharedPreferences(
"my.app.packagename_preferences", Context.MODE_PRIVATE);
Be sure to use the right file name for the new implementation or your users will lose access to everything saved with getDefaultSharedPreferences(!). The following will get the file name getDefaultSharedPreferences uses:
getPackageName() + "_preferences"