Updated ImageAdapter to integrate database code