Store list or vector of objects with Storage

47 views
Skip to first unread message

philip...@gmail.com

unread,
Feb 6, 2015, 10:45:51 AM2/6/15
to codenameone...@googlegroups.com
Hi,

I'm currently testing Storage object to see how good I can store datas without any database. Is it possible to store vector of externalizable objects?
this returns me IOException (type not supported):

Vector<Student> vectStudentsStored = (Vector<Student>) Storage.getInstance().readObject("vectStudents");

Student is implementing Externalizable and I did Util.register("Student", Student.class) before reading it. Of course I wrote vectStudents.

Thank you in advance.

Steve Hannah

unread,
Feb 6, 2015, 11:12:10 AM2/6/15
to codenameone...@googlegroups.com
That should work if you implemented Externalizable properly.  Remember:

1. The first parameter of Util.register() must match the value returned from your Externalizable's getObjectId().
2. Any child objects of Student must be externalizable also.

Focus on your Externalizable implementation -- that is likely where the problem lies.

Steve

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/a26cfa9d-c825-433d-879a-acdbb99e7a8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Software Developer
Codename One

Philippe Spat

unread,
Feb 12, 2015, 9:30:56 AM2/12/15
to codenameone...@googlegroups.com
Thank you for you answer Steve.

The problem was not directly in the implementation, it was because I had an argument in the student constructor. I only can use setters to set variables. 

Kind regards
Reply all
Reply to author
Forward
0 new messages