Skip to main content
Participant
September 9, 2012
Question

File.applicationStorageDirectory problem

  • September 9, 2012
  • 6 replies
  • 2986 views

Hello dear adobe air community!

I'm new to air mobile development and i'm currently facing a weird problem with File API and its applicationStorageDirectory property.

Please correct me if i'm wrong but it seems that every files stored in applicationStorageDirectory are not deleted during application update, true?

In m'y case, I'm using applicationStorageDirectory to store application database with some user settings. Obviously, these settings should be kept during application update process. Unfortunately, they are removed each time I'm updating the application...

Any ideas? Can this behaviour should result for a bad configuration of my air descriptor file?

Thanks in advance for your help...

This topic has been closed for replies.

6 replies

Adobe Employee
September 10, 2012

Please refer to http://blogs.adobe.com/airodynamics/2012/03/05/app-compliance-with-apple-data-storage-guidelines/ for more details about various directories and how they are used.

kakaroutAuthor
Participant
September 10, 2012

Ok thanks a lot for this link. It is exactly what i want!

Since the data are generated from the end user, i'll be able to store the db file in the "documentDirectory"

I suppose the file will be preserved after the application update, right?

But another question is: Is this file deleted if the user decide to remove the application from its device?

Thank you.

Adobe Employee
September 10, 2012

Yes the file will be preserved after the application update. All files are deleted when application is removed/deleted from the device.

Chris W. Griffith
Community Expert
Community Expert
September 10, 2012

How do you install this database? Do you check that exists before creating it? If you include a database with your app by default, do you check before you move it? You some random thoughts on some tiems that get overlooked sometimes.

Chris

kakaroutAuthor
Participant
September 10, 2012

Thank you Chris for your quick answer.

My database file is copied when the application starts up.

A check is performed before copying the database file.

However, after application update, the database seems to be removed  and recreated...

The following code performs the database initialization:

/**
* Init the database with a default database file.
*
* @param dbFilePathSource
* @param dbFilePathTarget
*/
public static function initDatabase(dbFilePathSource:String, dbFilePathTarget:String):void {
    trace("IN initDatabase.");

    // DB files lookup
    var embeddedSessionDB:File = File.applicationDirectory.resolvePath(dbFilePathSource);
    var writeSessionDB:File = File.applicationStorageDirectory.resolvePath(dbFilePathTarget);

    // If a writable DB doesn't exist, then we copy it into the app folder so it's writable
    if (!writeSessionDB.exists) {
        trace("DB file does not exist at path [" + dbFilePathTarget + "]. DB file file be created from reference file stored at path [" + dbFilePathSource + "].");
        embeddedSessionDB.copyTo(writeSessionDB);
    }
}

Thank you...