about the new iOS storage location

35 views
Skip to first unread message

Fabrizio Grassi

unread,
Jun 6, 2015, 9:05:06 AM6/6/15
to codenameone...@googlegroups.com
Hi,
this is something not really clear for me.
My app has been released before this change, so I think that I should be in the case in which everything should work seamlessly and my stored files should migrate automatically from /Library/Caches to /Documents.
As far as I can see this is true for some automatically created files and those stored using com.codename1.io.Storage but it is not for those stored using com.codename1.io.FileSystemStorage which are still in the /Library/Caches directory.

So, just because my app rely on this last kind of stored files, how should I behave? Is it correct to change location also to these files? And, if so, is there a specific way to follow or is it up to the developer?

thanks



Shai Almog

unread,
Jun 6, 2015, 10:56:27 AM6/6/15
to codenameone...@googlegroups.com, rbr...@gmail.com
Hi,
thanks for bringing this up. Its a minor detail I did neglect to mention in the blog post...
The FileSystemStorage class has a getRoots method that historically returned caches first and documents second. Unfortunately because of the way filesystem works we can't just move everything in the filesystem so we can't migrate it seamlessly and we can't change the default location of "app home".
However, if the build flag ios.newStorageLocation is defined to true (which you probably shouldn't do for your app) the filesystems will be reversed so the first root would be documents and hence app home will be under documents.

You can migrate your own files to documents by relying on the fact that the documents root is at getRoots()[1].

Fabrizio Grassi

unread,
Jun 24, 2015, 6:46:21 PM6/24/15
to codenameone...@googlegroups.com, rbr...@gmail.com
hi shai,
it seems that getRoots()[1] throws an ArrayIndexOutOfBoundsException on the simulator with an iOS skin, this could be confusing. I was about to write you the same about real iOS devices but suddenly I discovered an infinite loop.
That could lead to more difficult app debugging. 

Shai Almog

unread,
Jun 25, 2015, 1:33:49 AM6/25/15
to codenameone...@googlegroups.com, rbr...@gmail.com
Hi,
yes you will need to check the length of the roots array first.
I don't understand the infinite loop sentence?

Fabrizio Grassi

unread,
Jun 25, 2015, 6:26:12 AM6/25/15
to codenameone...@googlegroups.com
Hi shai,
It is only an example to show you that having only one root in the simulator could lead to difficult debugging.
Reply all
Reply to author
Forward
0 new messages