This is the insert code. It works fine until i close the app and start it again, then all changes are gone. I don\'t see any error, could it be some iphone specific issue?>
To write your DB to file manager:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *dbPath = [self getDatabasePath];
BOOL success = [fileManager fileExistsAtPath:dbPath];
if(!success) {
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"yourDB.sqlite"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
if (!success)
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
To fetch your DB from file manager:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
return [documentsDir stringByAppendingPathComponent:@"yourDB.sqlite"];
By this way your changes will be saved, next time you open your DB. I would rather suggest use FMDatabase wrapper, written in Obj C over sqlite. Here is the link for FMDatabase: http://code.google.com/p/flycode/source/browse/trunk/fmdb
hope it helps!!