not sure if this is still an open topic for Cocos2d-x, we at V-Play ( http://v-play.net ) also had a deeper look into the topic of writable paths. Our game engine defines four location types (explanation is iOS-specific as of iOS 5.1 and above):
CacheLocation: "/var/mobile/Applications//Library/Caches/" -> NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)
DataLocation: "/var/mobile/Applications//Library/Application Support/" -> NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)
DocumentsLocation: "/var/mobile/Applications//Documents/" -> NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
TempLocation: "/private/var/mobile/Applications//tmp/" -> NSTemporaryDirectory()
The locations can be selected depending on the desired behaviour in respect to BACKUP (iCloud back up), PURGE (auto purging files if the device runs out of memory) and PUBLIC (users can probably read the files with iTunes):
For user generated data, backed-up to iCloud, can be read with iTunes
All application specific files that need not persist between application launches must be put here and should be deleted at application exit.
For configuration files, backed-up to iCloud, not purged
~~> possible to apply the com.apple.MobileBackup extended attribute to prevent from backing up to iCloud
Can be purged when devices run out of (physical) memory, so must be re-downloaded in some cases
So to summarize I would suggest:
- For save games, screenshots and other user-generated content ~~> DocumentsLocation
~~ For downloadable content which can be fetched from web again -> CacheLocation or DataLocation with “no backup” file attribute
On Android there are the methods getFilesDir(), getCacheDir() (and there external representations getExternalFilesDir(), getExternalStoragePublicDirectory(), getExternalCacheDir()) like already stated above.
Hope this helps a little bit, cross-platform storage paths are sometimes a real mess!