Something is not correct in my function because it is successfully opening a file that does not exist. Can someone please help me with where I might be going wrong?
I don't even have a file named "game.sqlite", yet it apparently opens it. Does someone have any idea why this is happening?
Thanks for any information.
Code:
- (void) initializeDatabase {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"[B]game.sqlite[/B]"];
int result = sqlite3_open([path UTF8String], &db);
if (result != SQLITE_OK){
sqlite3_close(db);
alert = [[UIAlertView alloc] initWithTitle:@"Database error"
message:@"Failed to open database"
delegate:self
cancelButtonTitle:@"Hrm"
otherButtonTitles:nil];
[alert show];
[alert autorelease];
return;
}
alert = [[UIAlertView alloc] initWithTitle:@"Database good to go"
message:@"Database was opened"
delegate:self
cancelButtonTitle:@"Yeppers"
otherButtonTitles:nil];
[alert show];
[alert autorelease];
}
I don't even have a file named "game.sqlite", yet it apparently opens it. Does someone have any idea why this is happening?
Thanks for any information.