Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

How to access additional SharedPreferences on Android

$
0
0
We are porting an Android game from Cocos2d to Unity. We want to move players' saved game setting with the new install. In the original (Java/ C++) version of the game, we saved these in SharedPreferences. Example (somewhat truncated): public String getUserPref (String key) { String val = getSharedPrefs ().getString(key, ""); return val; } private SharedPreferences getSharedPrefs () { if(sharedPref == null) { sharedPref = Cocos2dxActivity.getInstance().getSharedPreferences("GamePrefs", 0); } return sharedPref; } How can we now access the original SharedPreferences? We'd really like to avoid writing an Android Library for this. I understand that Unity PlayerPrefs stores/ access SharedPreferences, but under a different name. We need to access prefs stored under the GamePrefs name.

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>