tags:

views:

28

answers:

1

Hi, I'm trying to open a database that I have in my project inside Resources.

The problem is that it seems that its impossible to find the database file! I tried with the complete path, and it works, but this is not a good solution.

I would like to now how to open it!

I'm using this code: db = [FMDatabase databaseWithPath:@"bbdd.sql"];

I don't know how to find the other part of the "actual" path.

Do you have a solution for me?

Thanks!!!!

A: 

You need to find the full path of the database in the your resource bundle, something like this :

NSString *databasePath = [[NSBundle mainBundle] pathForResource:@"mySQLiteDatabaseFile" ofType:@"sqlite3"];

There's a complete example in this thread http://stackoverflow.com/questions/2170740/copying-data-to-the-application-data-folder-on-the-iphone

Jimmy Selgen Nielsen
But I still have a problem it opens this long address the path it opens is:/Users/nameOfUser/Library/Application Support/iPhone Simulator/3.2/Applications/5399D73E-F31A-46B1-94B1-EAD3E2B96D6E/appName.app/bbdd.sqlAnd the path that I need is:/Users/nameOfUser/Folder1/Folder2/appName/bbdd.sqlI need to know how to get the path of the folder where the project is to open the database.
victorvj