Fixed the bug in DB.getPhotos

Now GalleryActivity and ImageActivity work.