Suggestion about changing the location of cn1storage folder

47 views
Skip to first unread message

P5music

unread,
Jun 3, 2021, 9:10:05 AM6/3/21
to CodenameOne Discussions
Can the cn1storage folder be under the Library directory on iOS instead of Documents for new maven templates or as an option for existing projects (at least those unpublished yet like mine)?

My app exposes the Documents folder to the user.
The user doesn't want to see other content among the "documents". It also can be accidentally deleted
even if it is made not visible, but it could be an option, I think. I saw also other files there, as for example a sort of package.
There is no technical reason to leave it in the Documents directory, the Library folder is under control of the app.

My app also created Library/Application Support, that is private to it.
Also other folders can be created under Library, that are different from the Application Support one (please do not put it there).

Regards

Shai Almog

unread,
Jun 3, 2021, 11:09:24 PM6/3/21
to CodenameOne Discussions
We can't change something dynamically as it will break compatibility. You can submit an RFE or pull request which provides the different storage location option as an API or configuration.

P5music

unread,
Jun 4, 2021, 2:45:03 AM6/4/21
to CodenameOne Discussions
Ok,
I meant for new projects or for developers who are aware of it, before publishing the app, like me.

However, I would like to understand if some other solution is available for my project.
My app does not use the Storage at all. It just has two data files in the Library/Application Support folder, and uses the Documents folder. Both are managed with the FileSystem access.

1 - Can I delete the cn1storage folder?
2 - Can its re-creation be prevented?
3 - Can I hide the folder?
4 - Can it be deleted by mistake but that being harmless, so I do not care if the user deletes it, even when it is hidden?
5 - What about the other CN1 content that can be seen in the Documents folder?

Regards

Shai Almog

unread,
Jun 5, 2021, 2:20:02 AM6/5/21
to CodenameOne Discussions
You might be able to move storage by setting ios.newStorageLocation=false which will place stoage under the caches directory. Notice that it might have adverse effects on some things but I doubt it will impact you much.

1. It might be recreated since things like Preferences use storage and we use Preferences internally.
2, 3. Not at this time
4. I think that will work. Didn't test this though
5. Such as? We have the app home directory which we use when you open a file association etc.

P5music

unread,
Jun 5, 2021, 3:13:28 AM6/5/21
to CodenameOne Discussions
(5)
So could the Documents folder passed random content according to what the user does with my app? so the user can see files not moved there explicitly by him/her?
Is that folder used as the inbox folder for my app and other things as a matter of fact?
Regards

Shai Almog

unread,
Jun 5, 2021, 9:05:52 PM6/5/21
to CodenameOne Discussions
We place the HTML files from the html directory there, if you pass a file to the app it's generally copied into there. We don't write there normally though.

P5music

unread,
Jun 8, 2021, 4:24:31 AM6/8/21
to CodenameOne Discussions
So, I used the ios.newStorageLocation=false hint
and
String documentsRoot=FileSystemStorage.getInstance().getRoots()[0];
yields a different path of course, I had to change the code for retrieving the "Application Support" and the "Documents" folders path.
It seems to work.
Regards

P5music

unread,
Jun 9, 2021, 3:11:41 PM6/9/21
to CodenameOne Discussions
Do you know if
ios.newStorageLocation=false
is overidden in some cases?
For example for some iOS versions.
I am testing with iOS 12, along with some other versions, and it seems that for iOS 12 the cn1storage folder is created even with that build hint.
Does it make sense to you? Is it possible?

Thanks

Shai Almog

unread,
Jun 9, 2021, 9:19:34 PM6/9/21
to CodenameOne Discussions
It's possible there's some code somewhere that does that but I'm unaware of this. Since this literally replaces the order of the roots it should be OK.
To be fair this isn't a use case we thought of when we built this behavior so I might be missing something.


Reply all
Reply to author
Forward
0 new messages