Implementation Code for writing data to the database:
Nsarray * paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes); <br/> nsstring * datapath = [[paths objectatindex: 0] stringbyappendingpathcomponent: @ "SQLite. SQLite "]; <br/> nsdata * image = uiimagepngrepresentation ([uiimage imagenamed: @" 01_02.png "]); <br/> nsstring * AAA = [[nsstring alloc] initwithformat: @ "update cards set c_image =? Where id = 1 "]; <br/> sqlite3 * database; <br/> If (sqlite3_open ([datapath utf8string], & database) = sqlite_ OK) {<br/> sqlite3_stmt * compliedstatement; <br/> databases (Database, [AAA utf8string],-1, & compliedstatement, 0); <br/> sqlite3_bind_blob (compliedstatement, 1, [Image bytes], [Image length], null); <br/> int result = sqlite3_step (compliedstatement); <br/> If (result = sqlite_done) {<br/>}< br/> sqlite3_finalize (compliedstatement); <br/>}< br/> sqlite3_close (database); <br/> [AAA release];
Read implementation code:
Nsarray * paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes); <br/> nsstring * datapath = [[paths objectatindex: 0] stringbyappendingpathcomponent: @ "SQLite. SQLite "]; <br/> sqlite3 * database; <br/> If (sqlite3_open ([datapath utf8string], & database) = sqlite_ OK) {<br/> const char * sqlstatement = "select c_image from cards where id = 1"; <br/> sqlite3_stmt * compliedstatement; <Br/> If (sqlite3_prepare (Database, sqlstatement,-1, & compliedstatement, null) = sqlite_ OK) <br/>{< br/> while (sqlite3_step (compliedstatement) = sqlite_row) {<br/> int bytes = sqlite3_column_bytes (compliedstatement, 0); <br/> const void * value = sqlite3_column_blob (compliedstatement, 0 ); <br/> If (value! = NULL & bytes! = 0) {<br/> nsdata * Data = [nsdata datawithbytes: Value length: bytes]; <br/> uiimage * image = [uiimage imagewithdata: Data]; <br/> [imageview setimage: Image]; <br/>}< br/> else {<br/>}< br/> sqlite3_finalize (compliedstatement ); <br/>}< br/> sqlite3_close (database); <br/>