Newer
Older
SpyWebView / app / src / main / java / me / bello / spywebview / util / PrefUtils.java
bello on 31 Jul 2020 955 bytes 过滤
package me.bello.spywebview.util;

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

/**
 * @Info
 * @Author Bello
 * @Time 20-7-31 下午3:54
 * @Ver
 */
public class PrefUtils {

    static String name = "myFile";
    /**
     * 存字符
     *
     * @param key
     * @param value
     */
    public static void setString(Context context, String key, String value) {
        SharedPreferences setting = context.getSharedPreferences(name, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = setting.edit();
        editor.putString(key, value);
        editor.commit();

    }


    /**
     * 取字符
     *
     * @param key     * @return
     */
    public static String getString(Context context, String key, String value) {
        SharedPreferences setting = context.getSharedPreferences(name, Context.MODE_PRIVATE);
        String result = setting.getString(key, value);
        return result;

    }

}