I have a long binary field in an Android UltraliteJ database and when I insert a value into it the byte array is around 800-900K in length. However, when I select it out it's less than 64K and not an image. The length returned varies depending on the length of the byte array I inserted. If I compress the image so it's around 20K it is returned from the select statement as the same size and is displayed as an image.
The database is in the applications Data folder on a Galaxy Nexus, Android version 4.0.1.
This is version 22.214.171.12437.
Is this is a bug or are long binary columns limited to 64k on Android?
EDIT I've tried both resultset.getBytes(x) and resultset.getBlobInputStream and both have returned the same byte array (the wrong one).
PreparedStatement command_statement; command_statement = connection.prepareStatement(commandText); command_statement.set(x + 1, byteArray); Log.v("Test","Insert Byte Array - " + Integer.toString(byteArray.length));
After consulting with Chris, I have determined that this is a bug with PreparedStatement.set(int,byte). The byte array is limited to 32 KB in size right now. I will fix that in an upcoming release. There is no such limitation on long binary columns in UltraLite databases, and, as a workaround, you could use PreparedStatement.getBlobOutputStream(int) to get a java.io.OutputStream, and use that to write the value into the long binary field. Thanks.
answered 18 Apr '12, 13:53