Search code examples
objective-ciossqliteios-simulatorfmdb

sqlite program works on simulator, not on device


I'm running a SQLite searching program on the iOS simulator in xcode, and it works perfectly, however, when I run it on my iPhone it gives me an error saying "error opening!: 14" I'm guessing it's the database path, but I have no idea what to do to fix it.


Solution

  • Documents path :

        NSArray *arrayPathComponent=[NSArray arrayWithObjects:NSHomeDirectory(),@"Documents",@"yourdatabasename.sqlite",nil];
    destinationPath=[NSString pathWithComponents:arrayPathComponent];
    

    Use this destination path for your database operation. But create your database at this path. This will work on your device also.