In the past few days, the android icon is stored in the database due to issues related to the entire database.
Intent and bitmap objects are stored.
Storage intent:
There is a touri method in intent to convert intent to string type data, and then you can save intent as text type data into the database. The conversion type is as follows:
# Intent; Component = com. Android. Settings/. settings; End
Retrieve intent:
To obtain the intent, first use the getstring method of cursor to obtain the value in the database, and then call the parseuri method of intent to convert the string type to the intent type.
Next, let's talk about database access to image information.
Storage image: bitmap
Private byte [] geticondata (Bitmap bitmap ){
Int size = bitmap. getwidth () * bitmap. getheight () * 4;
Bytearrayoutputstream out = new bytearrayoutputstream (size );
Try {
Bitmap. Compress (bitmap. compressformat. PNG, 100, out );
Out. Close ();
} Catch (ioexception e ){
E. printstacktrace ();
}
Return out. tobytearray ();
}
Get image:
Bitmap geticonfromcursor (cursor C, int iconindex ){
Byte [] DATA = C. getblob (iconindex );
Try {
Return bitmapfactory. decodebytearray (data, 0, Data. Length );
} Catch (exception e ){
Return NULL;
}
}