Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

java - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...