Вопрос

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"]];
Это было полезно?

Решение

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.

Другие советы

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;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top