Sebastian Sebastian - 26 days ago 8
JSON Question

Binary data in cursor android

I am saving a bitmap value in

SQLite
by encoding it into
base64
. I need to create a
JSON array
for all my SQLite values. I am using a a cursor to get all my values from SQLite.


But the cursor does not hold the whole base64 value, only half base64
bits.


How can I resolve this?

Answer

I think its not the best practice to save base64 representation in db:

Please remember base64 encoding makes file sizes roughly 33% larger than their original binary representations, So you can convert image to byte[] and then save it in blob field

To save binary data in JSON Object, please see here