/**
* 取出工具
*
* @param context
* @param key
* @param clazz
* @param <T>
* @return
*/
public static <T> T mGet(Context context, String key, Class<T> clazz) {
String s = SpUtils.mBuidSp(context).mGetStr(key);
Gson gson = new Gson();
T t = gson.fromJson(s, clazz);
return t;
}
/**
* 存入工具
* @param context
* @param key
* @param object
*/
public static void mSave(Context context, String key, Object object) {
Gson gson = new Gson();
String s = gson.toJson(object);
SpUtils.mBuidSp(context).mSaveStr(key, s);
}
/**
* 使用这种工具
*/
private void mUserUtils () {
TextBean test = new TextBean("我的世界", "123");
GsonAndSpUtils.mSave(MainActivity.this,"www",test);
TextBean www = GsonAndSpUtils.mGet(MainActivity.this, "www", TextBean.class);
Log.e("text123","返回的数据是 :"+www.toString());
}