向首选项中存取数据(仅限于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(); }
2021-12-07 10:23:00 2KB 自定义SP
1