6 Replies Latest reply on Dec 23, 2008 7:53 AM by solidated

    Delete Local Database file on Windows?

    solidated
      I have a function that deletes and later recreates my local SQLite database file. It works as expected on the Mac (my platform), but on Windows the database file won't delete. Any ideas?
        • 1. Re: Delete Local Database file on Windows?
          tzeng Adobe Employee
          Are you sure you point to the right path on Windows?

          -ted
          • 2. Re: Delete Local Database file on Windows?
            solidated Level 1
            Ted,

            Yeah, I'm sure. The function attempts to delete a parent directory that contains several directories, one of which contains the database file. When I run the function on the Mac everything works perfectly. When I run the function on Windows all the other directories (and the files in them) are deleted but not the database file or for that matter the directory containing the database file.

            I'm using:

            MyDirectory.deleteDirectory(true);

            Where "MyDirectory" is the parent directory containing all the directories mentioned above.

            For testing, I've tried just deleting the database file with deleteFile(); but that doesn't work either. I've also tried deleting the file manually while my app is running through Finder on the Mac and through Explorer on Windows. On the Mac the file can be deleted. On Windows I get a message from the OS that says:

            "Cannot delete mydb: It is being used by another person or program. Close any programs that might be using the file and try again."

            Is it possible that in Windows the database file gets locked and even the app itself can't delete it? If this is the case, is there any way to unlock (release it) and subsequently delete it?

            Your help is greatly appreciated.
            • 3. Re: Delete Local Database file on Windows?
              tzeng Adobe Employee
              Do you have a simple program that displays the problem?
              And which Windows , XP or Vista?

              -ted
              • 4. Re: Delete Local Database file on Windows?
                solidated Level 1
                I'm sorry, I don't understand the question about a "simple program that displays the problem", what do you mean?

                The problem occurs on both XP and Vista.
                • 5. Re: Delete Local Database file on Windows?
                  solidated Level 1
                  Ok, so I've been digging around... It looks like the database file is definitely being locked in Windows when the app opens a connection to it. I've tried the following:

                  if (myDBConnection.connected == true) {
                  myDBConnection.close();
                  }

                  But this generates an error:

                  Error #3104: A SQLConnection must be open to perform this operation.

                  I find this odd since "myDBConnection.connected" returns "true". I suppose there's a difference between "connected" and "open" but I can't figure out how to close, disconnect or whatever... to unlock the database file.

                  Has anyone else run into this?
                  • 6. Re: Delete Local Database file on Windows?
                    solidated Level 1
                    After a few days on this, it turns out that this is a limitation in AIR. On Windows (XP, Vista, etc.) once AIR opens a file or connects to a database file it is locked and cannot be renamed, deleted or moved.

                    I guess this is just another one of those inconsistencies between operating systems that supposedly (according to Adobe) don't exist in the runtime.

                    I have to say, after having created several apps in AIR since beta (and through version 1.5) I'm no longer confident that AIR will ever be a meaningful platform for development. There's just too much missing - too many holes in the platform to have to work around. I know other's here have compared it to Java, in how after years and years into it, it still hasn't lived up to what was promised. I initially, didn't agree. I felt confident that Adobe had learned the lessons that Sun never did. Now, I'm not so sure.

                    AIR isn't web development and it isn't application development. It's some kind of loose, informal, in-between hybrid, which IMHO, is probably best suited for non-commercial hobby projects.

                    ...Not what I'd hoped for, but it is what it is. Maybe (hopefully) in the future things will get better and I'll find that my assessment was wrong, but right now, that doesn't look likely.