简体   繁体   English

如何将base64字符串转换为blob?

[英]How to convert base64 string to blob?

A Synchronization service that provide an image in Base64 string and I want to save that into a SQLite database blob field?提供Base64字符串图像的同步服务,我想将其保存到SQLite数据库blob字段中?

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.稍后,我需要在位图中显示图像。

You convert a base64 image string to byte[] like :您将 base64 图像字符串转换为 byte[],例如:

byte[] decodedByte = Base64.decode(yourBase64String, 0); 

after that you also can convert it to Bitmap :之后,您还可以将其转换为 Bitmap :

Bitmap bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);

To convert a base64 string to a byte[], you can use:要将 base64 字符串转换为 byte[],您可以使用:

byte[] decodedByte = Base64.decode(yourBase64String)

And to convert a byte[] to a blob, you can use:要将 byte[] 转换为 blob,您可以使用:

Blob b = new SerialBlob(decodedByte);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM