Stats

20 Contributors: 1 Sunday, May 7, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Bitmap Cache

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

ParameterDetails
keykey to store bitmap in memory cache
bitmapbitmap value which will cache into memory

Related Examples