package cn.yyxx.commsdk.core.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesUtils {

    public static String getSharedPreferences(Context context, String tag,
                                              String key) {

        SharedPreferences sp = context.getSharedPreferences(tag,
                Activity.MODE_PRIVATE);
        String name = sp.getString(key, "");
        return name;

    }


    public static void setSharedPreferences(String head, String key, String value, Context context) {
        SharedPreferences sp = context.getSharedPreferences(head, Activity.MODE_PRIVATE);
        // 实例化SharedPreferences.Editor对象（第二步）l
        SharedPreferences.Editor editor = sp.edit();
        // 用putString的方法保存数据
        editor.putString(key, value);
        // 提交当前数据
        editor.commit();
    }
}
