i've got a question about best solution for caching downloaded images. From internet are downloaded URLs of images i want to show with specifig tag. On some other activities will be showed previews of images and after click on preview will be shown image in full size and his description. My idea is save info about image to database with path to directory named after tag in cache directory. When preview should be shown, i look to cache and if there image is, good and if not image will be downloaded
Maybe use a naming convention so you won't need to use the database ?
Like this :
Profil picture for user 1 will be in
tmp/mypackage/pic_cache/user_pic_1.jpg
Related
Currently I want to make a list like pictures and images on the server when I click on it, it will download the images to the memory device. If the image is downloaded, it will not download again and the image that is not there will be downloaded. Then I want to ask for a solution from everyone, how should I handle the download to be clean and good for performance. Or do you have an example for me to refer to? Thank you!
There are some ways to find out if your image already exists in your phone storage but the best way to find it out is by image name, compare image names before downloading.
When i develop a android app with download and caching image from internet, i see many app use MemoryLruCache or DiskLruCache to cache image after download. But i want to know why they use them, why don't use the way like: download image, then save image into sd card and after get image from sd card to show it( it is manual way).
I'm newbie in android dev. So please help me to understand it?
Thanks many many times.
well downloading a list of images from url will consume time and also fill up the user memory also....so its better to dynamically load images from url and make its cache and then preview the images from cache..
I hope you did got my point....check some example of lazy loading of image
I am using .net web services and I am having list of folders and files. I am successful in retrieving list of files(.jpg Image, .pdf, .TIF) but can anybody let me know how we can open .jpg, .pdf, .tif or other files format which I am getting from web services. Is there any specific code to open particular format or we can use path (/) to open that particular file?
Thanks.
if you need to download and display an image, check my answer on this post, that is probably what you are looking for. Common extensions for displaying images in Android are .png and .jpeg, you will not be able to show a .pdf file using an ImageView. You can also use the method mentioned in my answer inside an AsyncTask to perform the download in background and then update your UI thread
The device is Samsung Galaxy III. I developed an APP to run the camera activity and capture an image. After analyzing the image, I print out some text information. Right now every captured image is saved at gallery. I don't need the image to be saved in gallery or SD card. I think either of the following two solutions will work for me, but I don't know how to program it:
avoid saving pictures to gallery.
delete the picture somewhere in the APP.
Any comments are appreciated.
Read Android Camera tutorial.
...
Storage - Are the images or videos your application generates intended to be only visible to your application or shared so that other applications such as Gallery or other media and social apps can use them? Do you want the pictures and videos to be available even if your application is uninstalled? Check out the Saving Media Files section to see how to implement these options.
or see this one: How to save image captured with camera in specific folder.
In the Camera intent when starting, add this:
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(getTempFile(context)));
I solved my problem with following two steps:
as '#auselen' pointed, save all the images to a specific folder. How to save image captured with camera in specific folder.
delete all the images in that folder somewhere in the APP. How to Delete Image From SDCard in Android
use this for delete a pic
ImgPhoto1.setImageBitmap(null);
I am displaying image's from web using Image downloading logic from url, I want to image download at first time only, next time onwards don't download image from web, because First time downloaded image store in cache memory so i display image from cache memory, In case does not exits that image in cache memory, will download otherwise don't need download that image from web , How is it possible any body guide me ho to so this.?
Thanks in advance.
Go with the solution Lazy loading list with images because it does the same trick that you require. i.e. download image once, store it in cache and display as and when it requires.
go thorugh this example given at GitHub: https://github.com/thest1/LazyList
store your images in sdcard.check wheather your images exist in sdcard or not if yes simply display those images otherwise download from web and store in sdcard,display from sdcard