Reputation: 795
A Synchronization service that provide an image in Base64
string and I want to save that into a SQLite
database blob
field?
Could anyone tell me how to proceed with this or any other way to do this procedure?
As later on, I need to show image in bitmap.
Upvotes: 3
Views: 28890
Reputation: 159
To convert a base64 string to a byte[], you can use:
byte[] decodedByte = Base64.decode(yourBase64String)
And to convert a byte[] to a blob, you can use:
Blob b = new SerialBlob(decodedByte);
Upvotes: 2
Reputation: 3916
You convert a base64 image string to byte[] like :
byte[] decodedByte = Base64.decode(yourBase64String, 0);
after that you also can convert it to Bitmap :
Bitmap bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
Upvotes: 7