Using SQLite on the iPhone: do I have to read the entire database and store it into an array

Hi I am a newbie to iPhone programming. I have been looking at some tutorials online for using SQLite on the iPhone.
From what Iv'e seen, one has to read the entire database in the app delegate method and then store the contents in an array. This is then used to populate a UITableView.

I was wondering how this can be efficient? I mean, if you are going to store the contents of your entire database in memory why have a database?

Is this standard practice?

Instead of this, if I use Core Data, I can set the paging size and it will optimize how much data is stored in memory and only read whats being shown within the visible cells.

Is there anyway, In can have the same functionality using SQLite? so its easy on memory. I mean my database has only 300 entries now, but what if in the future it has 3 million?

Can some one please assist me in understanding this....

Are there any tutorials for SQLite that show how to do it in an optimized way?

Thanks

I would suggest using Core Data. It's extremely powerful, better supported than a SQLite table, and not as complicated as it looks, it just uses a lot of "managed object" jargon which can be daunting at first. Check out the CoreDataHelper class, and a few tutorials. I was able to get Core Data working in a few days (in my first ever app) using the links in my comment

If you're familiar with SQL, basically Core Data works like this: the Persistent Store IS a SQLite table, but you never access it directly; the managedObjectContext is where you do all the data work in your program (and don't forget to save it to the persistent store!), while an Entity is a table, attributes of that entity are your columns, and a managed object is a row.

Further Reading:

here are some tutorials
sqlite tutorial loading data as required,
iPhone Programming Tutorial,
iPhone SDK Articles that may help you

I recommend you consider using core data instead of sqlite

Related Articles
You Might Also Like