I would like to insert an image into ultralitej-db (Android) and later get it from db to display it again. I'm able to insert and select it from db but the displayed image is all black. insert-code:
select-code:
UPDATE it seems that the insert is wrong. i selected other images which are already stored in the db. they are displayed correctly. |
better late than never. i found the solution for my problem. it was a converting/format thing with jpeg. i used
thanks to all who gave me advices to solve the problem |
Hi - can you post the SQLA Version you are using
will find it.
i'm using SQLA 16.0
Is this ULj for BlackBerry or Android - I ask because Android uses JNI to access the native UL runtime code.
I ran a quick test on Android in which I retrieve a good image from the database and write it back into a new row. That image is set correctly. This is based on your code where the image is set in the prepared statement update as:
I guess the question is is "photo" a good value when you write it to the output stream?
photo is an byteArray of the Image. The code to obtain the byteArray from the image is:
ByteArrayOutputStream bos = new ByteArrayOutputStream(); mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
byte[] bArray = bos.toByteArray();
Have you verified that the bos after you you loaded the file and compressed the bitmap looks correct before storing it to the database. The database will only store the information that it is provided. I have modified by test application to implement the Bitmap.compress() and assign the ByteArrayOutputStream's byte array into the prepared statement. I am not seeing any problems with the image in my tests.