How To specify the path for Storage.getInstance().writeObject(filePath, data);

6 views
Skip to first unread message

Mark Bolduc

unread,
Oct 25, 2020, 12:21:55 PM10/25/20
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA Netbeans 12
Desktop OS Windows 10 Pro
Simulator latest
Device All

I am using Storage.getInstance().writeObject(filePath, data); and want to specify the folder to persist the data.

I don't see any methods exposed that allow this.

Thoughts?

regards.

Shai Almog

unread,
Oct 25, 2020, 11:46:23 PM10/25/20
to CodenameOne Discussions
Storage is a flat space that's cross platform. Don't confuse it with FileSystemStorage. On the simulator (and some devices) they map to similar locations but not on all.

FileSystemStorage is a hierarchy system but it has portability complexities. Storage is always flat.

Mark Bolduc

unread,
Oct 26, 2020, 3:59:14 PM10/26/20
to CodenameOne Discussions
Understood, 

However can I control what folder this object is written?

Shai Almog

unread,
Oct 26, 2020, 10:56:29 PM10/26/20
to CodenameOne Discussions
No. Storage isn't necessarily a user accessible folder.

If you want to use the Externalizable API to write to file system you can use the Util class methods.
Reply all
Reply to author
Forward
0 new messages