SQL Lite Usage and Preloading of data

I have a query regarding data. I have a data of 500 records and 4 to 5 columns. I want user to enter some thing and then my app will search from the available records if that data exists.As i am new to app development so may be i have some beginer questions to ask so dont mind 🙂

1) Should i use SQL Lite to keep the data in the app ? once in a month i want app to contact the server for record's updating purpose

2) how to prepopulate the data into the sql lite when the app is installed first time

3) should i use sqllite desktop interface to create a db and then import it via xcode to the app project and then from there it will start using it?

can u please send me link to study it and then implement it.

or if some one can give me hint about how to pre load the data in the sql lite data base?


Thanks in advance for your response 🙂

The following answers assume you're talking about iOS app development. This isn't a Swift language related question so you should probably move this thread to a more appropriate forum.


1. SQLite is a reasonable choice for that. Core Data may be another option though it has a steeper learning curve.


2. You can include an initial database in your bundle (or as an on-demand resource if it's hundreds of megabytes, but based on your description, sounds like the bundle would work). Upon initial installation (first run) you would check for the existence of the database in a writable location - typically Application Support - and if it doesn't yet exist, then you would copy the database file from the bundle to the writable location using NSFileManager methods.


3. That's the way I do it. I have also been known to write quick and dirty OS X GUI or command line programs to populate a DB. Another option that sometimes makes sense (particularly if the initial DB contents is just a cache of something you download) is to create and populate the database in your iOS app code, and then copy the database file from the device or simulator's app container.


Myself, for SQLite access I use the FMDB wrapper. It simplifies the API quite a bit.

2. You can include an initial database in your bundle (or as an on-demand resource if it's hundreds of megabytes, but based on your description, sounds like the bundle would work). Upon initial installation (first run) you would check for the existence of the database in a writable location - typically Application Support - and if it doesn't yet exist, then you would copy the database file from the bundle to the writable location using NSFileManager methods.

The one gotcha with this approach is that you have to make sure you comply with the iOS Data Storage Guidelines.

Avoid this problem in the general case is actually quite tricky. However, depending on your specific data requirements there may be shortcuts. For example, if the user just appends data to the database—never modifies or deletes any of the default records—you can simply open both databases and merge the results.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

DTS will close for the winter holidays at the end of business on Wed, 23 Dec 2015 and re-open on Mon, 4 Jan 2016.

SQL Lite Usage and Preloading of data
 
 
Q