07-18-2012 07:31 PM
Hi there,
FIrst of all, there seems to be an error in the documentation here: https://developer.blackberry.com/native/documentat
Second of all, any files I write to the tmp directory appear to get deleted as soon as the application exits. This is very inconvenient for me. I want to use the tmp directory for persistent caching of data between launches... I'm fine if it needs to be purged by the system on occasion for arbitrary reasons, and I don't want it to be backed up as permanent application data, but having it purged every single execution is pretty much useless to me.
Is there a way to change this behaviour? Or another directory that's recommended for use for caching/temporary files but not quite as aggressively purged as tmp?
Thanks,
Dan.
07-18-2012 07:37 PM
Hi
Why you want to use tmp dir? If you need to store some files , store them into app folder, they will be accessible only to your app.
07-18-2012 07:41 PM
Well, the reason for using the tmp directory instead of your app directory is twofold:
1. For files that you don't need backed up. A web browser, for example, might want to cache several hundred megabytes of web pages downloaded from the internet, but it would be wasteful and pointless to have those files backed up.
2. For files that you won't necessarily miss if they're purged. Again, with the web browser, it's very convenient to have the cached files around, but if the system needs to wipe them to make space it's not a problem to download them again.
Dan.
07-18-2012 08:53 PM
07-18-2012 10:40 PM
07-18-2012 10:46 PM
07-19-2012 01:31 PM
I've fired off some inquiries to the backup folks to see if we can find a solution that works for you.
I don't think we'll be able to get you a "pooled" cache directory where it only gets emptied when other apps need the space, as that is a nontrivial system feature. However, if I could get you support for something like an ".ignore" convention for folders in appdata/ during backups would that be a good start?
Obviously, the amount of space your app consumes or needs to consume is going to be dependent on what sort of app you have, and as a result, pruning that data should really be the responsibility of your app. You imply that this is a fundamental OS feature, but I'm not familiar with any comparable feature in other operating systems. If you could direct me to one, I'd be glad to learn about it.
Cheers,
Sean
07-19-2012 01:38 PM
Try putting your cache files in the "logs" directory. I am told that this folder is not part of backups. You will still need to do your own pruning.
I will pursue a more appropriate solution further, but will end up requiring backing from the highest levels to modify the appdata/ directory structure to add a new folder such as "cache".
Cheers,
Sean
07-19-2012 01:39 PM
Well, iOS and Android both have such a directory.
iOS has Library/Caches: http://developer.apple.com/library/mac/#documentat
Anroid has getCacheDir(): http://developer.android.com/guide/topics/data/dat
Both of these may be purged by the operating system but are not automatically, and are ignored by backup systems.
Dan.
07-19-2012 01:48 PM
Thanks for the info. I will use it to argue for this use case. The rules are a bit hand-wavy as to how such a cache dir operates on those systems, so much so that the tmp/ behaviour would also fall under that umbrella presently.
In any event.. the logs/ directory is persistent storage, and is not backed up, so it sort of suits your needs, however I have been cautioned that putting hundreds of MB in there may anger the system service that handles app crashes, as it may be making copies of these logs as part of crash reports. So be careful in the meantime.
Cheers,
Sean