问题描述:

I'm having trouble to store Lists in the storage and then loading it after a new start of my app. Here is what I've done:

At every start of the app I do this, to check if Data has already been written to the storage, if not, I return a new List.

public List loadSavedFormationList(){

String[] temp = Storage.getInstance().listEntries();

for(String s: temp){

if(s.equals("Formations") == true){

return (LinkedList<SongList>)Storage.getInstance().readObject("Formations");

}

}

return new LinkedList<SongList>();

}

When the user has entered a FormationList in my App, I do this to save it to the storage:

Storage.getInstance().writeObject("Formations", formationList);

Now, when I restart the App, I am getting a java.io.EOFException + java.lang.NullpointerException. It seems that he tries to read my Formations List from the storage, but it is empty, but why? On the first start of the App, the Storage should be empty. Does the Simulator also save the stuff I entered into the App at another time?

Thank you for any advice.

网友答案:

Codename One stores ArrayList not LinkedList and will convert that implicitly. I'm guessing the data wasn't written which is why you got the exception, you need to look at the console when writing and make sure all elements are externalizable.

相关阅读:
Top