- Home /
How to access additional SharedPreferences on Android
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.
Your answer
Follow this Question
Related Questions
Does Android delete PlayerPrefs when Updating the App? 2 Answers
Is it okay to store many player preferences for mobile? 1 Answer
Load NSUserDefaults from previous Android app. 0 Answers
does unity 5.3 change player prefs path or file extension on android ? 1 Answer
DeleteAll not working on android? 0 Answers