import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
/**
* Created by Administrator on 2018/11/26 0026.
*/
public class SharedPrefeerenceUtil {
private static String NAME = "SharedPrefeerence_name";
@SuppressLint("ApplySharedPref")
public static void putString(Context context, String key, String value) {
SharedPreferences sharedPreferences = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
sharedPreferences.edit().putString(key, value).commit();
}
public static String getString(Context context, String key) {
SharedPreferences sharedPreferences = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
return sharedPreferences.getString(key, "未获取到值");
}
@SuppressLint("ApplySharedPref")
public static void putInt(Context context, String key, int value)
基础封装SharedPreferences
最新推荐文章于 2025-03-28 15:27:10 发布