Add an SQLite database to an iPhone app?

First of all you need to create your database From the command line create your db file.

First of all you need to create your database. From the command line create your db file. Sqlite3 mydb.

Db Then create the tables within your database CREATE TABLE tags (id int(5), name varchar(255), created_at datetime, updated_at datetime); Repeat that for any tables that you want in your database. Then you need to include the database file in your project. Add the existing database file to your project as you would any other existing file.

Next you will have to link in the framework to interact with the database. This can be found under you current iPhone SDK folder. /Developer/Platforms/iPhoneOS.

Platform/Developer/SDKs/iPhoneOS2.2. Sdk/usr/lib/libsqlite3.0. Dylib Finally you have to include the header file sqlite3. H from /Developer/Platforms/iPhoneOS.

Platform/Developer/SDKs/iPhoneOS2.2. Sdk/usr/include/sqlite3. H It should now be possible to write code to access your sqlite database from within your iPhone application.

2 Note that, while creating a database on a desktop machine and then copying it into the iPhone app may be an expedient thing to do, it is not necessary. You can create a database, initialize the schema, and initialize data from within the iPhone app. – Kristopher Johnson Jan 28 '09 at 14:16.

There is lots of information on the web. Have you looked at the demo application? SQLite Book List This shows examples of common database functions under SQLite.

This is effectively using the standard SQLite C APIs. There are Objective C wrappers which may suite you more. EntropyDB, SQLitePersistenceObjects and FMDB.

I found this Tutorial and this list of resources which may help. Recently I've been using an ORM SQLite.net It is the way to go for me but then I'm developing in MonoTouch C#. Tony.

The QuickLite link above takes you to an annoying website that tries to charge you $29 to give you a recommendation about what SQL wrapper to use. The link is a waste of time, avoid it. – Dan J Nov 3 '09 at 21:18 it never used to.... I'm removing it now.

– AnthonyLambert Nov 4 '09 at 0:33 and it's gone forever. – AnthonyLambert Nov 4 '09 at 0:34.

I'd also recommend looking at FMDB. It makes using SQLite slightly more Objective-C/Cocoa-like. It's not a full ORM wrapper or anything though; it just wraps the C API into something a bit more flavoursome.

sqlite.org/docs.html is a good place to start. You might get more useful help if you are more specific about what you are trying to do, and what obstacles you are encountering.

CoreData should help, but I can't find it anywhere in the list of importable Frameworks. You could take a peek at the iPhone examples, especially the SQLite Book List example.

CoreData isn't available on the iPhone. – Daniel H Feb 3 '09 at 23:47 CoreData is available with the SDK 3.00 beta. – AnthonyLambert May 27 '09 at 14:35.

If you use Firefox, there's this handy addon that you can use to manage and create an SQLite database.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions