0

I have developed an android app which exports the data from the SQlite database into a .csv file. I am able to export all the data successfully except for the BITMAP data. I am storing the bitmap as a Blob datatype in SQlite database and as byte[] in the corresponding classes. How can I export the byte[] into .csv file. Eventually, the csv file will be opened in MS Excel as a workbook. I have imported/used OPENCSV's CSVWriter classes. Any suggestions would help. Thanks in advance.

The Bitmap data which is actually an image taken from the camera thru' the android app is stored as byte[]. I tried exporting it by converting it into a string using byte[] encodedBytes = Base64.getEncoder().encode(Bitmap as byte[]) and then Stirng temp = new String(encodedBytes, StandardCharsets.UTF_8); String temp is saved into .csv file. But when I open the .csv file in Excel, I expected to see a bitmap, instead this is what I saw '/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAA.........'

BigBen
  • 46,229
  • 7
  • 24
  • 40
Lakshmi
  • 92
  • 1
  • 7

1 Answers1

0

I found a solution. Instead of CSVWriter, I used apache.poi library and I am able to create a .xls file with the bitmap data in a single cell and other data in other cells successfully. You can refer to the org.apache.poi:poi library for further info.

Lakshmi
  • 92
  • 1
  • 7