Blograby

File System Access

Just as in the desktop version of Adobe AIR, AIR on Android gives you access to the file system. The usage is exactly the same.

Folder Aliases

To access the file system, you can navigate using several folder static alias properties of the File class.

Let’s review the code below. On applicationComplete, the application1_application CompleteHandler method is called, and the static File properties are read and written to a String variable. This String variable is written to the text property of a TextArea component. Figure 5-1 shows the results. You will notice that many of the aliases return the same value, which is a path to the device’s external storage card:

<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
applicationComplete=”application1_applicationCompleteHandler(event)”>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protectedfunction application1_applicationCompleteHandler
(event:FlexEvent):void
{
var s:String = “”;
s += “File.applicationDirectory : ” +
File.applicationDirectory.nativePath + “nn”;
s += “File.applicationStorageDirectory : ” +
File.applicationStorageDirectory.nativePath + “nn”;
s += “File.desktopDirectory: ” +
File.desktopDirectory.nativePath + “nn”;
s += “File.documentsDirectory : ” +
File.documentsDirectory.nativePath + “nn”;
s += “File.userDirectory : ” +
File.userDirectory.nativePath + “nn”;
info.text = s;
}
]]>
</fx:Script>
<fx:Declarations>
<!– Place non-visual elements (e.g., services, value objects) here –>
</fx:Declarations>
<s:Label text=”File System Paths” top=”10″ width=”100%” textAlign=”center”/>
<s:TextArea id=”info” width=”100%” height=”100%” top=”40″ editable=”false”/>
</s:Application>

 

Exit mobile version