Question

i'm building an app with sqlite db using FMDB,

on simulator everything works fine,on jailbroken iPhone everything works fine, But on idevice with developer account i get this error

error opening!: 14

i create the db like this

NSString *bundelpath = [[NSBundle mainBundle]bundlePath];
[FMDatabase databaseWithPath:[bundelpath stringByAppendingFormat:@"/database.db"]];
Was it helpful?

Solution

SQLite is attempting to open a file with read/write permissions in a location that is read only in a fully sandboxed application on a real device.

This documentation from Apple explains where you can and cannot write.

Most likely you want to use <Application_Home>/Documents/ as the path.

The simulator runs without an additional Sandbox and applications running in it are capable of writing anywhere in the development host's filesystem.

Presumably your jailbreak has also defeated the application sandbox.

OTHER TIPS

Marko is right. Here is the correct way to get the documents directory.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top