adding PreferenceManager.getDefaultSharedPreferencesName to default (#454)

Summary:
Adding context [PreferenceManager.getDefaultSharedPreferencesName](https://developer.android.com/reference/android/preference/PreferenceManager.html#getDefaultSharedPreferences(android.content.Context)) by default.

## Changelog

Adding context default shared preference by default.
Pull Request resolved: https://github.com/facebook/flipper/pull/454

Reviewed By: jknoxville

Differential Revision: D15759223

Pulled By: passy

fbshipit-source-id: d0770444ce2ea43e2c9bfdc9969532d330f71488
This commit is contained in:
Jan Rabe
2019-06-11 08:51:33 -07:00
committed by Facebook Github Bot
parent 79414aa3e1
commit 8dc9e5aee2

View File

@@ -10,6 +10,8 @@ import static android.content.Context.MODE_PRIVATE;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import com.facebook.flipper.core.FlipperConnection;
import com.facebook.flipper.core.FlipperObject;
import com.facebook.flipper.core.FlipperPlugin;
@@ -129,9 +131,19 @@ public class SharedPreferencesFlipperPlugin implements FlipperPlugin {
descriptors.add(new SharedPreferencesDescriptor(prefName, MODE_PRIVATE));
}
}
descriptors.add(
new SharedPreferencesDescriptor(getDefaultSharedPreferencesName(context), MODE_PRIVATE));
return descriptors;
}
private static String getDefaultSharedPreferencesName(Context context) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
? PreferenceManager.getDefaultSharedPreferencesName(context)
: context.getPackageName() + "_preferences";
}
private SharedPreferences getSharedPreferencesFor(String name) {
for (Map.Entry<SharedPreferences, SharedPreferencesDescriptor> entry :
mSharedPreferences.entrySet()) {