UserDefaults::flush() empty?

I want to save 1 integer using the UserDefault class.
right after i used setIntegerForKey i call flush to save the data.
But the data isnt saved (flush method also empty).
Also the data isnt placed into the ram, when i try getIntegerForKey it returns 0. (same game session)
i use the sharedUserDefault.
someone knows what im doin wrong?

auto sh = UserDefault::sharedUserDefault();
int val = sh->getIntegerForKey("xyz"); // returns 0 no matter what
if( score > val ){
  sh->setIntegerForKey("xyz",score);
  sh->flush(); // is empty, using cocos2dx 3.2rc0
}

You seem to be using a deprecated method.

Check out the sample in cpp-tests for correct usage.

1 Like

http://www.cocos2d-x.org/reference/native-cpp/V3.2/db/d94/classcocos2d_1_1_user_default.html