title: iOS - SQLite insertion not inserting data
body: <pre><code>- (id)init {
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:@"idataBase.sqlite3"];
      NSLog(@"Doc path: %@",databasePath);
      bool databaseAlreadyExists = [[NSFileManager defaultManager] fileExistsAtPath:databasePath];
      if (!databaseAlreadyExists){
          NSString *databasePathFromApp = [[NSBundle mainBundle] pathForResource:@"idataBase" ofType:@"sqlite3"];
          NSLog(@"Main bundle path: %@",databasePathFromApp);
          [[NSFileManager defaultManager] copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
      }
      if (sqlite3_open([databasePath UTF8String], &amp;_database) == SQLITE_OK){
          NSLog(@"Database opened");
      }dd
      return self;
  }
  
  -(void) setData:(NSDictionary *)data{
      NSLog(@"In Data %@",data);
      NSString *hostAddress = [data objectForKey:@"hostAddress"];
      NSString *userName = [data objectForKey:@"userName"];
      NSString *passKey = [data objectForKey:@"passKey"];
      NSString *listName = [data objectForKey:@"listName"];
      NSString *q = [NSString stringWithFormat:@"INSERT INTO user_info (host_name,user_name,password,text_name) VALUES (\"%@\", \"%@\", \"%@\", \"%@\")",hostAddress,userName,passKey,listName];
      NSLog(@"%@",q);
      sqlite3_stmt    *statement = NULL;
      const char *insertQuery = [q UTF8String];
      sqlite3_prepare_v2(_database, insertQuery, -1, &amp;statement, NULL);
      if(sqlite3_step(statement) == SQLITE_OK){
          NSLog(@"Data Inserted");
      }
      sqlite3_finalize(statement);
      sqlite3_close(_database);
  </code></pre>
  
  <p>}</p>
  
  <p>I am using the above code for inserting data. Database connection is opened in init method. But I cannot insert data in database. sqlite3_step(statement) never returns SQLITE_OK.</p>