check:
dbName = @"db.sqlite"; NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; dbPath = [documentsDir stringByAppendingPathComponent:dbName]; BOOL success; NSFileManager *fileManager = [NSFileManager defaultManager]; success = [fileManager fileExistsAtPath:dbPath]; if(success) return; NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:dbName]; [fileManager copyItemAtPath:databasePathFromApp toPath:dbPath error:nil];
and
sqlite3 *database ; [app checkAndCreateDatabase]; // Open the database from the users filessytem if(sqlite3_open([app.dbPath UTF8String], &database) == SQLITE_OK) { sqlite3_stmt *compiledStatement1; NSString* query; query=[NSString stringWithFormat:@ " insert into test ( name , company , phone , email , address , country , state , city, zip , online_id , in_time , flag_delete, flag_update,type_id) values (?, ?, ?,?,?, ?, ?, ?, ?,?,?,? ,?,?)"]; const char *compiledStatement = [query UTF8String]; if(sqlite3_prepare_v2(database, compiledStatement, -1, &compiledStatement1, NULL) == SQLITE_OK) { sqlite3_bind_text(compiledStatement1, 1, [text UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement1, 2, [text UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement1, 3, [text UTF8String], -1, SQLITE_TRANSIENT); } // Loop through the results and add them to the feeds array if(SQLITE_DONE != sqlite3_step(compiledStatement1)) NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database)); sqlite3_finalize(compiledStatement1); sqlite3_close(database); }