上传者: 33715783
|
上传时间: 2021-12-07 10:23:00
|
文件大小: 2KB
|
文件类型: -
向首选项中存取数据(仅限于String,Integer,Boolean)
public static void put(Context context,String key,Object value){
SharedPreferences sp = getSharedPreference(context);
SharedPreferences.Editor editor = sp.edit();
if(value instanceof String){
editor.putString(key, (String) value);
}else if(value instanceof Integer){
editor.putInt(key, (Integer) value);
}else if(value instanceof Boolean){
editor.putBoolean(key, (Boolean) value);
}
editor.commit();
}