IPhoneLearningSqlite DatabaseRead/writeImageExamples are the content to be introduced in this article. There is not much content, basically based on code implementation. Let's take a look at the content. UseIPhoneOfSqlite DatabaseRead/writeImageFirst, convert your image to the NSData format, and thenDatabaseAdd a row of blob data. The code below isImage):
- NSMutableString * insertSql = [[NSMutableString alloc] initWithString: @ "insert into"];
- [InsertSql appendString: BLOB];
- [InsertSql appendString: @ "("];
- [InsertSql appendString: BLOB_DATA];
- [InsertSql appendString: @ ") VALUES (? 1) "];
- Sqlite3_stmt * insert_statement = nil;
- Sqlite3 * database = your database;
- If (sqlite3_prepare_v2 (database, [insertSql UTF8String],-1, & insert_statement, NULL) = SQLITE_ OK ){
- Sqlite3_bind_blob (insert_statement, 1, [data bytes], [data length], NULL );
- If (sqlite3_step (insert_statement )! = SQLITE_DONE ){
- NSLog (@ "Db error % s", sqlite3_errmsg (database ));
- }
- } Else {
- NSLog (@ "Db error % s", sqlite3_errmsg (database ));
- }
- Sqlite3_finalize (insert_statement );
- [InsertSql release];
Summary:IPhoneLearningSqlite DatabaseRead/writeImageI hope this article will help you with the introduction of the instance!