Android saves the image conversion to the database, and then reads and converts it into image implementation code from the database
•
Android
First, we need to store the pictures in the database. First, we need to create a database, as shown below:
The code comments are more detailed
The key point here is that when initializing the database and converting drawable into byte [], first convert drawable into bitmap, then store the bitmap in the byte data output stream and obtain the byte [] array from the output stream.
Then store the character array into the database of type blob.
Then take byte [] from the database in the code, convert it into drawable, and set the picture.
The code is as follows:
Focus on how to convert byte [] retrieved from the database into drawable:
The operation effect is as follows:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码