In my mobile app I have an object implementing PropertyBusinessObject which contains numerous other objects also implementing this interface. This object structure is populated by JSON data I am getting back from my server. When I try to write this object to Storage with writeObject() I get the above error. The stacktrace shows it originating in the com.codename1.io.Util.writeObject() method where it is writing UTF-8 (limited to 64k). The developer guide does not reference any potential issues with Storage and recommends it over FileSystemStorage. My question is, is there a workaround/update for this? Would I have to revert to writing out the object structure to the filesystem? Thanks.
Asked
Active
Viewed 1,078 times
1 Answers
0
If you have a ridiculously long string e.g. to represent the contents of the file I would suggest rethinking that. Strings are inefficient in Codename One since we need to copy their representation into the iOS native layer. Also writing them to UTF is very wasteful if what you need is a binary representation. I suggest using a byte array.
Serializing to storage is a simple approach. It works great for small objects. If you have larger objects you might want to store them individually. You can also serialize to/from JSON so your storage data is readable.

Shai Almog
- 51,749
- 5
- 35
- 65
-
Thanks @Shai. Storage was working well but broke now when I did include some binary data which can be stored separately. Will take your suggestion/approach. Great platform btw, find what you've done with CN1 a real benefit to what I want to achieve. – Gabriel Kazama Jun 11 '21 at 06:03
-
Thanks! Be sure to spread the word around: https://www.codenameone.com/blog/how-you-can-help-spread-codenameone.html – Shai Almog Jun 12 '21 at 03:09