[URGENT] cc.sys.localStorage problem with Android Studio

I don’t know why this happen, or if it only happen with Android Studio, or with android targets.
I have this piece of code

    var userData = null;
    var userDataKey = USER_FILE;
    var ls = cc.sys.localStorage;

    userData = ls.getItem(userDataKey);

    if (userData == null)
    {
        cc.log("No saved file... Saving new one");
        SaveData();
    }
    else
    {
        var levelData = JSON.parse(userData);
        LevelInfo = {};
        LevelInfo = null;

        LevelInfo = levelData;
    }

The SaveData():

var SaveData = function()
{
    var ls = cc.sys.localStorage;
    var userDataKey = USER_FILE;
    var userDataValue = JSON.stringify(LevelInfo);
    ls.setItem(userDataKey, userDataValue);
};

Those codes are working on web and iOS… and they also work with Android, BUT, and here is my surprise, it doesn’t work at the beginning. When I press “Run” in Android Studio the game won’t start, showing a black screen; then if I comment the first block and I press “Run” again, the game works… and if I uncomment the code… it keeps working, :stuck_out_tongue: Why is this happening. Does someone had the same issues with cc.sys.localStorage. I’m using cocos2d-js 3.7.1. Also, I keep getting the warning “rejecting org/lib/localStorage”. But it works if I keep commenting/uncommenting that piece of code. What other way can I use to saves a js object?.

Using jsb.fileUtils with same results… Black screen if I try to save a file… What am I doing wrong?

        var path = jsb.fileUtils.getWritablePath();
        var file = cc.path.join(path, USER_FILE);

        if (!jsb.fileUtils.isFileExist(file))
            var saved = jsb.fileUtils.writeToFile(LevelSaved, file);
        else
            var data = jsb.fileUtils.getValueMapFromFile(file);

Ok, I believe that I’m closer to the solution (I hope!), only in Android I’ve change, using the first post code, the conditional: if (userData == null) for if (userData == “”)

Yes josempan right
Android accept userData==""
and js accept userData==null