wood burning stoves 2.0*
The moose likes Android and the fly likes Database vs filesystem which one is best for storing images? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Database vs filesystem which one is best for storing images?" Watch "Database vs filesystem which one is best for storing images?" New topic
Author

Database vs filesystem which one is best for storing images?

Pritam Shah
Greenhorn

Joined: Jul 13, 2009
Posts: 25
I am new on android and building an application which uses webservice to collect user information in xml.
I also get path for a small jpeg picture of each user. (Currently there are about 200 users)

I am parsing the xml and storing the information in SQLiteDatabase. Pictures are stored as blob and i m able to retreive them.
I display names of users on listview with images as well.

But is this a good solution for storing pictures in SQLite Database ?
Or should consider storing it in file system ?

Which is suitable in terms of performance , as well as memory and any other pro and cons on Android.

Also like to know which is best performing xml parser for Android ? My purpose is only to parse xml files which I get through webservices and sort out the data to store in storage.

And lastly my memory goes off easily when I load all images to display in list view after making thumbnails of each (which is obvious). Was wondering is there any library/framework/app available which dynamically loads images as and when required (when that list item is on display) something like Gallery program but in a list view ?

Any help highly appreciated. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

"mob king", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pritam Shah
Greenhorn

Joined: Jul 13, 2009
Posts: 25
Bear Bibeault wrote:"mob king", please check your private messages for an important administrative matter.


Thanks for reminding, I have done with that.
Pritam Shah
Greenhorn

Joined: Jul 13, 2009
Posts: 25
Any Update on this ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
We can't say what's suitable for your application; only you can. But it should be easy to compare a file-based storage approach with a DB-based approach in order to determine which one (or neither, or both) is sufficiently performant.

Android has SAX and DOM built in as part of the javax.xml package (just like Java SE), so unless you want/need to add additional libraries for some reason you should use those for XML handling.

Image processing is notorious for using a lot of memory. If it overwhelms the device, consider doing the processing on a server and keeping just the thumbnails (which should be quite small) on the device.


Ping & DNS - updated with new look and Ping home screen widget
Pritam Shah
Greenhorn

Joined: Jul 13, 2009
Posts: 25
Ulf Dittmer , Thanks for your reply. But for my last question , and in general , are there any libraries available that have implemented common functionality like custom widgets. If yes , where can I find them?
I have build a dynamic listview (images and names) that i read from database. I have also applied autotextview and filter to dynamically filter the list based on user input in Search box provided.
This works fine in emulator, as I load the whole list of images at one shot in memory and buffer it in array, so no problem , but a bad idea as the number of total images grow.
If I program it in a way to just load the current items that are visible on screen , my application response will be affected as user enters names to search and list getting generated dynamically, as it has to construct/load image for each item from database.

I found an interesting article that mentioned working of android GALLERY application, how it solves this problem by making a thumbnail of all images in a private folder for first launch and uses the same for subsequent launches.

My purpose is to know that do I need to write up the whole logic , or any framework already available ?
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369

Ulf Dittmer , Thanks for your reply. But for my last question , and in general , are there any libraries available that have implemented common functionality like custom widgets. If yes , where can I find them?
I have build a dynamic listview (images and names) that i read from database. I have also applied autotextview and filter to dynamically filter the list based on user input in Search box provided.
This works fine in emulator, as I load the whole list of images at one shot in memory and buffer it in array, so no problem , but a bad idea as the number of total images grow.

1. Not sure what you mean by "common functionality like custom widgets".
2. Yes it is a bad idea to load everything in shot if the list grows big.You should consider loading only what is to be displayed and not everything. Google "Droid Fu library for Android" they provide controls(custom ImageViews which lazy load images in background given image url). Perhaps you meant this in 1 above?
If I program it in a way to just load the current items that are visible on screen , my application response will be affected as user enters names to search and list getting generated dynamically, as it has to construct/load image for each item from database.

Try implementing the slow Adapter pattern in your ListView. Also, filtering should not be affected by this; just the loading of thumbnails. Usual practice is to show some default icon while loading the thumbnail in background(native applications do this).

[List of FAQs] | [Android FAQ] | [Samuh Varta]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database vs filesystem which one is best for storing images?
 
Similar Threads
which xml parser suitable 4 this?
Need weblogic specific classes to get reference to HttpSession object
Retreiving image through JPA and displaying it
whats the best way ?
How to restrict access to image folders