The Code below downloads an mp3 to your phone from a server using as3 Air For Android. I want to use these files later in the app so I have the following question:
How can I make it so the files save to a particular folder in the android app rather than a box opening for the user to choose a location?
import flash.net.FileReference;
/// It can be an mp3,jpg, png, etc... just change the url
/// and the extension name. nice huh?
var yourFileLocation = "http://YourWeb.com/YourSong.mp3";
var yourFileName = "YourSong.mp3";
var daFile:FileReference = new FileReference();
daFile.download(new URLRequest(yourFileLocation), yourFileName);
Would also be sweet to monitor this progress, when it starts, stops and progress but I think an eventListener might work with that.
The Following Code downloads an mp3 from a remote url and makes a folder called .007(You can change the name or add many or no folders). Then it saves to that location.
P.S. REMEMBER TO GRANT THE CORRECT PERMISSIONS USING ANDROID IN THE APP
I was looking all over the place for an answer on how to download etc...
What I personally prefer is to download any file with LoaderMax from Greenshocks AS3 library (which is already included in most of my projects since its a kick-ass lightweight loader.
Instead of specifying a URL which is local i specify a URL which is remote.. lemme show you some code:
And below is the handler for the COMPLETE event. You can also have handler for ERROR,FAIL,PROGRESS etc you name it..
Remember LoaderMax does not really care whether the file is local or remote, it just loads it into memory..
From that point on you can decide whether you want to save it as a file or just use it and then discard it.
If you want to save it as a file here is how: (iOs example below)