0

I have code for inserting Bitmap to sqlite database below. If I put byte[] object into content values the query insert is unsuccessful, it returns -1, but if I comment on the line cv.put(CagTablePictures.CAG_FIELD_PICTURE, byteArray);, the insert is success. Where is the mistake? thanks.

ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();

ContentValues cv = new ContentValues();
cv.put(CagTablePictures.CAG_FIELD_NAME, "Bitmap_" + n);
cv.put(CagTablePictures.CAG_FIELD_PICTURE, byteArray);
long id = mDatabase.insert(CAGLayerManager.CAG_TABLE_PICTURES, null, cv);
NREZ
  • 942
  • 9
  • 13
muyassar
  • 41
  • 1
  • 5

1 Answers1

0

Just an easy Alternative You can use SqliteMaestro software to create databases with bitmap in them

lazyandroid
  • 157
  • 1
  • 10