views:

393

answers:

2

Hi everybody,

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... 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

+3  A: 

Use BitmapFactory.decodeByteArray().

Daniel Lew
thx for the hint, i'll have a closer look and come back to you if I don't find.
Sephy
+3  A: 

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.

systempuntoout
that's exactly what i did, but i was using drawable so I added a cast, but i don't think i need it. thanks for the help guys. thanks for the detailed explanation here
Sephy
however, i'm getting a nice "return null" from the BitmapFactory...
Sephy
decodeByteArray method return null if the image could not be decoded; check your code that store to db.
systempuntoout