2

I'm trying to follow that http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html the part where It talks about DiskCache but I found lot of problems in that code. I fixed a lot of them, but there's one that I don't know what to do. It's this one:

mDiskLruCache.put(key, bitmap);

and this one

mDiskLruCache.get(key);

Those methods doesn't exist. I'm adding the .jar of Jake Wharton and Support Library v4, but neither of them seems to work. Please, can anyone tell me what's going on here??

Also I'm looking how to catch images using that https://github.com/fhucho/simple-disk-cache but I don't see how to do It.

ANY help will be apreciated.

EDIT 1

I'm using what Budius recomend me, but I have a problem. I'm creating that onCreate

DiskLruImageCache dlic=new DiskLruImageCache(getApplicationContext(),"bckgCache", CACHESIZE, CompressFormat.PNG, 70);

So I think, every time I open the App I'm overwritting the cache, wich is bad because I need to store some Bitmaps from one use to another. Is there any way to check If the cache already exist so I do not create It again?

EDIT 2

I opened another Post asking this question so we will not mixing both. How check if a DiskLruCache already exists? (Android)

Can´t mark any comment as answer, just as helpful one

Community
  • 1
  • 1
MBRebaque
  • 359
  • 2
  • 5
  • 14
  • 1
    I've used the code from this SO post before and it worked great: http://stackoverflow.com/questions/10185898/using-disklrucache-in-android-4-0-does-not-provide-for-opencache-method – Budius Apr 14 '13 at 21:04
  • Thanks for the reply. I saw that before, I didn't try. As far as I can understand It only does the get/put files right? I mean, I have my own thread wich downloads images from url, is still neccesary? – MBRebaque Apr 14 '13 at 21:16
  • yes. That code and Jakes library does everything in the thread you call them. So make sure to call everything of the UI. – Budius Apr 14 '13 at 21:17
  • Ok, I'm going to try that one, I will tell you tomorrow. Thanks a lot – MBRebaque Apr 14 '13 at 21:25
  • correction: So make sure to call everything **off (away from)** the UI thread. – Budius Apr 14 '13 at 21:29

1 Answers1

0

https://github.com/JakeWharton/DiskLruCache/blob/master/src/main/java/com/jakewharton/disklrucache/DiskLruCache.java

looking at the source the open method checks if the cache exists already and returns it if possible.

shbi
  • 90
  • 8