アプリケーションdidFinishLaunchingWithOptionsのAppDelegateのデータベースにいくつかの値を挿入しようとしていますが、データの挿入に失敗するたびに。
コード
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *path = [docsPath stringByAppendingPathComponent:@"db.sqlite"];
FMDatabase *database = [FMDatabase databaseWithPath:path];
[database open];
FMResultSet *results = [database executeQuery:@"select * from settings"];
if(results == nil)
{
NSLog(@"Creating DB");
[database beginTransaction];
[database executeUpdate:@"create table settings(id int primary key, defaultaction text, beepsound text, vibrateeffect text, level text)"];
NSString *query = [NSString stringWithFormat:@"insert into settings(id,defaultaction,beepsound,vibrateeffect,level) values (%d, '%@', '%@','%@','%@',)",11,@"auto", @"YES", @"YES", @"HIGH"];
NSLog(@" %@",path);
BOOL y= [database executeUpdate:query];
if (!y)
{
NSLog(@"insert failed!!");
}
[database commit];
[database close];
}