0

I have a weird problem with my iphone application. I have created an sqlite3 database file with console, and added it to project usint "add existing file..." in resource folder, but when i execute project to test with simulator, application couldn't find the sqlite file. I checked Documents folder (/Users/XXXXXX/Library/Application Support/iPhone Simulator/4.2/Applications/XXXXXX/Documents/) and it's empty :^S Please, this problem is getting me crazy, i'm tired of searching a solution through web, could someone help me? Thanks in advance...

2 Answers 2

2

It does not go to the documents - it goes to your bundle as resources. To find out the path, use the following:

NSString *Path = [[NSBundle mainBundle] pathForResource: @"myfilename" ofType:@"db"];
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much @viggio24 and @Seva Alekseyev!!! both are right! Finally i used NSString *databasePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: sqliteFileName]; :D:D:D:D
1

If you added it to XCode then the file is in the bundle, so you must check this path:

[[NSBundle mainBundle] bundlePath]

instead of the Documents folder.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.