Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Objects Cache

Looking for a simple open source non-copyleft caching for Android (SDK 7+) class.

The purpose is primary to store the Bitmaps fetched asynchronously (so i don't need this functionality to be included in the cache class).

I was using a weakList for this purpose, that was naturally a bad solution, with Guava cache that is a little better but still not fine.

It's preferred that the cache is able to store any serializable Object, not just a Bitmap, and that i could easily purge the objects of certain tag used while the object is added to cache.

The best option would be to get the filesystem cache like wrapping the sqlite database. It would be great if the cache would be cleared by Settings >Manage Application > Clear Cache

like image 853
A-Live Avatar asked May 31 '12 21:05

A-Live


1 Answers

The plain LruCache suggested above is an in memory cache. From your question it sounds like you are looking for a disk cache solution.

Read the Disk Cache of the Caching Bitmaps android training doc.

Then take a look at the DiskLruCache implementation discussed on the following thread : Using DiskLruCache in android 4.0 does not provide for openCache method

You can grab the DiskLruCache source on GitHub.

like image 145
Akos Cz Avatar answered Sep 24 '22 20:09

Akos Cz