Possible Duplicate:
Reading and writing images to an SQLite DB for iPhone use
How to store a images file in database in blob type in sqlite database and how to retrieve a image from the database.
save image in your nsdocument directory. in database save the path of this image. this is a good approach. if u save blob in data base database will so heavy. it take time to load.
First convert image into NSData
Then NSData into bytes
Then store that bytes...
Sorry I don't know the method that should be called, because I use core data which is far better than sqlite c api
The easiest way is to use an Objective-C sqlite wrapper such as fmdb. Then you can pass an NSData handle from UIImagePNGRepresentation() into the wrapper as a blob.
Alternatively, you could do something like this:
NSData *rawImage = UIImagePNGRepresentation(myUIImage);
sqlite3_bind_blob(mySavedSQLStatement, 2, [rawImage bytes], [rawImage length], SQLITE_TRANSIENT);
精彩评论