I can’t figure why db.sqlite can’t be found. I added it to the resource dir of the project. It is there.
Here is some code how I check for existing.
-(void)getDatabaseLocation
{
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = [dirPaths objectAtIndex:0];
// Build the path to the database file
NSString *databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"db.sqlite"]];
NSFileManager *filemgr = [NSFileManager defaultManager];
if ([filemgr fileExistsAtPath: databasePath ] == NO)
{
NSLog(@"NO"); // It's say no when this method is called.
}
else
{ NSLog(@"YES");
}
}
//EDIT
Now I check that the path in docsDir doesn’t exist.
Of course it isn’t there. You must first copy the resource to the documents directory, like this:
EDIT: If you only need to do lookups on the database (no editing), then you can simply do this: