[Solved] UserDefault on win32 not work

Trying to build a mobile game. I am using Windows PC for developing. But when I save data though UserDefault it is not saving. Even the snippet below does not work.

const char* key = "theKey";
UserDefault::getInstance()->setIntegerForKey(key, 1);
UserDefault::getInstance()->flush();
int what = UserDefault::getInstance()->getIntegerForKey(key);
UserDefault::getInstance()->flush();
what = UserDefault::getInstance()->getIntegerForKey(key);

This always returns 0.

There is no other language on c:\user\MyName.

Any suggestion?
Thanks.

I am also experiencing this issue on 2.2.6 windows 7 64Bit

There should be a folder under c:\user\MyName\ called AppData it’s a hidden folder so make sure you enable hidden folders in control panel. Under that folder should be another folder with the name of your game - that’s where the file should be saved.

Sorry for my dumb mistake. The reason was the comma (,). You should not use comma in as a key for json. After remove all commas from the json file. It works fine.