title: sqlite3_open - 'Database Failed to open'
body: <p>I'm new to iOS programming.
  I don't know what is the cause of my error.
  My code simply load the database when the app is starting but it force closes itself whenever I'm running it.</p>
  
  <p>Here is my <strong>header file</strong>:</p>
  
  <pre><code>//
  //  ViewController.h
  //  Manicuriousv2
  //
  //  Created by Bonafide on 6/5/14.
  //  Copyright (c) 2014 Bonafide_iOSTeam. All rights reserved.
  //
  
  #import &lt;UIKit/UIKit.h&gt;
  #import "sqlite3.h"
  
  @interface ViewController : UIViewController &lt;UITabBarDelegate, UITableViewDataSource&gt;
  {
      sqlite3 *AppDB;
  
  }
  - (IBAction)btnAvailPop:(id)sender;
  - (IBAction)btnRstPop:(id)sender;
  - (NSString *) filePath;
  - (void) openDB;
  
  - (void)
  createTable: (NSString *) Ref_ServType
  withfield1: (NSString *) ServID
  withfield2: (NSString *) ServiceTitle;
  
  
  @end
  </code></pre>
  
  <p><strong>Implementation file:</strong></p>
  
  <pre><code>   //
  //  ViewController.m
  //  Manicuriousv2
  //
  //  Created by Bonafide on 6/5/14.
  //  Copyright (c) 2014 Bonafide_iOSTeam. All rights reserved.
  //
  
  #import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (void)
  createTable: (NSString *) Ref_ServType
  withfield1: (NSString *) ServID
  withfield2: (NSString *) ServiceTitle;
  
  
  {
  }
  
      -(NSString *) filePath{
      NSArray *paths =NSSearchPathForDirectoriesInDomains
      (NSDocumentationDirectory,NSUserDomainMask, YES);
      return [[paths objectAtIndex:0]
      stringByAppendingPathComponent:@"ManicuriousDB.db"
              ];
  
  }
  
  -(void) openDB{
      if (sqlite3_open([[self filePath] UTF8String], &amp;AppDB) != SQLITE_OK){
          sqlite3_close(AppDB);
          NSAssert(0,@"Database Failed to open");
      }else{
  
          NSLog(@"Database Opened!");
      }
      }
  
  
  - (void)viewDidLoad
  {
      [self openDB];
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  - (IBAction)btnAvailPop:(id)sender {
      UIAlertView *alert = [[UIAlertView alloc]
      initWithTitle:@"Avail List"
      message:@"Are you sure you want to avail the services you have selected?"
      delegate:nil
      cancelButtonTitle:@"Cancel"
      otherButtonTitles:@"Avail", nil];
  
      [alert show];
  
  
  }
  
  - (IBAction)btnRstPop:(id)sender {
      UIAlertView *alert = [[UIAlertView alloc]
      initWithTitle:@"Avail List"
      message:@"Are you sure you want to reset the list of services you have selected?"
      delegate:nil
      cancelButtonTitle:@"Cancel"
      otherButtonTitles:@"Reset", nil];
  
      [alert show];
  
  }
  @end
  </code></pre>
  
  <p><strong>Error Message:</strong></p>
  
  <pre><code>2014-06-06 16:43:28.502 Manicuriousv2[2261:60b] Cannot find executable for CFBundle 0x99341f0 &lt;/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/AccessibilityBundles/CertUIFramework.axbundle&gt; (not loaded)
  2014-06-06 16:43:28.590 Manicuriousv2[2261:60b] *** Assertion failure in -[ViewController openDB], /Users/jennifer/Desktop/Manicuriousv2/Manicuriousv2/ViewController.m:38
  2014-06-06 16:43:28.593 Manicuriousv2[2261:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Database Failed to open'
  *** First throw call stack:
  (
      0   CoreFoundation                      0x018d61e4 __exceptionPreprocess + 180
      1   libobjc.A.dylib                     0x016558e5 objc_exception_throw + 44
      2   CoreFoundation                      0x018d6048 +[NSException raise:format:arguments:] + 136
      3   Foundation                          0x012354de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
      4   Manicuriousv2                       0x00002293 -[ViewController openDB] + 339
      5   Manicuriousv2                       0x00002307 -[ViewController viewDidLoad] + 55
      6   UIKit                               0x0043433d -[UIViewController loadViewIfRequired] + 696
      7   UIKit                               0x004345d9 -[UIViewController view] + 35
      8   UIKit                               0x0045f509 -[UINavigationController rotatingSnapshotViewForWindow:] + 52
      9   UIKit                               0x007a6e3c -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 420
      10  UIKit                               0x0035bc22 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 1495
      11  UIKit                               0x0035b646 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
      12  UIKit                               0x0035b518 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
      13  UIKit                               0x0035b5a0 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
      14  UIKit                               0x0035a63a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
      15  UIKit                               0x0035a59c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
      16  UIKit                               0x0035b2f3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
      17  UIKit                               0x0035e8e6 -[UIWindow setDelegate:] + 449
      18  UIKit                               0x00438b77 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
      19  UIKit                               0x00354474 -[UIWindow addRootViewControllerViewIfPossible] + 591
      20  UIKit                               0x003545ef -[UIWindow _setHidden:forced:] + 312
      21  UIKit                               0x0035486b -[UIWindow _orderFrontWithoutMakingKey] + 49
      22  UIKit                               0x0dcda587 -[UIWindowAccessibility(SafeCategory) _orderFrontWithoutMakingKey] + 77
      23  UIKit                               0x0035f3c8 -[UIWindow makeKeyAndVisible] + 65
      24  UIKit                               0x0030fbc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
      25  UIKit                               0x00314667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
      26  UIKit                               0x00328f92 -[UIApplication handleEvent:withNewEvent:] + 3517
      27  UIKit                               0x00329555 -[UIApplication sendEvent:] + 85
      28  UIKit                               0x00316250 _UIApplicationHandleEvent + 683
      29  GraphicsServices                    0x038cbf02 _PurpleEventCallback + 776
      30  GraphicsServices                    0x038cba0d PurpleEventCallback + 46
      31  CoreFoundation                      0x01851ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
      32  CoreFoundation                      0x018519db __CFRunLoopDoSource1 + 523
      33  CoreFoundation                      0x0187c68c __CFRunLoopRun + 2156
      34  CoreFoundation                      0x0187b9d3 CFRunLoopRunSpecific + 467
      35  CoreFoundation                      0x0187b7eb CFRunLoopRunInMode + 123
      36  UIKit                               0x00313d9c -[UIApplication _run] + 840
      37  UIKit                               0x00315f9b UIApplicationMain + 1225
      38  Manicuriousv2                       0x0000296d main + 141
      39  libdyld.dylib                       0x01e1f701 start + 1
  )
  libc++abi.dylib: terminating with uncaught exception of type NSException
  (lldb) 
  </code></pre>