Introduction
Memory efficient bitmap caching:
This is particularly important if your application uses animations as they will be stopped during GC cleanup and make your application appears sluggish to the user.
A cache allows reusing objects which are expensive to create. If you load on object into memory, you can think of this as a cache for the object.Working with bitmap in android is tricky.It is more important to cache the bimap if you are going to use it repeatedly.
Syntax
LruCache<String, Bitmap> mMemoryCache;//declaration of LruCache object.
- void addBitmapToMemoryCache(String key, Bitmap bitmap){}//declaration of generic method adding bitmap into cache memory
- Bitmap getBitmapFromMemCache(String key){}//declaration of generic method for get bimap from cache.
Parameters
| Parameter | Details |
|---|
| key | key to store bitmap in memory cache |
| bitmap | bitmap value which will cache into memory |