Bitmap Cache
suggest changeVersions
[{“Name”:“4.0”,“GroupName”:null},{“Name”:“4.0.3”,“GroupName”:null},{“Name”:“4.1”,“GroupName”:null},{“Name”:“4.2”,“GroupName”:null},{“Name”:“4.3”,“GroupName”:null},{“Name”:“4.4”,“GroupName”:null},{“Name”:“4.4W”,“GroupName”:null},{“Name”:“5.0”,“GroupName”:null},{“Name”:“5.1”,“GroupName”:null},{“Name”:“6.0”,“GroupName”:null},{“Name”:“7.0”,“GroupName”:null},{“Name”:“7.1”,“GroupName”:null}]
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|