Wishing someone might help a brand new iOS developer out - I've got a ready to use sqlite database known as teamresults.db which i put into the project using "Add Files..." however when I am while using below code I appear to become hooking up/referencing a clear database rather than the main one that's added (on inspection with the terminal the database the simulator uses is 0mb in dimensions while the main one I have added is about 3mb).

It appears such as the application is creating a clear database however i can't exercise why? Any ideas?

For reference I do not have any error messages:

BOOL success;
dbName = @"teamresults.db";

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
dbPath = [documentsDir   stringByAppendingPathComponent:dbName];

NSFileManager *fileManager = [NSFileManager defaultManager];

success = [fileManager fileExistsAtPath:dbPath];

if(success) {

NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:dbName];

[fileManager copyItemAtPath:databasePathFromApp toPath:databasePathFromApp error:nil];

There appears to become a problem with this particular type of code:

[fileManager copyItemAtPath:databasePathFromApp toPath:databasePathFromApp error:nil];

The most appropriate one could be:

[fileManager copyItemAtPath:databasePathFromApp toPath:dbPath error:nil];

You need to copy database to sandbox path rather than assets path !!

Do one factor. Remove the database added by right click might click remove rather than "Remove reference only". Adding it again you should also click "Copy into destination item". Hopefully that will assist you to.