I'm implementing an image cache system for caching downloaded image.
My strategy is based upon two-level cache:
Memory-level and disk-level.
My class is very similar to the class used in the droidfu project
My downloaded images are put into an hashmap and the Bitmap objet is wrapped inside a SoftRererence object.
Also every image is saved permanently to the disk.
If a requested image is not found into the Hashmap<String,SoftReference<Bitmap>> it will be searched on the disk, readed, and then pushed back into the hashmap. Otherwise the image will be downloaded from the network.
Since I store the images into the phisical device momery, I have added a check for preserve the device space and stay under a 1M of occupied space:
This method is called sometime afte a disk writing:
What I'd like to add is the same check on the HashMap size to prevent it will grow too much. Something like this:
My question is:
What could be a right MAX_MEMORY_SIZE value? Also, Is it a good approach? A good answer also could be: "Don't do it! SoftReference is already enough"
In cm roms, dalvik cache of system apps are generated in /cache but those data/apps are generated in /data. Is there any way to disable this behaviour? Cache partition in our phones is too small. In AOSP and AOKP and stock roms, dalvik cache is always generated in /data no matter whether its a system app. any way to achieve this in cm roms?
My app has a WebView which displays Google maps. I'm trying to limit the cache size to a reasonable one - like 2MB. After checking with settings->applications->manage applications I found out that regular page load gets the cache to 900kb. And dispite my efforts, I can't limit the cache size or monitor when the cache limit is being reached. If I'm playing with the map on the webview, the app can even reach 10MB and no "ache max size reached" message is received.
Configure the web browser cache size? In HTC's new product HERO, they limit the cache size from 100KB to 6MB, and user can configure it manually. It can prevent browser sucking up memory space too much.
I do really love cloud computing... But, Google seems to have forgot something: set a limit to the cache size.
I have a Nexus S and my poor 16Gb internal memory is saturated because of caches: Google+, Android Gallery (Picasa), Google Music and Google Listen all fight for the sdcard space.
The only apps who have explicit cache settings is Google Listen... The others don't have obvious options. I have 10K songs, 10-20K photos, etc.. I need to access them, but I need to limit the cache size.
Is there a way to easily limit cache size per apps?
I have set of images fetched from internet and set it on gridview,here i have option to click here to view more,below the grid view and it fetches images and set it on grid with prevoius set of images,when i exit the application and run it again,the previous set of images remain in cache and grid shows images from cache,here i need to clear my application cache memory,when i exited my application.how can i get it.
I've got an app that is heavily based on remote images. They are usually displayed alongside some data in a ListView. A lot of these images are new, and a lot of the old ones will never be seen again.
I'm currently storing all of these images on the SD card in a custom cache directory (ala evancharlton's magnatune app).
I noticed that after about 10 days, the directory totals ~30MB. This is quite a bit more than I expected, and it leads me to believe that I need to come up with a good solution for cleaning out old files... and I just can't think of a great one. Maybe you can help. These are the ideas that I've had:
Delete old files. When the app starts, start a background thread, and delete all files older than X days. This seems to pose a problem, though, in that, if the user actively uses the app, this could make the device sluggish if there are hundreds of files to delete. After creating the files on the SD card, call new File("/path/to/file").deleteOnExit(); This will cause all files to be deleted when the VM exits (I don't even know if this method works on Android). This is acceptable, because, even though the files need to be cached for the session, they don't need to be cached for the next session. It seems like this will also slow the device down if there are a lot of files to be deleted when the VM exits. Delete old files, up to a max number of files. Same as #1, but only delete N number of files at a time. I don't really like this idea, and if the user was very active, it may never be able to catch up and keep the cache directory clean.
I am wondering if it is possible to limit the size of the dalvik-cache. I am looking for an alternative to putting it on the sdcard. Maybe I could create a partition on the internal storage for the cache?
I went to do a nandroid backup and it failed, "no space on my SD card".
Thats weird, as usually have at least 4 gig on my Nexus S 4g.
Poking around, it was the cache from Google plus,).[url].... That, coupled with my titanium backup of same ate my SDCARD. easy to fix Titanium from backup it up, but the cache is still several gigs large. 40,000 + files with [number].screen extensions.
I have like 2 friends on google+, 3 posts, and can not for the life of me figure out what in the world all that data is.
I'm going to remove the data , freeze the app, but just wanted to know if noticed a disproportionate amount of data in the Google+ app compared to the amount of activity/usage I have on google+.
There are a couple of options within the browser I didn't find until after searching for it, so I thought I would share it with the rest of the community in order to help out.
-Everyone should clear the browser cache and previous history in order to save internal phone memory. To do this go to BROWSER press the MENU button and press MORE. There should be a list of things in there but what you should be interested in is the last item which is SETTINGS. From there in privacy settings there will be options to clear both cache and history.
- Another little tip I wanted to share was viewing webpages in landscape mode without opening your keyboard. To do this simply press the MENU button from within the BROWSER and go down to FLIP ORIENTATION. You should realize tho by doing this you browser will continue to be in landscape the next time it's used. In order to return it to it's normal portrait mode just follow these steps once again.
-There are a number of other things you can mess around with or find with the MENU button within the browser so just take a look at it yourself even if you don't want to do any of these tips.
I bought a Samsung Galaxy S2 Hercules (T-Mobile) and its used. In the Last week I pull some photos and mistakenly delete them, but with my "Recurva" program i could see all the photos (mine and others owners)
On the one hand I'm happy for having recovered, but if one day I want to permanently delete photos, I have the fear that the other person recovers.
How I can delete all photos, videos and files in the cache memory?
From the JavaDoc, it said it returns 'a bitmap representing this view or null if cache is disabled'. My question is what if the View is longer than the phone screen (you need to scroll vertically), what does the bitmap return? * only the visible portion of the view * everything the view has (both visible + invisible part)
My app is downloading a file that does not need to be kept. So I was trying to put it in the directory returned by Environment.getDownloadCacheDirectory() (that returns "/cache"). But apparently it is not accessible, (a FileNotFoundException is thrown).
I work on an application to display a remote page in a webview. The page contains a simple input form and an image. The image is updated automatically by server using specific header. The page is never displayed.
Searching on the web to find a way to resolve this issue.
I read this : http://remotedroid.net/blog/2009/11/13/android-browser-caching/ "Pragma: no-cache, and all the other server-side headers also have no effect as far as I can tell."
I have a couple apps I have noticed when I open a file it must cache the file internally, but gives me no way to clear. For example Zumodrive and repligo reader both will show 20+mb in my settings, but clear cache is greyed out and shows 0mb. However when I delete these apps and reinstall them, I get all that internal memory back. I am running a rooted Nexus One.
I'm trying to manage the files that I store in a local cache. I download files, then delete them after the total file size in the cache exceeds a certain number of bytes. What I'm shooting for right now is something simple: setting the max cache size to be 1 MB, or 1*1024*1024 bytes = 1048576 bytes. I have a method that gets the cache directory, then does a listFiles() on that File to get all children of the directory. I have a flat cache structure, no subdirectories, so simply calling f.length() on every child should give me my total cache size right?
Well what I'm finding is that the amount I count is about 0.9 of size reported in Manage Applications > Application Info for my app, in the Cache section.
Am I making a bad assumption that File.length() will actually return to me the size, in bytes, of a file on disk? I also wonder also if disk space in the Cache directory is being used by Android at all for some reason I'm unaware of.
I'm trying to understand the way android handles my application cache data....Some times i'll go in there and the cache directory is 6-7mb. What type of data is stored there? Is there a way in the mainifest I can say don't use cache or clear cache at Xmb ?
Recently I switched to SDK 1.1 and it worked for a short time without any problems. Now I'm getting "Can't open dex cache '/data/dalvik- cache/system ..." error and emulator doesn't start at all. Just shows Android screen of death with blinking cursor. When I repoint Eclipse back to 1.0 r2 it works fine. I did adb shell and /data folder is empty.
Coming from a Blackberry Storm, I had Slacker Radio and it was one of the first apps I downloaded on my new Eris yesterday. However, I am finding that the ability to cache radio stations to your media card is missing from the features of the Android app. The cache was extremely useful as it wouldn't force the data connection and thus helped to conserve battery life.
Is there an alternative app for radio that will cache stations or do I need to hit up the Slacker team to get an update to the Android App?
I've seen some apps like dolphin browser (not the HD version, the normal one) utilizing a cache-to-sd for webview but i can't seem to figure out how to do this, does anyone know how to do this or point me in the right direction?
I searched and found many posts regarding clearing cache. But didn't find this answer. Is there a way to clear cache on all apps at once? I went through the settings/applications/manage apps, and checked and cleared cache on many, but this is real tedious, but seemed to give great results. Phone feels much faster. (NOT ROOTED) Psychological? Dunno, but question still stands, does anyone know an easy way to do this? Additionally, is there any risk of clearing cache from any apps?
Is it possible to force the cache of your app to clear when the user exits the app? My app piles up cache data (rightfully so) on each start, which is no longer needed once the user quits the app, so I am trying to find a way to forcibly clear it.