My issue is as follows : I have stored a few pictures into the sqlite database, using the blob format, which seems to work ok. now i want to get my pictures out of the DB and put then back into images...开发者_StackOverflow社区 to complicate the matter, their format is variable (png, jpg, maybe something else, im not sure) Is there a way of doing so in android?
thank you
Use BitmapFactory.decodeByteArray() method:
byte[] blob=c.getBlob("yourcolumnname");
Bitmap bmp=BitmapFactory.decodeByteArray(blob,0,blob.length);
ImageView image=new ImageView(this);
image.setImageBitmap(bmp);
Look at this thread too.
Use BitmapFactory.decodeByteArray().
I prefer to convert the array of bytes to Drawable directly. It is the best format to use in Android. Bitmaps generated leaks in the past.
Drawable d = Drawable.createFromStream(new ByteArrayInputStream(ARRAY_BYTES), null);
精彩评论