1、缓存bitmap图片和获取:相当于键值对的保存
(1)、缓存:
public void save(View v) {
Resources res = getResources();
Bitmap bitmap = BitmapFactory.decodeResource(res, R.drawable.img_test);
mCache.put("testBitmap", bitmap);
}
(2)、读取缓存的图片:
public void read(View v) {
Bitmap testBitmap = mCache.getAsBitmap("testBitmap");
if (testBitmap == null) {
mIv_bitmap_res.setImageBitmap(null);
return;
}
mIv_bitmap_res.setImageBitmap(testBitmap);
}
(3)、清除操作:
mCache.remove(“testBitmap”);
2、总结:
缓存:就直接put进去;
获取:指定类型获取
mCache.put(“testJsonArray”, jsonArray);
JSONArray testJsonArray =
mCache.getAsJSONArray(“testJsonArray”);
3、缓存的类型数据:
4、特色:
4.1:轻,轻到只有一个JAVA文件。
4.2:可配置,可以配置缓存路径,缓存大小,缓存数量等。
4.3:可以设置缓存超时时间,缓存超时自动失效,并被删除。
4.4:支持多进程。