users23456
users23456

Reputation: 49

Android Database storage

Here is what I'd like to do:

  1. Write an image file (png) and an audio file into an SQLite DB (I guess I have to go with BLOB to do this but not sure exactly how)
  2. Then pull this PNG image and the text from the DB to show it in a regular listview (regular list adapter) and combine it with corresponding text

So for example, one DB entry would have an image of an baby, the word baby as a text to describe the image and an audio recording of the baby crying. Another entry would have an doorbell and so on.

Then I want to show all those DB entries in a ListView (image + corresponding text elements) to make it look like this:

(baby image) Baby

I am aware that I could use a custom list adapter and pull the image from @drawables but the SQLite approach seems more elegant and appropriate to me.

As I am novice I would appreciate a tutorial & sample code that shows how to do this.

Upvotes: 1

Views: 680

Answers (1)

Jigar Pandya
Jigar Pandya

Reputation: 5977

First read the blogs and then try to implement the example

  1. http://www.helloandroid.com/tutorials/store-imagesfiles-database
  2. http://www.anddev.org/png_image_--und-gt_sqlite_db_--und-gt_imageview-t7188.html Full example

Hope it helps

On top of that rather then storing audio file data inside SQLITE, save the files into your file-system (like inside Documents directory) & save the file names into your SQLITE database in the same table that is storing image file... to store AUDIO you can see Upload video into SQLite section as well.

If I am not wrong SQLite has an restriction of total row size < 1024kb

Upvotes: 1

Related Questions