-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use app cache for caching #43
Comments
I probably just don't understand this fully (of course), but now when diskCacheIsEnabled, the app grows large very quickly. Thanks. |
How do you measure the disk cache size? I'm going to the app settings and finding the cache is near zero, even though I see in the logs messages like "DISK cache hit for xxx". |
You can specify where you want to write the files using the AbstractCache.DISK_CACHE_INTERNAL and AbstractCache.DISK_CACHE_SDCARD fields. ImageLoader's ImageCache caches to SD by default, unless no SD card is available. |
app cache is near zero because the cache is being registered in the app's data. This was my original question: How do we assign the cache to the app cache, so users can manage the cache in Manage Applications, and not have to delete the app data (which deletes all settings, databases, etc)? |
Hmmm, it actually should already do that. We use getApplicationContext().getCacheDir() to determine where to write cached files when DISK_CACHE_INTERNAL is requested as the caching mode. Here are the relevant parts:
... I think there are actually helper functions for this nowadays, but we wanted to remain backwards compatible to Android 1.5. So to be honest: I'm not sure why this is not working, I'd have to debug this first. |
@jjfster: I am not sure I get your question. Are you asking how is it possible to wipe the files in "/Android/data/package/cache/" when the user chooses the clear the cache from the Settings? If so I am not sure how to do that, I thought the Android OS took care of that but it doesn't. Moreover: I tried to clear data but even when after that the files in that directory are still there. |
When the images are cached, they are cached to the app's data storage, not the app cache. When you go on your device to: Settings/Applications/Manage Applications/[your app], you can see that the app cache (the second item in the dialog to clear) does NOT grow, but the app data storage (the first item on the list to clear) DOES grow, when using Droid-Fu's abstract cache. |
Hm yeah that's definitely an issue if that's true. I remember vaguely that in one of the newer SDK versions Google added a standard helper function to get a reference to the standard app cache dir. However, these methods are unavailable before 2.2 or so, that's why we never used them. |
Ok, so I did a little playing around. It looks like no matter what I do, getExternalCacheDir() does not participate in the "app cache" helper feature. The "app cache" is only used and recognizes cache that is in the getCacheDir() directory. Pretty silly, but I thought I didn't quite understand how they were handling app cache, and I just proved it!. Oh well, unless I'm still missing something? |
Which API level was that? |
Droid-Fu uses the app data storage for caching images.
Any way to have it use the app's cache, so that users can manage (read: clear) the app cache without affecting settings, etc.?
The text was updated successfully, but these errors were encountered: