AlexanderNajafi
AlexanderNajafi

Reputation: 1651

Caching bitmap Android

What is the best way of caching Bitmaps if my min sdk is api lvl 8? I have a downloaded Bitmap which I would like to save, I can also get a type of hash for the image. Is it OK to just write it to a normal file anywhere if i fix the permissions, say like this?

FileOutputStream fOut = new FileOutputStream(file);

bmp.compress(Bitmap.CompressFormat.PNG, 85, fOut);

Upvotes: 0

Views: 1291

Answers (2)

fida1989
fida1989

Reputation: 3249

I think you should use Universal Image Loader library. It will do the caching, loading from url and other things by itself.

Upvotes: 0

validcat
validcat

Reputation: 6268

One of the best way to download and cache images is use Volley library. It's really easy and comfortable. There are a lot of different examples in the Internet but at first I suggest you to watch IO video . And then look for code examples (BitmapLruCache - is used directly for caching) (e.g. here or here)

Upvotes: 1

Related Questions