Filename to use for android's SharedPreferences to access Cocos CCUserDefaults

This may have been more apparent to others or easier to find, but I had a lot of trouble finding the solution to accessing values between my android activity and the cocos layer. And I know this functionality was just recently added, not a month ago.

After digging in the source, I found the filename used for CCUserDefault is “Cocos2dxPrefsFile”.

So if you want to save some information from an android activity and access that data in the cocos layer (or visa versa) easily,
you can use
getSharedPreferences( “Cocos2dxPrefsFile”, MODE_PRIVATE );

This may be similar in iOS, but I’ve only been working with Android.

Just thought this post might be useful to other lost souls searching the web for the solution :slight_smile:

NOTE: this is only an available option with version 2.1.2 I believe.

This is useful!