Skip to main content
sinious
Legend
February 3, 2012
Answered

Storing cache data in app/Library/Caches, how do you access this folder?

  • February 3, 2012
  • 1 reply
  • 2864 views

Hey all,

I'm trying to abide by the new rules to keep content that is not vital to the application yet very desirable to cache in 5.0.1. The original project was built using Flash IDE and FlashDevelop and stored files in the Documents folder. It was rejected from the app store for 2.23 for not putting those files in the app/Library/Caches folder.

I've checked to see if this folder auto-exists using a bunch of File.applicationDirectory.resolvePath() traces and I can't find this folders existence. I can see that /Library/Caches exists but I get errors trying to write to that so that can't be it.

For example, here's a bunch of traces using applicationDirectory and then applicationStorageDirectory and their outputs:

File.applicationDirectory.resolvePath('/Library/Caches');

File.applicationDirectory.resolvePath('./../../Library/Caches');

File.applicationDirectory.resolvePath('./../Library/Caches');

File.applicationDirectory.resolvePath('../Library/Caches');

File.applicationDirectory.resolvePath('Library/Caches');

File.applicationDirectory.resolvePath('./../Library/Caches');

----------------------------

File.applicationStorageDirectory.resolvePath('/Library/Caches');

File.applicationStorageDirectory.resolvePath('./../../Library/Caches');

File.applicationStorageDirectory.resolvePath('./../Library/Caches');

File.applicationStorageDirectory.resolvePath('./Library/Caches');

File.applicationStorageDirectory.resolvePath('Library/Caches');

File.applicationStorageDirectory.resolvePath('./../Library/Caches');

outputs:

cache 1 exists: /Library/Caches

cache 2 exists: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/myApp.app

cache 3 exists: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/myApp.app

cache 4 exists: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/myApp.app

cache 5 doesnt exist: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/myApp.app/Library/Caches

cache 6 exists: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/myApp.app

----------------------------

cache 1 exists: /Library/Caches

cache 2 exists: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/Library/Application Support/com.example.myApp/Local Store

cache 3 exists: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/Library/Application Support/com.example.myApp/Local Store

cache 4 doesnt exist: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/Library/Application Support/com.example.myApp/Local Store/Library/Caches

cache 5 doesnt exist: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/Library/Application Support/com.example.myApp/Local Store/Library/Caches

cache 6 exists: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/Library/Application Support/com.example.myApp/Local Store

I would have expected 'Library/Caches' to resolve.. You can see clearly 'cache 5 doesnt exist: /var/mobile/Applications/F6DD6D3B-E01A-44B5-849C-349170008DDD/myApp.app/Library/Caches' traced there.

I even made the folders Library\Caches included it as a folder in my publish options. I still don't see the directories existence. Now that's weird. I also include a 'data' folder and that exists if I trace for it.

Any tips on how I can find this "Library/Caches" path?

This topic has been closed for replies.
Correct answer sinious

The answer to access /Library/Caches/ is like so:

var homePath:String = File.applicationDirectory.nativePath;

var cachesFolder:File = new File(homePath + "/\.\./Library/Caches");

if (cachesFolder.exists) { trace('it exists!'); }

1 reply

sinious
siniousAuthorCorrect answer
Legend
February 6, 2012

The answer to access /Library/Caches/ is like so:

var homePath:String = File.applicationDirectory.nativePath;

var cachesFolder:File = new File(homePath + "/\.\./Library/Caches");

if (cachesFolder.exists) { trace('it exists!'); }

January 17, 2013

With AIR 3.6 latest prerelease, this workaround is not required. A new static property, File.cacheDirectory has been added, which points to the <APPLICATION_HOME>/Library/Caches directory on iOS devices, and files in this directory are not backed up.
You can find additional details on this feature here<http://labsdownload.adobe.com/pub/labs/flashruntimes/shared/air3-6_flashplayer11-6_releasenotes.pdf>