How to download a file and store it on a tablet

Hi everyone,

I have a huge problem. I am currently working on a game on iPad2 and Android tablets. I need to download a file (an xml file, to be precise) from an url address, and store it on the device for later use (reading, parsing, whatever).

I have read that I could use persistentDataPath – which I have done (as shown below) – but this doesn’t work for the iPad, while being perfectly ok for the Android tablet. Here is a snippet of my code:

yield return www;
XmlDocument xmlDoc = new XmlDocument();
if (iPhoneSettings.generation == iPhoneGeneration.iPad2Gen){
  xmlDoc.Save(Application.persistentDataPath + "/database.xml");
else if(Application.platform == RuntimePlatform.Android){
  xmlDoc.Save(Application.persistentDataPath + "/database.xml");
else{ // for PC applications
  xmlDoc.Save(Application.dataPath + "/StreamingAssets/database.xml");

I really can’t see what’s wrong with this.

Thank you in advance!


EDIT: Just added a missing line in the code. Can anyone help me? :slight_smile:

here’s a fragment for a PNG, it may help you …

function _folder():String
	return Application.persistentDataPath + "/fattie";
function _filename( n:int ):String
	return "picture" + n + ".png";
function _fullFilename( n:int ):String
	return _folder() + "/" + _filename(n);

	var bytes:byte[];
	bytes = sillyPhoto.EncodeToPNG();
	System.IO.File.WriteAllBytes( _fullFilename( 13 ), bytes );