|
@@ -9,18 +9,16 @@ import java.util.Set;
|
|
|
|
|
|
public class SPUtils {
|
|
|
private static final String SP_NAME = "common";
|
|
|
- private static SPUtils mSpUtils;
|
|
|
- private Context context;
|
|
|
+ private SPUtils mSpUtils;
|
|
|
private SharedPreferences sp;
|
|
|
private Editor editor;
|
|
|
|
|
|
- public SPUtils(Context context) {
|
|
|
- this.context = context;
|
|
|
- sp = this.context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
|
|
|
+ public SPUtils(Context mContext) {
|
|
|
+ sp = mContext.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
|
|
|
editor = sp.edit();
|
|
|
}
|
|
|
|
|
|
- public static SPUtils getInstance(Context context) {
|
|
|
+ public SPUtils getInstance(Context context) {
|
|
|
|
|
|
if (mSpUtils == null) {
|
|
|
synchronized (SPUtils.class) {
|
|
@@ -74,7 +72,7 @@ public class SPUtils {
|
|
|
}
|
|
|
|
|
|
public void remove(String key) {
|
|
|
- sp.edit().remove(key).commit();
|
|
|
+ sp.edit().remove(key).apply();
|
|
|
}
|
|
|
|
|
|
}
|