This site requires JavaScript, please enable it in your browser!
Greenfoot back
Vellyxenya
Vellyxenya wrote ...

2015/11/3

Saving Data

Vellyxenya Vellyxenya

2015/11/3

#
Hi, I have been trying to save the game.credit using the UserInfo.class :
public static void store() 
    {
        if (UserInfo.isStorageAvailable())
        {
            UserInfo myInfo = UserInfo.getMyInfo();
            myInfo.setInt(0, Store.wealth);
        }
    }
public void load()
    {
        if (UserInfo.isStorageAvailable())
        {
            UserInfo myInfo = UserInfo.getMyInfo();
            previousWealth = myInfo.getInt(0);
        }
    }
And it works: I can earn money ingame and re-compile the game again and again, the money I earned is saved. But when I close the who.e Scenario (When I exit Greenfoot) and re-open my project, all the datas are gone... is the method i'm using not useful in that case or is there something wrong in its code? Could you help me please?
danpost danpost

2015/11/3

#
You need to execute the following command for the data to be stored:
myInfo.store();
Vellyxenya Vellyxenya

2015/11/3

#
Oh yes, forgot it, thank you very much!
You need to login to post a reply.