Hi all,
I am currently trying to store an image into the sqlite database as
a blob and retrieve it back.I am not sure if this is the correct
approach since i dint find much of sample codes related to inserting
images in sqlite.
//creating blob datatype
db.execSQL("CREATE TABLE IF NOT EXISTS "+dbTable+"(image BLOB);");
//getting a sample image from drawable folder inside my project
InputStream xmlInputStream = this.getResources().openRawResource
(R.drawable.abc);
//convert it into a byte
byte[] bb = (xmlInputStream.toString()).getBytes();
//try inserting the byte into sqlite
db.execSQL("INSERT INTO "+ dbTable + "(image)" + " VALUES
(\""+bb+"\");");
I am able to insert values but when i try retrieving them as byte
using decodeByteArray it gives me the following error.
DEBUG/skia(13003): xxxxxxxxxxx jpeg error 53 Not a JPEG file: starts
with 0x%02x 0x%02x
The image retrieving query works fine as i have checked retrieving an
image previously stored as blob in a sample database.
I have tried storing and retrieving different image files but i am
getting the same error.Could any one tell me as how to solve this
problem
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---