Import SQLite-SQLite basic tutorial in the Project (1)

Source: Internet
Author: User
Statement

You are welcome to repost this article, but please respect the author's Labor achievements. repost this article and keep the statement in this box. Thank you.
Article Source: http://blog.csdn.net/iukey

SQLite is implemented in pure C, so it is doomed to be a cross-platform tool that can be used in both Android and iOS, and can completely write common code for us to transplant. Of course, SQLite has been encapsulated in Android and IOS for developers, but this is inconvenient to transplant, and we do not know the efficiency after encapsulation, therefore, it is still the best in the original ecology. The last important reason is that native usage is quite simple. I will explain it to you in the next tutorial.

First, the most important thing is to import SQLite into the project. Apple's SDK has already included it for you, so you only need to import a framework called libsqlite3.0.dylib. Then, include the corresponding header file: # Import
"Sqlite3.h ".

The import of the IOS project is over and you can use it normally.

In other projects, such as Android, embedded Linux, we need to add two files please go to the http://sqlite.org/download.html to download the corresponding files, which platform you use corresponds to which file, but I'm usually the first sqlite-amalgamation-3071000.zip
Which contains a sqlite3.c and a sqlite3.h. I dragged the two files directly to my project and included the. h file where I needed it. The advantage of calling the compiled library is that I can debug it more conveniently and make some modifications to its functions. For example, I can add my own encryption method in it, or I can add several callback functions to facilitate interaction with the upper layer. You can also delete unnecessary functions to reduce code redundancy.

In my next explanation, I will use pure C to explain. Although I will write code in Apple's xcode environment, except for the reference methods of libraries, everything else is the same, I will try to avoid platform-related things. Of course, sometimes I may write a demo with a UI. At this time, I will inevitably deal with the platform. However, the key point of this tutorial is to understand the underlying principles and learn how to call SQLite APIs, encapsulate and provide interfaces as needed.

The following figure shows how to import SQLite to xcode 4.2:

Click the plus sign. Search for sqlite3, select sqlite3.0.dylib, and click Add. Then you will see the library imported in the project. Then import the header file where you want to call it:


Now let's get to the end. I hope you can give me some motivation to write more. Thank you.


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.