package com.zkjc.common.utils;

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

public class SharedPreferencesUtil {
    private static SharedPreferencesUtil instance;

    public static final String KEY_UNLOCK_MODE = "unlock_mode";
    public static final String KEY_PASSWORD = "password_key";

    private SharedPreferences.Editor editor;
    private SharedPreferences prefer;

    public SharedPreferencesUtil(Context context) {
        this.prefer = PreferenceManager.getDefaultSharedPreferences(context);
        this.editor = this.prefer.edit();
    }

    public static SharedPreferencesUtil getInstance(Context context) {
        if (instance == null) {
            synchronized (SharedPreferencesUtil.class) {
                if (instance == null) {
                    instance = new SharedPreferencesUtil(context);
                }
            }
        }

        return instance;
    }

    public void saveString(String name, String data) {
        this.editor.putString(name, data);
        this.editor.commit();
    }

    public String getString(String name) {
        return this.prefer.getString(name, null);
    }
}
