title: can't create sqlite3 database in ios
body: <p><strong>Create Database Code</strong></p>
  
  <p>This code is correct. i used that code to create a database it's successful run and created a database but i test my application so i remove or delete my simulator app and again run my application then i see database is not created.</p>
  
  <p>Please tell me what is the actual problem i face. </p>
  
  <p><strong>ClsUpdateNetworkViewController.h</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "Person.h"
  #import &lt;sqlite3.h&gt;
  
  @interface ClsUpdateNetworkViewController : UIViewController{
  
     UITextField *name;
     UITextField *phone;
     NSString *databasePath;
     sqlite3 *contactDB;
     int rowcount;
  
  }
  
  @property (nonatomic, strong) Person *person;
  @property (nonatomic, strong) NSString *firstName;
  @property (nonatomic, strong) NSString *lastName;
  @property (nonatomic, strong) NSString *fullName;
  @property (nonatomic, strong) NSString *phoneNumber;
  @property (nonatomic, strong) NSString *workEmail;
  
  @end
  </code></pre>
  
  <p><strong>ClsUpdateNetworkViewController.m</strong></p>
  
  <pre><code> #import "ClsUpdateNetworkViewController.h"
   #import "ClsMainPageAppDelegate.h"
   #import "ClsAddressBookViewController.h"
  
  
  @interface ClsUpdateNetworkViewController ()
  
  @end
  
  @implementation ClsUpdateNetworkViewController
  
  @synthesize  person,firstName,lastName,fullName,phoneNumber,workEmail;
  @synthesize name,phone;
  
  - (void)viewDidLoad
  {
     [super viewDidLoad];
  // Do any additional setup after loading the view.
  
     [self createDatabase];
  }
  
  
  
  -(void) createDatabase
  {
     NSString *docsDir;
     NSArray *dirPaths;
  
     // Get the documents directory
     dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  
     docsDir = [dirPaths objectAtIndex:0];
  
     // Build the path to the database file
     databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"contacts.db"]];
  
     NSFileManager *filemgr = [NSFileManager defaultManager];
  
     if ([filemgr fileExistsAtPath: databasePath ] == NO)
     {
      const char *dbpath = [databasePath UTF8String];
  
         if (sqlite3_open(dbpath, &amp;contactDB) == SQLITE_OK)
         {
             char *errMsg;
             const char *sql_stmt = "CREATE TABLE IF NOT EXISTS CONTACTS (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, PHONE TEXT)";
  
             if (sqlite3_exec(contactDB, sql_stmt, NULL, NULL, &amp;errMsg) != SQLITE_OK)
             {
                 NSLog(@"Failed to create table");
  
             }
  
             sqlite3_close(contactDB);
  
         }
         else
         {
             NSLog(@"Failed to open/create database");
  
         }
     }
  
  }
  </code></pre>
  
  <p><strong>i test or debug my application</strong></p>
  
  <pre><code>Code is not going inside this condition.
  if ([filemgr fileExistsAtPath: databasePath ] == NO)
  {
      // inside code is not executed.
  }
  </code></pre>