Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FMDB open database

Tags:

fmdb

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!!!!

like image 422
victorvj Avatar asked Feb 16 '26 11:02

victorvj


1 Answers

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 Copying data to the Application Data folder on the iPhone

like image 161
Jimmy Selgen Nielsen Avatar answered Feb 21 '26 14:02

Jimmy Selgen Nielsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!