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?
Asked
Active
Viewed 2,157 times
3 Answers
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.

Shankar BS
- 8,394
- 6
- 41
- 53
-
-
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. – Shankar BS Aug 29 '13 at 12:30
-
and performance side also it is good, better see this answer http://stackoverflow.com/questions/4158286/storing-images-in-core-data – Shankar BS Aug 29 '13 at 12:32
-
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. – Neha Aug 30 '13 at 07:43
-
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. – Shankar BS Aug 30 '13 at 08:01
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.

Divya Bhaloidiya
- 5,018
- 2
- 25
- 45
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);

erdikanik
- 674
- 9
- 11