12 SQLite Resources for iPhone Developers
There are plenty of different places to get a mobile application designed. The problem is that they’re quite expensive. You might be able to figure out how to create your own, but it will probably look very basic. Instead, a good mobile application development software can make it even easier, so that you can build great looking apps all by yourself.
The Mobile design Starter Kit includes all the themes and scenarios you need to build whatever app you want. There are customizable and standard files that allow you to sell or offer anything you want through the kit. Everything is there, so once you spend the money, you can create as many mobile apps as you want – and even sell the apps if this is your thing.
SQLite is a public domain database library that offers file and memory based relational database functionality from a single C library. The iPhone / iPod Touch has the SQLite library included and ready to roll and Apple expects the SQLite library to form the backbone of most applications’ data storage requirements.
We’ve collected together some of the best SQLite related tutorials, and libraries in order to help you on your way with this essential iPhone programming technology:
Tutorials
iPhone SQLite Database Basics by Lee Falin is a comprehensive introduction to using SQLite in respect to iPhone application development. He covers SQLite database creation and iPhone specific database design considerations well. Lee’s tutorial has lots of screenshots and he takes a step-by-step approach that’s easy to follow. He walks through creating an SQLite database from scratch (on the desktop to start with) and then imports that into an XCode project. Bear in mind, however, that Lee’s tutorial is not about the actual coding necessary to use SQLite on the iPhone itself.
Reading data from a SQLite Database by Dean Collins is a wonderful “start to finish” tutorial that covers creating an SQLite database, creating an XCode project, and then all the code necessary to use that database within an iPhone app. There’s even a link to an archive of the code used in the tutorial so you can more quickly try it out for yourself.
SQLite Tutorial 1: Selecting Data by Jai Kirdatt is the first in five SQLite focused tutorials from the aforementioned author. This one covers creating an SQLite database and, like Dean’s tutorial above, using that database from Objective C. There’s more code and less screenshots than in the aforementioned tutorials, so this tutorial is worth coming to once you’re totally confident with the basics. Source code is available to download at the bottom of the post.
SQLite Tutorial 2: Deleting Data by Jai Kirdatt follows on nicely from the previous tutorial and quickly demonstrates how to delete rows of data from an SQLite database.
SQLite Tutorial 3: Adding Data by Jai Kirdatt demonstrates how to add data to an SQLite database from Objective C.
SQLite Tutorial 4: Loading Data As Required by Jai Kirdatt shows how to select rows in a database to then display in a detail view. Data is only loaded when it is required.
SQLite Tutorial 5: Updating Data by Jai Kirdatt shows you how to update the database when fields on a form are edited and the application is then terminated.
Libraries
EntropyDB is an embedded object database for OS X 10.5 and iPhone OS written in Objective C that’s built on top of SQLite. It provides a nicer API than that offered by SQLite directly. You don’t need to use SQL at all, but instead just work with Objective C objects!
SQLitePersistentObjects allows you to call “save” on your objects and trust that they will be saved properly and can be easily reloaded in future. No SQL required.
FMDB is a library that acts as a wrapper around SQLite – inspired by JDBC. fmdb-migration-manager (originally by last week’s podcast interviewee – Dr Nic Williams) allows you to easily roll out database migrations using fmdb.
iPhone SQLite Persistence for Objects is an open source project that lets you add “object persistence” to your applications. The object persistence uses SQLite, and the library works on both the iPhone and iPod Touch.
Suggestions?
Know of any others? Leave a comment and we’ll do our best to include them!
Also note an ActiveRecord-like lib on github:
https://github.com/aptiva/activerecord/tree/master
There are lots of hows and whys of using SQLite at http://www.squidoo.com/sqlitehammer.
There’s also Quicklite https://www.webbotech.com. Google around for an ars technica report for how to use quicklite in CocoaTouch.
Hi!
Thanks for linking to my SQLite tutorial, I am currently writing a multi-part series on creating a whole application from start to finish including publishing to the App Store. It will use SQLite, TouchXML, Drill-down UITableViews, UIWebViews and much more!
The first installment is available at https://dblog.com.au/iphone-development/rss-reader-part-1-getting-started-with-iphone-development/
You can also follow me on twitter at @bigclick_dean to get notified of when the next installments are out.
Stay Tuned!
-Dean
Check out StepSqlite PL/SQL compiler for SQLite at https://www.metatranz.com/stepsqlite
It has an option to compile DB interface written in PL/SQL directly to a static library for use in iPhone apps.
Here’s the wrapper that I like. I looked at several, and this one has the simplest implementation (1 class, about 350 loc) and simplest usage. If you’re just looking for a better interface with Sqlite, and not a whole ORM layer, you should look at this one. The learning curve is 5 min and you keep access to the full power of SQL.
I don’t think it has a real name. https://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/
If you’re trying to avoid SQL, you should look at the ActiveRecord implementation. It was nice and not too much cognitive overhead. But as with most ORM, it’s difficult to do complex SQL like multi-level self-joins that are grouped by calculated columns and nested queries. You don’t always need that stuff, but just knowing you can’t…
If you’re just looking for a quick way to take a look at existing iPhone application SQLite data I’ve written a How to view iPhone application data tutorial that uses the great SQLite Manager Firefox plugin.
With the advent of Core Data, it would be nice to construct a tutorial on Core Data. I do not anything about Core Data, but I am willing to participate in constructing a tutorial.