- Home /
Application.persistentDataPath is not working in Ios Device?
My app is working perfectly in android but in ios devices, app is unable to retrieve data from the file. What could be the reasons for the following problem?
I am Using this Code which is working fine in android but not in ios devices to save and load the data in different scenes. Can you please tell where do i need to edit the script exactly?
public void Save() {
BinaryFormatter bf = new BinaryFormatter ();// CREATES A BINARY FOR$$anonymous$$ATTER
FileStream file = File.Create(Application.persistentDataPath + "/playerInfor.dat"); // CREATES A FILE
PlayerData data = new PlayerData (); // CREATES A CONTAINER FOR OBJECTS
data.scoreValue = scoreValue;
data.bestScoreValue = bestScoreValue;
bf.Serialize (file, data); //WRITE THE DATA OF PLAYERDATA INTO FILE
file.Close ();
}
public void Load()
{
if(File.Exists(Application.persistentDataPath + "/playerInfor.dat"))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath + "/playerInfor.dat", File$$anonymous$$ode.Open);
PlayerData data = (PlayerData)bf.Deserialize(file); // CASTING IS USED TO $$anonymous$$NOW THE OBJECTS FRO$$anonymous$$ FILE ARE OF PLAYERDATA.
file.Close();
scoreValue = data.scoreValue;
bestScoreValue = data.bestScoreValue;
}
}
Answer by smoggach · Dec 01, 2014 at 05:22 PM
The android operating system knows what to do with the path you provide. iOS is far more picky. Try escapeuristring. WWW www = new WWW(System.Uri.EscapeUriString("file://" + System.IO.Path.Combine(Application.persistantDataPath, fileName)));
hi, I have the same issue , where would you put that?
Your answer

Follow this Question
Related Questions
iOS playing audio from Documents folder 2 Answers
Upload/Download user files Android/IOS, 0 Answers
Latest Unity can run on iphone 3? 1 Answer
File Read-Write Error in iOS 1 Answer
Unity Remote 5 0 Answers