How can I use SQLite blob type to store picture voice files.
It is known that the current received is a picture or voice of the URL address, can be stored in the SQLite database when the image or voice through the received URL to the address of the SQLite database.
Thank you.
Reply content:
How can I use SQLite blob type to store picture voice files.
It is known that the current received is a picture or voice of the URL address, can be stored in the SQLite database when the image or voice through the received URL to the address of the SQLite database.
Thank you.
1, httpconnect obtain picture data;
2. Transform the image data into a binary system to write to the database
Contentvalues values = new Contentvalues ();
Final Bytearrayoutputstream os = new Bytearrayoutputstream ();
Bmp.compress (Bitmap.CompressFormat.PNG, MB, OS);
Values.put ("Express_img", Os.tobytearray ());
Values.put ("Express_name", "ZF");
Values.put ("Express_no", "ZF");
Getcontentresolver (). Insert ("Express", values);
3. Read bitmap from SQLite
Byte[] In=cur.getblob (Cur.getcolumnindex ("express_img"));
Bmpout=bitmapfactory.decodebytearray (in,0,in.length);
4, displayed on the ImageView
ImageView ImageView = (ImageView) View.findviewbyid (r.id.img);
Bytearrayinputstream stream = new Bytearrayinputstream (Cur.getblob (Cur.getcolumnindex ("express_img"));
Imageview.setimagedrawable (Drawable.createfromstream (Stream, "img"));
$url = "http://....../logo.png"; $handle = fopen($url,"rb"); $contents = fread($handle,filesize($url));
Var_dump ($contents);
Why do I read a picture of a URL as a binary with output $contents: bool (FALSE)