Android bitmap stored in SQLite and how to remove it without damage

Source: Internet
Author: User

When the small fish in the project, encountered directly put bitmap into SQLite

The small fish logo is very confusing when removing the problem that causes the picture to be displayed.

followed the code discovery. The original data stored in and taken out of the different.

Why does it cause this situation?


is because The data type used by my project is not the result.

(If you turn the image type byte[] into a string it will invalidate the picture!) )


The solution I'm using is. Encodes a byte array into a string before decoding

<span style= "White-space:pre" ></span>byte[] Bitmap_byte=cursor.getblob (columnIndex);//Direct removal has a transmission problem, Solve Base64encoder encode = new Base64encoder () by adding decoding; String Encode_bitmap=encode.encode (Bitmap_byte);


Decoding:

<span style= "White-space:pre" ></span>string bitemap_string = (String) data.getrow (0). GetValue ( ColumnName);//decoder Base64decoder decode = new Base64decoder (); byte [] bitemap_byte=null;try {//decode operation bitemap_byte= Decode.decodebuffer (bitemap_string);} catch (IOException e) {log.e ("Convert picture Failed", GetClass (). GetName () + ""); E.printstacktrace ();}



Add the decryption device:

http://download.csdn.net/detail/u010962482/8748905




Android bitmap stored in SQLite and how to remove it without damage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.