0

I have a problem. I'm creating an appplication for android with AS3 and the problem i´ve got it's that when I install the application in my android the directory I should create is doesn't appear and the file neither.

var dirPath:File = File.applicationStorageDirectory.resolvePath("MUSIC/");                     
var newFile:File = File.applicationStorageDirectory.resolvePath("songslist.xml");  
if (!dirPath.exists)
    {
        dirPath.createDirectory();
        stream.open(newFile, FileMode.WRITE);
        stream.close();
        trace("entra if");
    }
if (!newFile.exists)
    {
        stream.open(newFile, FileMode.WRITE);
        stream.close();
    }

Could be the problem that I should write and isntall the app in sdcard ? and how can obtain later the root sdcard for searching all the existing *.mp3 files in the directories to add in my songslist.xml

4

1 回答 1

0

至少我已经解决了。如果有人有兴趣或有同样的问题。

var newFile:File = File.desktopDirectory.resolvePath("MusicPlayer/songslist.xml");
if (!newFile.exists)
{
   stream.open(newFile, FileMode.WRITE);
   stream.close();
}
else
{
    newFile.deleteFile();
    stream.open(newFile, FileMode.WRITE);
    stream.close();
}
于 2013-01-24T15:56:09.333 回答