2 Replies Latest reply on Aug 19, 2009 5:19 PM by huskycoding

    Migrating Data


      I recently received a free code signing certificate from Adobe as part of their 1.5 earlier adopters program. When I sign my application I of course get a new publisher id. I'm trying to figure out a way to migrate my sqlite database from the old publish storageDirectory to the new one without requiring the user to do anything manually. I have search and tried a number of things and nothing seems to work. I tried use resolvePath on applicationStorageDirectory to back up directories to the old publishers id directory but it won't let me. I really don't want to have to write a check for all the different paths, ie one for windows, mac os x and linux to get at the old sqlite database. Can anyone think of an easy way to determine the storage directory based on publisher id? Any help would be great. This is using html/javascript.

        • 1. Re: Migrating Data
          Jeff Swartz Level 3

          On any platform, the application storage directory is in a "Local Store" subdirectory of a directory that is named based on the application ID and publisher ID. And the parent directory of that directory (the appID.publisherID directory) contains all other application storage directories.


          So, if you know the publisher ID, you should be able to find its application storage directory this way (in the new application):


          var rootAppStorage = new air.File(air.File.applicationStorageDirectory.nativePath).parent.parent;
          var oldAppStorageDir = rootAppStorage.resolvePath(appID + "." + oldPubID);


          Note that calling new air.File(air.File.applicationStorageDirectory.nativePath) creates a File object that uses the file URL scheme (not the app-storage URL scheme). (You probably got an error if you tried to access the parent directory of air.File.applicationStorageDirectory directly. AIR will not let you navigate to the parent of the application storage directory if the File object uses the app-storage URL scheme.)

          • 2. Re: Migrating Data
            huskycoding Level 1

            Thanks for the reply, that probably would have work great. Instead I just setup an array that stored the path each operating system uses added that to user.Directory and then checked to see if it existed and if it did used copyTo to get the sqlite database.