In my application, i have some url’s using these url’s i am downloading the images from web and use these images in my app. Where to store these images? because my app have lot of images are there.Suggest the best way i.e,that way have no chance to get the “out of memory exception”.please can anybody help me.
I am using the following way is it good or bad. can anybody suggest me.
- Using the url’s i am downloading the images from the web and at the download time i am creating the directory for these images in the sd card. Save these images with url names in the sd card.if the image name is exist in the directory then that image will be fetching from the sd card. otherwise it will be downloaded from the web. is it good?
thanks
As per Saving cache files from the Android developer, use
Context.getExternalCacheDir()(API level 8) orEnvironment.getExternalStorageDirectory()+/Android/data/<package_name>/cache/(API level 7 or lower) as the location to store cache files.If you have different caches, add a subdirectory for each.
Both of the above approaches are in your app’s “private” data space and will be removed along with your app — that’s a good thing, you don’t want to use space on a device when your app is gone.
Also, don’t use the URL direclty as file name, create a digest/hash of it and use that, like the iosched app does. This spares you from escaping any special characters in the URL yourself.