package com.android.chmo.app;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2018/7/31.
 */

public class SpManager {
    private static SpManager spManager;
    private SharedPreferences mSp;

    private SpManager(){
    }

    public static SpManager getInstance(){
        if(spManager == null) {
            spManager = new SpManager();
        }
        return  spManager;
    }
    public void init(Context context) {
        mSp = context.getSharedPreferences("'APP_CONFIG'",Context.MODE_PRIVATE);
    }

    public void setBoolean(String key, boolean value) {
        mSp.edit().putBoolean(key, value).commit();
    }

    public boolean getBoolean(String key) {
       return mSp.getBoolean(key,false);
    }

    public void setString(String key, String value) {
        mSp.edit().putString(key, value).commit();
    }

    public String getString(String key) {
        return mSp.getString(key,null);
    }

    public void setInt(String key, int value) {
        mSp.edit().putInt(key, value).commit();
    }

    public int getInt(String key) {
        return mSp.getInt(key,0);
    }

    public void setLong(String key, long value) {
        mSp.edit().putLong(key, value).commit();
    }

    public long getLong(String key) {
        return mSp.getLong(key,0);
    }
}
