I want to download a set of video files to a default folder path in an Android device and then have access to the path and files. The FileReference class does not support this features. Is there another way? Thank you.
Asked
Active
Viewed 533 times
2
-
You should be able to do it. Can you please show the code? – J_A_X Feb 26 '12 at 20:09
-
put some effort on your question and try to put your code so that answers and reply will be much faster thanks. – Triode Feb 27 '12 at 06:23
-
Thank you for your answers. I have to admit that I found a sample code in this link http://stackoverflow.com/questions/342994/download-a-file-with-adobe-air. However, livedocs under the File class state that the various functions for accessing directories paths e.g. browseForDirectory() are not supported in Android. Moreover, the code I currently use is based on the examples of livedocs which are quite helpful. I apologize for not posting my code since it was code reused for the examples. My main problem still resides to the fact that I cannot have access to the path or folder Android. – Antonios Feb 27 '12 at 13:26
-
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html I don't think browseForDirectory does what you want, if you try this out on a desktop or web app you'll see that it prompts the user to choose a folder location, generally speaking phone users aren't expected to think about the file system nor is there a standard file browser included in the mobile OSes (on a desktop or web app this would prompt the user with a native browse window). – shaunhusain Mar 16 '12 at 01:53
1 Answers
1
I dont use file reference at all. I use a Loader to download the file. I then create a new File object with the path where I want to save the file, and use a FileSteam to write the data from the loader to the file.
var req:URLRequest = new URLRequest(url);
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handler);
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.load(req);
function handler(e:Event):void{
var file:File = new File(path);
var stream:FileSteam();
steam.open(file, FileMode.WRITE);
steam.writeBytes(loader.data);
steam.close();
}
something like this should accomplish what you are looking for. I wrote this code from memory so it may not be exactly correct but should be good enough to get you going. Make sure you put this in a try/catch since file and filesteam both throw exceptions

vjuliano
- 1,474
- 2
- 15
- 29