Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sujithkrishnan

macrumors 6502
Original poster
May 9, 2008
265
0
Bangalore
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...
 

mysticwhiskey

macrumors newbie
Mar 31, 2008
25
0
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.
 

DJPaul

macrumors newbie
Oct 26, 2007
24
0
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.
 

tommyh1122

macrumors newbie
May 19, 2008
8
0
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
 

mysticwhiskey

macrumors newbie
Mar 31, 2008
25
0
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.
 

tommyh1122

macrumors newbie
May 19, 2008
8
0
Thanks mysticwhiskey,

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

Thanks
 

Delirium39

macrumors regular
May 19, 2008
205
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.