AIR on Android provides access to the file system to read, write, and update files of all types. This functionality can be very useful not only for reading existing files, but also for storing files, media, data, and so on. This chapter will demonstrate how to read and write text files, browse the file system for media files, and create and write to an SQLite database.
This chapter has sample applications that require access to the file system, so you will need to select the WRITE_EXTERNAL_STORAGE permission when you are creating these projects. See Chapter 3 for help with permissions.
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.
To access the file system, you can navigate using several folder
static alias properties of the
Let’s review the code below. On
application1_applicationCompleteHandler 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
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)"> ...