Usually not a good idea to store bitmaps/images in general on your database, it's not efficient at all.
You should save the bitmaps as images and store the paths on the database.
This was discussed on this question.
EDIT:
But... If you're really into storing that for whatever reason, you could also try to encode the image as a Base64 String
, and store it on your DB.
Android has the Base64 class
for this. Try to use the following snippet to encode:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); // Could be Bitmap.CompressFormat.PNG or Bitmap.CompressFormat.WEBP
byte[] bai = baos.toByteArray();
String base64Image = Base64.encodeToString(bai, Base64.DEFAULT);
// Call your method to save this string on the DB here.
And you'll have to decode it try the following:
byte[] data = Base64.decode(base64Image, Base64.DEFAULT);
Bitmap bm;
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inMutable = true;
bm = BitmapFactory.decodeByteArray(data, 0, data.length, opt);
// Now do whatever you want with the Bitmap.
You can see the docs for the Bitmap
class here.