Where to store images obtained from the server - android

I am downloading a number of small images from the server. My question is: where do I store them? The images are icon size and I am expecting at the very most 100 of them. I want to use a HashMap to store them. But I am wondering if I should be storing them on the SD card. And if I decide to store them on the SD card: Do I have to "inflate" the bitmap each time a user calls the image (which is used on multiple activities) or would I be storing them in a data structure anyway at that point? To me the obvious answer is HashMap. But just in case I overlook something, does anyone know reasons for which way I should go?

Why not cache them on external storage or internal storage? This is actually how Android Gallery has done. You can find cache file at /sdcard/Android/data/gallery_package/cache/cache_file. In Gallery, you can access Picasa data which will be downloaded by gallery and cached to local disk. when drawing these data on screen, you can load them from cache directly.

Related

What is the best way to store the image in the memory of app?

I'm using sqlite db in my app and now I would like to allow user customize the background image make them able to select one from their gallery.
Should I just store the path to image and simpy refer to it every time or should I some how transfer the image to some text and store it completely in my db? The second option prevents in case of picture being deleted from gallery. But I would like to know the most appropriate way of doing that.
SQLite has a cursor limit of 1Mb. So, you will probably not be able to store it completely in the DB, when you go to to request it will probably be truncated. Store the path to the image in the database table, and access it that way.
You wouldn't store it as text. Store it as blob to your database. In my opinion this is the way to go (if you use SQLite anyway).
If you have large images then store the path to your storage and not the image to the database.
I think it would be better to save only the path of the background, you won't be limited by the size of the image
In my opinion, the best way to save the customized background image is copy it into the internal storage (private storage) of your application. If you store only the path of the file, then file cannot be available once the user deleted that.
The official docs saying about the internal storage is:
It's always available.
Files saved here are accessible by only your app by default.
When the user uninstalls your app, the system removes all your app's files from internal storage.

Better place to save images in device

Lets say, i am creating a news app and also fetching the images from server.
Which is best place to save those images? in Cache Directory or external directory? since those images might be 500kb or sometimes even 1 MB or less.. How to manage those images since those files are app specific and user can read news containing images in offline too..
Currently i am saving in internal cache directory by creating another folder inside cache directory. If i save it in SD Card then wont it create problem for the phone or tablet which don't have Memory Card?
Any Alternative best way?
Use this https://github.com/nostra13/Android-Universal-Image-Loader lib to loading images , it do a lot of work for you. To cache images you on sdcard just needed to properly set up ImageLoaderConfiguration and DisplayImageOptions fields.

Android storing rss feed data

I need some suggestion here on the Sql database approach for storing rss feed data
First : My rss feeds gives image url links which i diplay using bitmap and inputstream at runtime but now for offline purposes so as to use app when internet not available how do i load them, do i need to save complete images like whatsapp does right ? is this approach right ? if yes how to save complete images in database ? a sample code will help.
Last i want to save the complete database on sd card not in internal memory , storing data on sd card will work fine or it will create problem ? because whatsapp or many other apps stores quite a data in internal memory !! if storing on sd card is not a problem how do i store complete data on sd card ?
If your image comes from your online server, use cache then save the URL to your SQLite database together with the other data you need to access when offline.
As for the downloading and caching approach for images you can see this link:
http://theandroidcoder.com/utilities/android-image-download-and-caching
Once the image is downloaded and cached you can view it even offline. :) Or else you may want to store the whole image and save it in a specific path on your phone and access it when internet connection is not present.
As for your idea on storing in SD card. there is only one problem I can think about. When the SD card is removed, all your data is lost. You should search on how to better handle data on your phone as well as do as research on storing in external storage for this one. It's now on your end to do some research about it to further understand its risk and advantages.

In android image store in internal memory or DB. Which is most efficient way.

I want to store images locally, So which is efficient way , storing image in data base or storing image in internal memory. I have no option of external memory.
Best wud be to pre bundle the images in your apk itself. Else there is no way to do that.Also if you can save images on the sd card, you can make the folder names start with "." (dot) so that they wont be visible in normal condition (will be visible only if there is option checked of "show hidden files" in your file browser of phone).And if you want that your images dont show up in gallery then just add an empty file to the folder named ".nomedia".This will make your images not to shpw up in Android Gallery.
This page shows the various options you have for data storage. If you just need to save images, I can't see why you would use a database. Also, your database would be located in Internal memory.
Images stored in private internal memory do not show up in the gallery as they are only accessible to the app that created them.

Android - Store Image Manually and Display Image From Preloaded Database

May I know how to store an image manually into a database without using codes/programming? How do I go about doing that? How do I even save it as a BLOB type? Or do I save the image URL(from local desktop location and not from the internet) to the database? And after which, how do I go about displaying the image from the preloaded database and display it in the image view?
Many thanks in advance!
I suppose you want to store images on your device, am i wright? As for me the best practice is to save them on SD card and remember the path in DB.
For easy saving you can use bitmap map method compress which receives outputstream to sd card path as a parameter
I have managed to find alternatives to settle down with. Which is to save the image file name into the database and store the images in the application's asset folder after which display the image by the path name in webview.

Categories

Resources