I have used the following code snippet to read images stored in Blob fields in a SQLite database [created on Windows].
while (rs.next()) {
InputStream is = rs.getBinaryStream(1);
byte[] buffer = new byte[1024];
while (is.read(buffer) > 0) {
fos.write(buffer);
}
However, this does not work when an SQLite database has been created for use in an Android device and images stored in Blob fields in such database. In my tests, files so created using the above code snippet were all in an unrecognizable format.
Use of the following code snippet results in an error.
while (rs.next()) {
Blob imageBlob = rs.getBlob(2);
InputStream is = imageBlob.getBinaryStream(0,imageBlob.length());
//Writing to output file.
byte[] buffer = new byte[1024];
while (is.read(buffer) > 0) {
fos.write(buffer);
}
The error reported is:
java.sql.SQLException: not implemented by SQLite JDBC driver
After having searched through posts in this forum, I understand that Blob is not supported by sqlite-jdbc-3.8.11.2.jar.
It appears that I am failing to read those images that are stored in Blob field using Android's Bitmap class. [B@dde6e5
is an example of a value of an image stored in the Blob field of the Android SQLite table.