Question

Hello i'm using FMDB to use SQLite database. And i have next code:

FMDatabase *db = [FMDatabase databaseWithPath:@"stories_db.sqlite"];
[db open];
FMResultSet *resultsFavorite = [db executeQuery:@"SELECT * from favorites"];

But there is error shown on [db open];

2013-10-23 11:08:22.951 Pasakas[1013:a0b] error opening!: 14

enter image description here

Maybe i should change the path?

Was it helpful?

Solution

You have to give path of database not name of database,

try with

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *path = [docsPath stringByAppendingPathComponent:@"stories_db.sqlite"];

FMDatabase *db = [FMDatabase databaseWithPath:path];
[db open];
FMResultSet *resultsFavorite = [db executeQuery:@"SELECT * from favorites"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top