Volley的介绍就不写了 网上一大堆
废话不多少
1.Volley的缓存是默认开启的
2.//最重要的一点是在url前面天上网络请求类型get或者是post(0/1),摸索了半天才发现的...
public void getVolleyCache(RequestQueue queue, String url, int what) {
3.//根据url判断本地是否有缓存
if (queue.getCache().get("0:" + url) != null) {
String s = new String(queue.getCache().get(url).data);
Gson gson = new Gson();
Object obj= new Object ();
obj = gson.fromJson(s, obj.getClass());
//.........obj就是的到缓存中的数据,接下来就很简单了,至于转换成什么类型就不必写了
Logger.e("QUEUE", "本地数据" + obj.toString());
}
}
废话不多少
1.Volley的缓存是默认开启的
2.//最重要的一点是在url前面天上网络请求类型get或者是post(0/1),摸索了半天才发现的...
public void getVolleyCache(RequestQueue queue, String url, int what) {
3.//根据url判断本地是否有缓存
if (queue.getCache().get("0:" + url) != null) {
String s = new String(queue.getCache().get(url).data);
Gson gson = new Gson();
Object obj= new Object ();
obj = gson.fromJson(s, obj.getClass());
//.........obj就是的到缓存中的数据,接下来就很简单了,至于转换成什么类型就不必写了
Logger.e("QUEUE", "本地数据" + obj.toString());
}
}