Array

Internal or External Storage?

Must Read

Data Format and Synchronization Considerations

One way to reduce memory, storage, and communication bandwidth requirements is by choosing an appropriate format for the data...

City Life and Country Charm Meet in Greater Binghamton, New York

The Central Leatherstocking Region of New York State is an area filled with nostalgic charm and unspoiled beauty. Here...

Refinance Mortgages – Tips For Finding the Best Home Mortgage Rate

There are many reasons to refinance mortgages. Borrowers often refinance when interest rates drop. As little as one-quarter percent...

Easy 4 Step Success Guide to Internet Marketing MLM

Most people don't have success in MLM because they never get started the right way.Maybe it's not their fault,...

Criminal Defense 101 – What to Do If Arrested and Charged With a Crime

If you have recently been arrested and/or charged with a criminal offense, there are a few important legal issues...

I Can’t Refinance My ARM Mortgage – What to Do When You Are Unable to Refinance Your ARM Loan

All across the world there are home owners that cannot refinance their mortgages because for one reason or another...
Admin
test

Let’s consider where to save data first. Data can be saved internally or externally.

Internally, File.ApplicationDirectory is the directory where your application and its assets are installed. AIR made this directory read-only because it is not writable on all systems. Instead, you can write to File.ApplicationStorageDirectory, the storage directory allocated to your application. Use this location to save fairly small amounts of data and information such as preferences and user settings. For example, your application data should not occupy more than a portion of the application’s full size.

If your application is removed, the data saved in storage is deleted along with it.

Users can erase the data by selecting Settings→Applications→Manage Applications→ Application→Clear Data. They will be alerted to the consequences with a warning that reads, “All of this application’s data will be deleted permanently. This includes all files, settings, accounts, databases and so on.” Android provides the option to set allowClearUserData to false to prevent users from clearing data. At the time of this writing, this feature is not available in the Flash Professional and Flash Builder permissions panel.

Data can also be saved internally in the memory cache allocated to your application. To use this approach, create a temporary file or folder and save data in it. This is a good place to save noncritical information such as downloaded data files that may not have a lasting value, or temporary saved files. If your application is removed, the data saved in the cache is also deleted.

Users can erase the cache under Settings→Applications→Manage Applications→Application→Clear Cache. Android does not provide the option to prevent clearing the cache.

Externally, data can be saved on the device’s SD card under the File.documentsDirectory directory, also referred to as File.userDirectory or File.desktopDirectory. Use this approach for any relatively large amounts of data, such as images or video or temporary files. Create a directory with your application name to keep it distinct from other applications’
data.

Writing to the card requires a permission, which needs to be added to the descriptor file. If you don’t have this permission, AIR will throw a runtime error:

<uses-permission android:name=
“android.permission.WRITE_EXTERNAL_STORAGE” />

Before installing any data, make sure the user’s phone has an SD card:

if (File.userDirectory)
// proceeds with saving data

You can use this approach as a way for one application to write data and another application to access that data.

If your application is deleted, the data is not deleted automatically. However, the data is visible, and can therefore be removed by the user even if your application is not. If the user removes the SD card, the data becomes unavailable.

A word of warning: during development, if you are using Flash Professional to install your application on the device, every uninstall/reinstall deletes previously saved data, including updates. In Flash Builder, you can prevent this behavior from occurring by unchecking the “Clear application data” box on each Launch option when you first create your project. If the user installs an update of your application, however, previously saved data is preserved.

It is better to use filenames than paths to guarantee consistency across devices and platforms, and the resolvePath method to refine the path.

Here is the list of directories and their equivalent paths:

/data/data/app.appId/app/assets
app:/
File.applicationDirectory
/data/data/app.appID/appID/Local Store
app-storage:/
/data/data/app.appID/appID/Local Store
File.applicationStorageDirectory
/sdcard
File.documentsDirectory
File.userDirectory
File.desktopDirectory
/data/data/app.appId/cache
File.createTempDirectory()
File.createTempFile()

There are several ways to save persistent application data on your device. The amount of space your data requires, and the complexity of the data, will determine which approach to take. We will discuss these options next.

 

Previous articleWhy and How to Save Data
Next articleLocal SharedObject

Latest News

Digital Marketing for Beginners

Digital marketing for starter, Let to basic learning about connecting with your audience in the right place...

What are 7 things poor people do that the rich don’t?

1. poor people watch TV in which people read books how many hours you spend in front of the TV and when...

Top 18 best small business ideas for beginners starting

A small business can be frightening and requires plenty of careful planning there are many small business ideas which can be beneficial...

Summer that makes you happy

We saw were already here I've been thinking about some of the things. I used to do with my husband even though...

4 Point to helpful tips specifically for caregivers

What you need to take a vacation. I know it sounds impossible creative and try to make it work for you almost...

More Articles Like This