Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009

Insert Image into SQLite

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?

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009

Re: Insert Image into SQLite

any ideas!!!!

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Developer
rcmaniac25
Posts: 1,789
Registered: ‎04-28-2009
My Carrier: Verizon

Re: Insert Image into SQLite

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.

------------------------------------------------------------
Three simple rules:
1. Please use the search bar before making new posts.
2. Kudo posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
New Contributor
kinjalshah_5320
Posts: 9
Registered: ‎07-02-2012
My Carrier: Blackberry

Re: Insert Image into SQLite

Hey i also want to store image into Database...

Have you got solution?

Plz help me..I am new to Blackberry..

Please use plain text.
New Contributor
kinjalshah_5320
Posts: 9
Registered: ‎07-02-2012
My Carrier: Blackberry

Re: Insert Image into SQLite

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

Please use plain text.
Developer
kamal_nigam
Posts: 416
Registered: ‎07-23-2012
My Carrier: Orange

Re: Insert Image into SQLite

Use byte array to store data.

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Please use plain text.