Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 16, 2008, 01:14 AM   #1
sujithkrishnan
macrumors 6502
 
Join Date: May 2008
Location: Bangalore
Send a message via Yahoo to sujithkrishnan
How to add sqlite db to iphone simulator.

Hi all..

I tried a sample app and found (by watching memory during debugging that the app is looking for a books.sql databse in application Document directory.

Line in app is as follows...

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

But the folder specified above is not visible in my PC so that i can put the books.sql file into that folder.

That folder is created only after launching the simulator.

So my question is that how to direct my iPhone app to a fixed filepath...

Whether that file get ported to device if i put in some other folder and specify that path??

I want read and write actions on that database..

PLEASE HELP ME WITH A DETAILED REPLY.....

{ I read that adding as a resource will give us only read permission, we cant write to DB }

thanks in advance...
sujithkrishnan is offline   0 Reply With Quote
Old May 16, 2008, 01:38 AM   #2
mysticwhiskey
macrumors newbie
 
Join Date: Mar 2008
Quote:
Originally Posted by sujithkrishnan View Post
I read that adding as a resource will give us only read permission, we cant write to DB
Hi,

Not true, I have included an SQLite database as a resource in one of my iPhone projects, and had no problems writing to it.

Another alternative would be to programmatically create the SQLite database at a particular path on the iPhone when your application first launches, if it's not already there to begin with.
mysticwhiskey is offline   0 Reply With Quote
Old May 16, 2008, 11:55 AM   #3
DJPaul
macrumors newbie
 
Join Date: Oct 2007
Take a look at the SQLiteBooks sample app. Basically, on startup, check to see if your database file exists in the Documents directory (e.g. the path in the sample code you pasted below) and open that. If the file doesn't exist, then copy your SQLite DB file out of the Bundle to the Documents directory.
DJPaul is offline   0 Reply With Quote
Old May 19, 2008, 01:56 PM   #4
tommyh1122
macrumors newbie
 
Join Date: May 2008
Hello,

I looked at the SQLiteBooks example and was wondering how to create the bookdb.sql file. It looks to me that the this is the file that creates the book database and has the statements that inserts the 3 records. How do you create the file and in the file do you have to include the sqlite3 my_database.sqlite statement as well?

Thanks
tommyh1122 is offline   0 Reply With Quote
Old May 19, 2008, 04:55 PM   #5
mysticwhiskey
macrumors newbie
 
Join Date: Mar 2008
Quote:
Originally Posted by tommyh1122 View Post
Hello,

I looked at the SQLiteBooks example and was wondering how to create the bookdb.sql file. It looks to me that the this is the file that creates the book database and has the statements that inserts the 3 records. How do you create the file and in the file do you have to include the sqlite3 my_database.sqlite statement as well?

Thanks
That file is the database. You can create such a file using an SQLite manager type of utility, or even create it programmatically using C if you know what you're doing.
mysticwhiskey is offline   0 Reply With Quote
Old May 19, 2008, 07:05 PM   #6
tommyh1122
macrumors newbie
 
Join Date: May 2008
Thanks mysticwhiskey,

Would you have any recommendations on a good SQLite manager utility.

Thanks
tommyh1122 is offline   0 Reply With Quote
Old May 19, 2008, 09:07 PM   #7
Delirium39
macrumors regular
 
Join Date: May 2008
The readme.txt file included with the SQLiteBooks project has instructions on how to create the database file via Terminal, and some basic instructions for creating tables.
Delirium39 is offline   0 Reply With Quote
Old May 19, 2008, 10:37 PM   #8
mysticwhiskey
macrumors newbie
 
Join Date: Mar 2008
Quote:
Originally Posted by tommyh1122 View Post
Thanks mysticwhiskey,

Would you have any recommendations on a good SQLite manager utility.

Thanks
If you use Firefox, there's a free Firefox add-on to manage SQLite databases:

http://addons.mozilla.org/en-US/firefox/addon/5817
mysticwhiskey is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Anyone else have huge iPhone simulator? HawaiiMacAddict iPhone/iPad Programming 14 Jul 16, 2014 03:30 PM
[Free][Game] Truck Simulator 3D - real simulator! MarusacAlexandr iPhone and iPod touch Apps 0 Jan 11, 2014 01:43 AM
[Free Game] Bus Simulator 3D - real bus simulator driving ! MarusacAlexandr iPad Apps 0 Oct 7, 2013 02:29 AM
[Free Game] Bus Simulator 3D - real bus simulator driving ! MarusacAlexandr iPhone and iPod touch Apps 0 Oct 7, 2013 02:27 AM
iPhone simulator DShap5 iPhone 3 Mar 15, 2013 11:40 AM

Forum Jump

All times are GMT -5. The time now is 02:55 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC