In my app I want to swap images at runtime when user clicks on it.
there are two imageviews when user click on first image and then click on second image at the same time I'm fetching bitmap of first imageview's image and assigning to second imageview for this I used following code:
public Bitmap createBitmap(ImageView imageview) {
imageview.setDrawingCacheEnabled(true);
imageview.buildDrawingCache(false);
if(imageview.getDrawingCache() != null) {
Bitmap bitmap = Bitmap.createBitmap(imageview.getDrawingCache());
imageview.setDrawingCacheEnabled(false);
return bitmap;
} else {
return null;
}
}
Code is working fine but the cache not cleared every time and the bitmap created with previous cache so how I can clear a bitmap cache?