ADD: Deprecate CrossProcessSharedPreferences.get() with new overload without argument "mode".

FIX: Mistaken import cause incorrect mode used in CrossProcessSharedPreferences.
This commit is contained in:
Oasis 2016-07-03 01:58:58 +08:00
parent 3ac93ec091
commit bf96baab30

View File

@ -22,8 +22,6 @@ import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import static android.R.attr.mode;
/**
* Make changes of SharedPreferences in one process propagate to all other processes with the same SharedPreferences (only after commit/apply).
*
@ -38,6 +36,12 @@ public class CrossProcessSharedPreferences {
/** Cross process version of {@link Context#getSharedPreferences(String, int)} except for the mode is always {@link Context#MODE_PRIVATE} */
public static SharedPreferences get(final Context context, final String name) {
//noinspection deprecation
return get(context, name, Context.MODE_PRIVATE);
}
/** @deprecated mode is officially deprecated by Android SDK, use {@link #get(Context, String)} instead. */
@Deprecated public static SharedPreferences get(final Context context, final String name, final int mode) {
if (mSingleton == null) synchronized(mLock) {
if (mSingleton == null) mSingleton = new CrossProcessSharedPreferences(context);
}
@ -53,12 +57,6 @@ public class CrossProcessSharedPreferences {
});
}
/** @deprecated mode is not supported any more
* @see #get(Context, String) */
@Deprecated public static SharedPreferences get(final Context context, final String name, final int mode) {
return get(context, name);
}
private SharedPreferencesWrapper getSharedPreferences(final Context context, final String name, final int mode) {
final SharedPreferences prefs = context.getSharedPreferences(name, mode);
if (prefs == null) return null; // Should not happen, but still check for safety (in case of custom implementation)