title: Delete SQLite Data from .db File and Update UITableView Using Swift
body: <p><strong>I am trying to delete the data from a sqlite table</strong> using swift and remove the contents of UITABLEVIEW CELL.</p>
  
  <p>Code shown below is working fine (no error). However, the problem is that when application is run next time , it populates the data from previous sql queries.</p>
  
  <pre><code>@IBAction func removeAllData(sender: AnyObject) {
  
             //deleting the data from arrays responsible for updating the labels in UITableView Cell
  
              self.endData.removeAll()
              self.startData.removeAll()
              self.driveData.removeAll()
  
          //Deleting the table
          let tripsDB = FMDatabase(path: recievedDatabasePath as String)
  
          if tripsDB.open(){
              let sqlQuery = "DELETE  FROM trips"
              let results : FMResultSet? = tripsDB.executeQuery(sqlQuery, withArgumentsInArray: nil)
  
              print(tripsDB.lastErrorMessage())
  
          } else {
              print(tripsDB.lastErrorMessage())
          }
          tripsDB.close()
  
          self.tableView.reloadData()
      }
  </code></pre>
  
  <p>Any suggestion will be helpful. Thanks a lot in advance.</p>
  
  <p><strong><em>updated:</em></strong></p>
  
  <pre><code>let filemgr = NSFileManager.defaultManager()
  let dirPaths = filemgr.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
  databasePath = dirPaths[0].URLByAppendingPathComponent("trips.db").path!
  
  
  
  //sending the database contents to table view controller. here the recievedDatabasePath Variable is equal to the current database path mentioned in the first view controller
  
  
  override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) 
  {
     if  segue.identifier == "historySegue" {         
       let destinationViewController = segue.destinationViewController as! HistoryTableViewController
      destinationViewController.recievedDatabasePath = databasePath
          }
       }
  </code></pre>