Hi guys! I've just started testing my app on my iPhone, and was wondering if there is a way to tell the app to dump the .sqlite db that I have every time I build and run the app. Previously I would just navigate to the simulator's app instance on finder and remove the file myself.
This is the code I'm using to create the db if it doesn't exist. Would I be able to just force a new creation? Will there be an issue if the file exists?
Code:
-(void) checkAndCreateDatabase{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
success = [fileManager fileExistsAtPath:self.databasePath];
if(success){
return;
}//end if
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:self.databaseName];
[fileManager copyItemAtPath:databasePathFromApp toPath:self.databasePath error:nil];
[fileManager release];
} // end checkAndCreateDatabase
Thanks!
- Josh