StrongReference weakedReference ,softReference的学习理解
1 Strong Reference
eg: Emp e=new Emp();
2.soft Reference
eg: softReference ref=new SoftReference(bitmap);
HashMap<String,SoftReference<Bitmap>> cache=new HashMap<String,SoftReference<bitmap>>();
*图片下载完成存入缓存
cache.put(path,new SoftReference(bitmap));
*在需要图片时从内存缓存中查询
SoftReference srf=cache.get(path);
if(ref!=null){
Bitmap bitmap=ref.get();
if(bitmap!=null){
setBitmap()......
}
}
stong Reference;//强引用
Emp e=new Emp();
softReference;//弱引用
softReference ref=new softReference(bitmap);
HashMap<>cache=new HashMap<String,SoftReference<Bitmap>>();