jimu-decompiled/sources/com/ubtech/jimu/storage/UbtPrefs.java
2025-05-13 19:24:51 +02:00

41 lines
1.4 KiB
Java

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()));
}
}