I have a sqlite database that has over 2000 low res thumbnails of
pictures. The database itself is over 100MB in size. The project
requires me to have the photos residing in the database instead of the
file path.
This is what I would like to do and need help with as this
is my first time dealing with images. I have a horizontal GalleryView
in my App UI that I want to populate with images pulled from this
database dynamically. I don’t mind if these images are lazy loaded on
to the gallery view in the background. I read somewhere that I will
have to use an ImageAdapter to bind the images to the UI element
dynamically. I need in understanding how this is done. I have never
used the BaseAdapter class.
Thanks,
AB
You will indeed be subclassing an Adapter to pull the images out of your db turn them into Bitmaps or Drawables then set your picture to an ImageView and add it to your Gallery.
I would suggest you switch away from using a Gallery right now before you get going though. Gallery has a bug where it will not allow your Adapter to recycle views properly. This means while the user is scrolling the gallery every time a new Image enters the screen a new ImageView object is getting created. This is wasteful and will lead to noticeable performance drop while your gallery is being scrolled due to garbage collection constantly running.
To get started with your adapter check out SimpleCursorAdapter and search around online for examples of how to extend SimpleCursorAdapter. Inside your getView method you’ll pull your image out of the db and set it into a view to be shown to the user.