adhi Immanuel
adhi Immanuel

Reputation: 1

How To Write XML to applicationDirectory for android air

I am trying to write an xml file to my applicationDirectory, but it doesnt work...

My code is:

pathToFile = File.applicationDirectory.resolvePath("app:/tbHewan.xml").nativePath;//   
file = new File(pathToFile);
fileStream = new FileStream();
fileStream.openAsync(file, FileMode.WRITE);
fileStream.writeUTFBytes(xml.toXMLString());
hais.text = file.nativePath+"\n"+file.url; //this only for tracing my location
fileStream.addEventListener(Event.CLOSE, fileClosed);
fileStream.close();

But it doesnt work on my android device

Upvotes: 0

Views: 197

Answers (1)

CyanAngel
CyanAngel

Reputation: 1238

You cannot write to File.applicationDirectory (or use app: which is just a URL shortcut to File.applicationDirectory). It is a protected path in android and it is considered bad practice in all OS versions, use File.applicationStorageDirectory instead.

pathToFile = File.applicationStorageDirectory.resolvePath("tbHewan.xml").nativePath;

Upvotes: 1

Related Questions