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

Get All Key and Value of PlayerPrefabs saved on Device Android

$
0
0
On Android data is stored (persisted) on the device. The data is saved in SharedPreferences. C#/JavaScript, Android Java and Native code can all access the PlayerPrefs data. The PlayerPrefs data is physically stored in ```/data/data/pkg-name/shared_prefs/pkg-name.xml``` . And we can get all key,value saved in storage device android by scripts C#? I tried with scripts: ``` public static void ReadAndroidSharedPreferences(string packageName, string xmlDataName) { string path = "/data/data/" + packageName + "/shared_prefs/" + xmlDataName + ".xml"; FileStream levelFile = File.Open(path, FileMode.Open); XmlDocument xmlDoc = new XmlDocument(); string xmlText = ""; using (StreamReader sr = new StreamReader(levelFile)) { string line = null; do { line = sr.ReadLine(); xmlText = xmlText + line + "\n"; } while (line != null); sr.Close(); levelFile.Close(); } xmlDoc.LoadXml(xmlText); var baseNode = xmlDoc.DocumentElement; foreach (XmlNode node in baseNode.ChildNodes) { Debug.Log("Type: " + node.Name); if (node.Attributes["name"] != null) Debug.Log("name: " + node.Attributes["name"].Value); else Debug.Log("Empty"); if (node.Attributes["value"] != null) Debug.Log("Value: " + node.Attributes["value"].Value); else Debug.Log("Empty"); } } ```

Viewing all articles
Browse latest Browse all 1333

Trending Articles



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