Reputation: 12617
I want to open a database.sqlite3. Firstly, I need to get a path. But I don't know how to get this path.
I need a relative path.
EDIT: I don't want to use NSBundle. It get a very long path.
I want to use /Users/Voloda2/Projects/facebook/database.sqlite3 Is it possible to get a relative path?
EDIT2: I often change my database. I use Navicat for this operation. If I use NSBundle I have one problem. git did't indexed my database because it didn't lies in project folder. Thus I need to lay my database to project folder.
straight path is /Users/Voloda2/Projects/facebook/database.sqlite3
relative path something like this ../database.sqlite3
Relative path is a path relative to project folder. Is it possible to get a relative path? May be it didn't possible.
Upvotes: 0
Views: 149
Reputation:
Assuming you're making a regular OS X/Cocoa app, Xcode will copy the database file to the app bundle. So, you can use the NSBundle
class to obtain its path easily:
NSString *databasePath = [[NSBundle mainBundle] pathForResource:@"database" ofType:@"sqlite3"];
Upvotes: 3