Hi All,
I have a couple of apps that I'm working on that use the same core table view code. I'm using a method called 'checkAndCreateDatabase', which I have found many people are using. One of the apps I'm completing needs to ONLY use the data file in the bundle, but I can't for the life of me see what the change is to stop it having to copy the data file to the documents folder.
The data will be updated regularly, but there should only be one and not in the documents folder. If anyone can point me in the right direction I will be eternally greatful.
I have a couple of apps that I'm working on that use the same core table view code. I'm using a method called 'checkAndCreateDatabase', which I have found many people are using. One of the apps I'm completing needs to ONLY use the data file in the bundle, but I can't for the life of me see what the change is to stop it having to copy the data file to the documents folder.
- (void)checkAndCreateDatabase {
// Check if the SQL database has already been saved to the users phone, if not then copy it over
BOOL success;
// Create a FileManager object, we will use this to check the status
// of the database and to copy it over if required
NSFileManager *fileManager = [NSFileManager defaultManager];
// Check if the database has already been created in the users filesystem
success = [fileManager fileExistsAtPath:databasePath];
// If the database already exists then return without doing anything
if (success) return;
// If not then proceed to copy the database from the application to the users filesystem
// Get the path to the database in the application package
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
// Copy the database from the package to the users filesystem
[fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
}
The data will be updated regularly, but there should only be one and not in the documents folder. If anyone can point me in the right direction I will be eternally greatful.