This content has been marked as final.
Show 5 replies
-
1. Re: getting reference to local file
Jeff Swartz Feb 25, 2009 6:31 PM (in response to kamckng)A couple of notes, Kyle:
1. There are a number of ways to reference existing files. If you have the actual path to the file (as a string), you can create a new File object pointing to that file: new File(myPath). Also, the File class includes many properties for accessing common paths (such as the desktop directory), and you can use the resolvePath() method to point to relative paths. For example (in ActionScript):
var db:File = File.desktopDirectory;
db = db.resolvePath("databases/foo.db");
2. You probably do not want to include the database file in the same directory as the SWF files installed with the AIR application. You should not modify files in the application directory. The application storage directory is a good place to store dynamic application-specific data.
For details on pointing to files, see the following sections of the documentation:
For Flex developers: http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7fe4. html
For Flash developers: http://help.adobe.com/en_US/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7fe4 .html
For HTML developers: http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7fe4. html -
2. Re: getting reference to local file
kamckng Feb 25, 2009 6:46 PM (in response to kamckng)I appreciate the detailed response! Very helpful. A follow-up question then. Since to use the special directories it means as far as i know that the app has to actually be installed. That seems to me to create a very tedious workflow. Having to install the program each time and what not. So what is a good workflow for that type of thing so that I can test everything from with flash instead of having to install it and such. Also, I know that I can include certain folders, like the datbase folder and other resources by including them in the AIR settings. But those are then installed into the application directory. How can I get those data files to be installed in the storage directory instead as they will already have data in them when the user installs the program?
Thanks!
Kyle -
3. Re: getting reference to local file
kamckng Feb 25, 2009 7:03 PM (in response to kamckng)I suppose I could test for some sort of first run thing, and if it's the first time the program is run, then I can move the files from the app directory to the app data directory? is that a good way? And if so, then how about whenever I update the program. Will it then say it's a first run again so it'd then copy the data over? Although I suppose there is the overwrite flag so even if it tries, if the data already exists, then I just don't overwrite?
Kyle -
4. Re: getting reference to local file
Jeff Swartz Feb 25, 2009 7:10 PM (in response to kamckng)Yes, your strategies are good. On an application update, you could simply check to see if the database already exists in the application storage directory, and overwrite only if it does not. -
5. Re: getting reference to local file
kamckng Feb 25, 2009 7:11 PM (in response to kamckng)Great!
Very helpful, thank you.
Kyle

