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...
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"];
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.
精彩评论