I am new to sQLite and created a sqlite database in the mac's terminal for my app. I then added the database too my app and ran fine. Recently I needed another table, so i downloaded sqlitemanager(a firefox plugin with a gui for sqlite databases, kinda didnt want to write script for everysingle thing). From since then, I have been getting the error "Table not found". However browsing my database i see the table, but if i look at the database in the ios simulator i dont see the tables(database is zero kb so i guess the error is justified). However, if I just copy and paste the database directly into that folder the app works fine. However this is not a good fix...but is this occuring because i used this manager to edit the database? If yes what manager can i use or if no what is the problem.
Thank you
+ (NSString *) getDBPath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
return [documentsDir stringByAppendingPathComponent:@"tourism.sql"];
}
+ (void) copyDatabaseIfNeeded {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *dbPath = [DBAccess getDBPath];
BOOL success = [fileManager fileExistsAtPath:dbPath];
if(!success) {
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"tourism.sql"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
if (!success)
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}