title: Error while updating. 'attempt to write a readonly database
body: <p>HI</p>
  
  <p>I am using sqlite database. I know after application crash or system crash database get locked.. </p>
  
  <p>How I avoid to get my sqlite db locked. </p>
  
  <p>How does I check that database lock during DML queries.</p>
  
  <p>How does I open locked database.</p>
  
  <p>Thanks</p>
  
  <p>Mandeep</p>
  
  <p>following is My Code.</p>
  
  <pre><code>NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"MyApp.sqlite"];
      return defaultDBPath;
  </code></pre>
  
  <p>Now I changed above code to this.     </p>
  
  <pre><code>NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDir = [documentPaths objectAtIndex:0];
  databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
  </code></pre>