Our iOS port has some pieces that are pretty old and haven’t been touched since we started, one of those things
is the IO code which mostly works as we wrote it when we started Codename One. Unfortunately it seems that
Storage in iOS is mapped to the iOS caches directory, this directory can be wiped by the iOS device if space
on the device is running low. That’s a very rare occurrence which is why we didn’t pick that up until a
bug report was filed on it this week…
Unfortunately fixing Storage to point at the right directory would mean breaking compatibility and your app
losing all the data it kept in storage… So we decided to go about this in a rather creative way.
We defined a new build argument which will be on by default for all new projects:
This build argument effectively means that we should use the documents directory as storage and the app is ready
to deal with it. Its useful for apps that aren’t already in users hands. If you don’t define that flag we will automatically
migrate the app to the documents directory on the first usage of
Storage, we will detect if our
storage directory exists under documents and if not we will move all files to that directory. This should maintain
compatibility with a small performance overhead on the first activation for new installs and possibly the first
time this code occurs in a pre-existing app.