I have the following problem. An application that has a sqlite database. I run the application in xcode, with the simulator. I have the following code to know where I have to put the database.
sqlite3 *bd;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *dbPath = [documentsDir stringByAppendingPathComponent:@"bd.sqlite"];
NSLog(@"bd route is ---- %@",dbPath);
So I get the path, and copy the sqlite database, so the application works perfectly in xcode. The problem is when I connect my iphone and try to run the application. Because the previous code gives me a route on the iphone, and I try to put the sqlite database there but it does not run, the application is blocked because it cannot find the database, even if I put it there. I don't know if what I am doing is correct or there is another way to do it. I'm going crazy looking for possible solutions on the internet, but none works for me and I've been standing for 3 months trying to run the application on the iphone. Please, some help or advice, I would appreciate it. Many thanks.
1. In Xcode's Project Navigator (View > Navigators > Show Project Navigator) at the left of screen, click on Info.plist
2. Press the + button that is to the right of the first line "Information Property List" and then, in the box that appears, type "Application supports iTunes file sharing". The Type property should be Boolean and the Value "YES"
3. Compile the app onto your device.
4. With the device connected to your Mac, open iTunes and click the small device icon near the top left of screen. You should then see a list of options on the left of screen: click File Sharing.
5. You should then see your app listed, so click on it.
6. Scroll to the bottom of the panel at right to show the "Add" button and then click it.
7. Select your database file from your Mac's storage and press the blue Add button, then press the blue Done button.
8. Your database file will (should) now be in the correct location for use by your app.
NOTE that you can also Save your database file from your device, via iTunes, to your Mac, and then examine the database on your Mac if you have appropriate SQLite reader software. I use RazorSQL, but there are free Mac versions such as "DB Browser for SQLite". If you are doing a lot of database work, then getting a Mac-based browser is well worth it.
Good luck and best wishes, Michaela