0 Replies Latest reply on Jun 1, 2012 5:58 PM by Laurence MacNeill

    Trying to delete SQLite database-file...

    Laurence MacNeill Level 1

      Hello,

       

      I'm working on my first mobile app, and one thing I need to do is when the user is done with it and has transferred the data off the device onto our servers, I want to close and delete the SQLite database file.

       

      The variable sqlConnection stores the SQL connection.  I have the following code in a function that runs when the user clicks on a "delete info" button:

       

      protected function deleteButttonClickHandler(event:MouseEvent):void {
           var file:File = File.applicationStorageDirectory.resolvePath("my.db");
           if (file.exists) {
                sqlConnection.addEventListener(SQLEvent.CLOSE, sqlDeleteFileHandler);
                sqlConnection.close();
           }
      }
      
      protected function sqlDeleteFileHandler(event:SQLEvent):void {
           sqlConnection = null;
           var file:File = File.applicationStorageDirectory.resolvePath("my.db");
           if (file.exists) {
                file.deleteFile();
           }
      }
      

       

      So, when it gets to the file.deleteFile() statement, I *ALWAYS* get a #3013 File In Use error...  Every time...  So obviously something isn't letting go of the file...  What am I doing wrong here?  Clearly the CLOSE event is being dispatched, otherwise it would never get to the sqlDeleteFileHandler function...  You'd figure after the close event happens, the file is no longer in use, eh?

       

      So what up wid dat?

       

      Thanks for any help you can give,

      Laurence MacNeill

      Mableton, Georgia, USA