Now CCFileUtils::getWriteablePath returns different values on different platforms
* iOS
/Caches
* Android
/data/data//caches
It seems that the return value on iOS and Android is not so suitable. And i want to change the return value of CCFileUtils::getWriteablePath, but i am sure
if i am correct.
iOS
what’s the problem
Refer to this document, it says that
On iOS 5.0 and later, the system may delete the Caches directory on rare occasions when the system is very low on disk space. This will never occur while an app is running.
However, you should be aware that iTunes restore is not necessarily the only condition under which the Caches directory can be erased.
So, it is not safe to safe a file in /Caches.
what’s correct path
There are two other path can be used to save a file in on iOS except for /Caches:
* /Documents
* /Library
Some developer told me that, Apple will reject an app if it saves a file in /Documents. I am not sure if it is true. The other problem
of /Documents is that, the contents under it will be backup. It meas that, if you save a file in /Documents, a customer
will use iTunes to checkout this file and modify it. So i think /Documents is not suitable for saving files.
Android
what’s the problem
Now CCFileUtils::getWriteablePath() returns the value returned by Context.getCacheDir(). According to this document,
it says that
public abstract File getCacheDir ()
Added in API level 1
Returns the absolute path to the application specific cache directory on the filesystem. These files will be ones that get deleted first when the device runs low on storage.
There is no guarantee when these files will be deleted. Note: you should not rely on the system deleting these files for you; you should always have a reasonable maximum,
such as 1 MB, for the amount of space you consume with cache files, and prune those files when exceeding that space.
So it is not suitable to save file in this directory.
what’s correct path
I think the correct path to save files is /data/data//, is it right?
Conclusion
As a result, /Library is the best choice to save a file on iOS,
and /data/data// is the best choice on Android.
Please correct me if i am wrong.