12-29-2009 01:04 AM
Hi all,
am working on 5.0. i need to save an image to the sqlite database. how can i make that?
is it possible to save the image in sqlite for blackberry? what are the supporting data formats?
12-29-2009 04:38 AM
any ideas!!!!
12-29-2009 09:11 AM
I have never used the database classes so this might not work but from what I suppose is the class you use to store data (Statement?) you could save the image as an array of bytes.
07-28-2012 01:45 AM
Hey i also want to store image into Database...
Have you got solution?
Plz help me..I am new to Blackberry..
07-31-2012 01:15 AM
Hey I got solution..and its work perfectly fine..
For inserting,
EncodedImage pic = getImage();
byte [] imageBytes = pic.getData();
Statement st = db.createStatement("INSERT INTO Image (image_data) values (?)");
st.prepare();
st.bind(1, imageBytes);
st.execute();
And for Fetching,
Statement st = db.createStatement("SELECT image_data FROM Image");
st.prepare();
Cursor c = st.getCursor();
Row r;
while(c.next()){
r = c.getRow();
byte[] pic=r.getBlobBytes(0);
EncodedImage _bmap = EncodedImage.createEncodedImage(pic,0, pic.length);
BitmapField bmf=new BitmapField(_bmap.getBitmap());
add(bmf);
}
st.close(); // moved this line out of the loop
07-31-2012 01:48 AM
Use byte array to store data.