package com.tencent.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/* JADX INFO: loaded from: classes.dex */
public class PrefUtil {
    private static PrefUtil sInstance;
    private SharedPreferences mPreferences;

    private PrefUtil(Context context, String str) {
        this.mPreferences = context.getSharedPreferences(str, 0);
    }

    private PrefUtil(SharedPreferences sharedPreferences) {
        this.mPreferences = sharedPreferences;
    }

    public static PrefUtil get(Context context, String str) {
        return new PrefUtil(context, str);
    }

    public static PrefUtil getDefault() {
        return sInstance;
    }

    public static void initDefault(Context context) {
        sInstance = new PrefUtil(PreferenceManager.getDefaultSharedPreferences(context));
    }

    public SharedPreferences.Editor edit() {
        return this.mPreferences.edit();
    }

    public boolean getBoolean(String str, boolean z2) {
        return this.mPreferences.getBoolean(str, z2);
    }

    public float getFloat(String str, float f2) {
        return this.mPreferences.getFloat(str, f2);
    }

    public int getInt(String str, int i2) {
        return this.mPreferences.getInt(str, i2);
    }

    public long getLong(String str, long j2) {
        return this.mPreferences.getLong(str, j2);
    }

    public String getString(String str, String str2) {
        return this.mPreferences.getString(str, str2);
    }

    public SharedPreferences.Editor putBoolean(String str, boolean z2) {
        return edit().putBoolean(str, z2);
    }

    public SharedPreferences.Editor putFloat(String str, float f2) {
        return edit().putFloat(str, f2);
    }

    public SharedPreferences.Editor putInt(String str, int i2) {
        return edit().putInt(str, i2);
    }

    public SharedPreferences.Editor putLong(String str, long j2) {
        return edit().putLong(str, j2);
    }

    public SharedPreferences.Editor putString(String str, String str2) {
        return edit().putString(str, str2);
    }

    public void saveBoolean(String str, boolean z2) {
        putBoolean(str, z2).apply();
    }

    public void saveFloat(String str, float f2) {
        putFloat(str, f2).apply();
    }

    public void saveInt(String str, int i2) {
        putInt(str, i2).apply();
    }

    public void saveLong(String str, long j2) {
        putLong(str, j2).apply();
    }

    public void saveString(String str, String str2) {
        putString(str, str2).apply();
    }
}
