title: database is malformed in iphone + error disk i/o error
body: <p>I have More than 5000 Record to be loaded from Server to my App and Inserted into Database.
  While inserting these records after some successful insertion  I am getting this kind of error and my app crashes.</p>
  
  <p><strong>database is malformed in iPhone + error disk i/o error</strong></p>
  
  <p>Following are code snippet that could be useful,Here I am getting Records in 5 Categories One by One and Inserting them into Database</p>
  
  <pre><code>    if (tag==1) {
          NSMutableDictionary *catDic=[dic valueForKeyPath:@"GetAllRecords.results.categories.category"];
          [self performSelectorInBackground:@selector(insertDataInCategoryMaster:) withObject:catDic];
  
          NSMutableDictionary *levelDic=[dic valueForKeyPath:@"GetAllRecords.results.levels.level"];
          [self performSelectorInBackground:@selector(insertDataInLevelMaster:) withObject:levelDic];
  
          NSMutableDictionary *queDic=[dic valueForKeyPath:@"GetAllRecords.results.questions.question"];
  
          [self performSelectorInBackground:@selector(insertDataInQueMaster:) withObject:queDic];
  
          [self getQueCatLevelData:2];
      }
      else if(tag==2){
  
          NSMutableDictionary *queDic=[dic valueForKeyPath:@"GetAllRecords.results.questions.question"];
          [self performSelectorInBackground:@selector(insertDataInQueMaster:) withObject:queDic];
  
          [self getQueCatLevelData:3];
  
      }
      else if(tag==3){
  
          NSMutableDictionary *queDic=[dic valueForKeyPath:@"GetAllRecords.results.questions.question"];
          [self performSelectorInBackground:@selector(insertDataInQueMaster:) withObject:queDic];
  
          [self getQueCatLevelData:4];
      }//and so on for 5 also
  </code></pre>
  
  <p>in each insertDataInQueMaster I am doing  following things.</p>
  
  <pre><code>         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
          for(NSDictionary *queDictionary in dictionary)
          {
  
              NSString *strQuery = [NSString stringWithFormat:@"insert into QuestionMaster values(%d,'%@','%@',%d,%d,%d,%d,%d,0,'%@')",[[queDictionary valueForKey:@"questionid"]intValue], [queDictionary valueForKey:@"questiontext"],[queDictionary valueForKey:@"answertext"],[[queDictionary valueForKey:@"categoryid"]intValue],[[queDictionary valueForKey:@"levelid"] intValue],[[queDictionary valueForKey:@"status"]intValue],[[queDictionary valueForKey:@"RangeFrom"]intValue],[[queDictionary valueForKey:@"RangeTo"]intValue],[queDictionary valueForKey:@"Fact"]];
  
              [NSNumber requestWithSynchronousExcuteQuery:strQuery withReturnningError:&amp;error];
  
              if(error)
              {
                  NSLog(@"error description:%@",[[error userInfo] description]);
                  [[NSUserDefaults standardUserDefaults]setBool:NO forKey:@"FirstTime"];
              }
  
          }
  
          count++;
          [[NSUserDefaults standardUserDefaults]setInteger:count forKey:@"CheckCount"];
          [[NSUserDefaults standardUserDefaults]synchronize];
          [pool drain];
  </code></pre>
  
  <p>I am doing These all things while App is Loading in AppDelegate.m , that too in Background
  The Error Comes After  successfully inserting few records in Database so I think there is no problem with Database opening and Inserting.</p>
  
  <p>I hope I am clear,
  Please comment if any confusion.
  Waiting for reply.
  Thanks in advance. </p>