I have installed my application in the simulator and need to view the DB. Please tell me the application to view this or can I view it from Xcode itself.
DATABASE
//database connection
con = [[DataBase alloc]init];
NSError *error = [[NSError alloc]init];
NSFileManager *filemanager = [NSFileManager defaultManager];
NSArray *arryPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *DocumentPath = [arryPath objectAtIndex:0];
NSString *strDocumentPath = [DocumentPath stringByAppendingPathComponent:@"School.sqlite"];
// check file is exist or not
int success = [filemanager fileExistsAtPath:strDocumentPath];
//if file not exist at path
if (!success) {
NSLog(@"SchoolName is: %@",@"No Database exist");
NSString *strDefaultPath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:@"School.sqlite"];
success = [filemanager copyItemAtPath:strDefaultPath toPath:strDocumentPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
//file exist at path
if (success) {
NSLog(@"SchoolName is: %@",@" Database exist");
if (sqlite3_open([strDocumentPath UTF8String],&database) == SQLITE_OK) {
} else {
sqlite3_close(database);
NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
}
}