IPhone learning Sqlite database read and write image instances

Source: Internet
Author: User

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):

 
 
  1. NSMutableString * insertSql = [[NSMutableString alloc] initWithString: @ "insert into"];
  2. [InsertSql appendString: BLOB];
  3. [InsertSql appendString: @ "("];
  4. [InsertSql appendString: BLOB_DATA];
  5. [InsertSql appendString: @ ") VALUES (? 1) "];
  6. Sqlite3_stmt * insert_statement = nil;
  7. Sqlite3 * database = your database;
  8. If (sqlite3_prepare_v2 (database, [insertSql UTF8String],-1, & insert_statement, NULL) = SQLITE_ OK ){
  9. Sqlite3_bind_blob (insert_statement, 1, [data bytes], [data length], NULL );
  10. If (sqlite3_step (insert_statement )! = SQLITE_DONE ){
  11. NSLog (@ "Db error % s", sqlite3_errmsg (database ));
  12. }
  13. } Else {
  14. NSLog (@ "Db error % s", sqlite3_errmsg (database ));
  15. }
  16. Sqlite3_finalize (insert_statement );
  17. [InsertSql release];

Summary:IPhoneLearningSqlite DatabaseRead/writeImageI hope this article will help you with the introduction of the instance!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.