Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Yes the file will be preserved after the application update. All files are deleted when application is removed/deleted from the device.
Copy link to clipboard
Copied
I'll make the change. You helped me a lot.
Big thanks to everyone.
Le 10 sept. 2012 à 18:30, Varun Bhatia <forums@adobe.com> a écrit :
Re: File.applicationStorageDirectory problem
created by Varun Bhatia in Mobile Development - View the full discussion
Yes the file will be preserved after the application update. All files are deleted when application is removed/deleted from the device.
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Mobile Development by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now