1

I am making one IOS application in which will be using core data and I want to save image in database can anyone tell me how to upload image in Sqlite Database Browser?

1
  • If you are using Core Data why are you asking about SQLite? Commented Oct 15, 2013 at 8:39

3 Answers 3

2

To store image in Sqlite Database using core data u need to convert image to data for example

NSData *photo_data = UIImagePNGRepresentation(aImage);


Now u can store this photo_data. In core data model u create a attribute of type "Binary data"

use this attribute while storing the image data.

Sign up to request clarification or add additional context in comments.

5 Comments

What if,I want to store 30 images simultaneously then how to do it?
since image sizes are more better u can save image names and get particular image by using name it the best way, in general. store all images in one folder and access them using path.
and performance side also it is good, better see this answer stackoverflow.com/questions/4158286/storing-images-in-core-data
Thanks, Shan for the above solution but my images will be coming from server and that too dynamic that means I will be getting binary data that I was thinking to store in database.Please provide your thoughts.
Hmmm , well since u have more data, better u save them in one location i,e for example in a folder, store location of this folder in core data to get the images to display. i think this is the best way to handle images with big data and it is simple and efficient way.
0

You can't just slap in an image file into sqlite. you need to transform the image into a format such as base64 or something that can be stored. when you want to retrieve the image you must transform it back into its original form. for most cases all you need to do is store the path to the image, and not the image itself.

Comments

0

You can use blob object at sqlite. First of all you transform your image to NSData type:

NSData *uiimage=UIImagePNGRepresentation(im);

After bind your datas as blob object such as :

sqlite3_bind_blob(statement,.., [uiimage bytes], [uiimage length], SQLITE_TRANSIENT);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.