Initial commit
This commit is contained in:
40
sources/com/ubtech/jimu/storage/UbtPrefs.java
Normal file
40
sources/com/ubtech/jimu/storage/UbtPrefs.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.ubtech.jimu.storage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtPrefs<T> {
|
||||
private Context a;
|
||||
private String b;
|
||||
|
||||
public UbtPrefs(Context context) {
|
||||
this(context, false);
|
||||
}
|
||||
|
||||
public synchronized void a(String str, Object obj) {
|
||||
SharedPreferences.Editor edit = this.a.getSharedPreferences(this.b, 4).edit();
|
||||
if (obj instanceof Boolean) {
|
||||
edit.putBoolean(str, ((Boolean) obj).booleanValue());
|
||||
} else if (obj instanceof Float) {
|
||||
edit.putFloat(str, ((Float) obj).floatValue());
|
||||
} else if (obj instanceof Integer) {
|
||||
edit.putInt(str, ((Integer) obj).intValue());
|
||||
} else if (obj instanceof Long) {
|
||||
edit.putLong(str, ((Long) obj).longValue());
|
||||
} else if (obj instanceof String) {
|
||||
edit.putString(str, (String) obj);
|
||||
}
|
||||
edit.commit();
|
||||
}
|
||||
|
||||
public UbtPrefs(Context context, boolean z) {
|
||||
this.a = context.getApplicationContext();
|
||||
this.b = z ? SharePreferenceHelper.SP_FILE_NAME_USER : SharePreferenceHelper.SP_FILE_NAME_SETTING;
|
||||
}
|
||||
|
||||
public synchronized Boolean a(String str, Boolean bool) {
|
||||
return Boolean.valueOf(this.a.getSharedPreferences(this.b, 0).getBoolean(str, bool.booleanValue()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user