package com.ads.cal.picturetranslate;

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

public class SharedPreferencesUtil {
    private static final String PREFS_NAME = "MyAppPreferences";

    public static final String KEY_FIRST_INSTALL_APP = "key_first_install_app";

    public static final String KEY_FIRST_CLK_TAKE_PHOTO = "key_first_clk_take_photo";

    // 保存字符串
    public static void saveString(Context context, String key, String value) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.apply();
    }

    // 读取字符串
    public static String getString(Context context, String key, String defaultValue) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        return sharedPreferences.getString(key, defaultValue);
    }

}
