I am devoloping an app where at certain points the user can save an image file to the sdcard.
All works fine when the phone is connected to the PC but when I disconnect my phone and launch the app, the file saving does not work.
I am guessing that I should use a different path to save when not connected to a PC?
my current path is
"//mnt/sdcard/DCIM/Camera/image"+Math.random()*10000+".jpg"
I am using pure AS3 AIR to develop.
here’s the code:
var bmd:BitmapData = new BitmapData(Main.instance.stage.stageWidth, Main.instance.stage.stageHeight);
bmd.draw(_board)
var je:JPGEncoder = new JPGEncoder(100);
var ba:ByteArray = je.encode(bmd);
var fl:File = File.documentsDirectory.resolvePath("//mnt/sdcard/DCIM/Camera/image"+Math.random()*10000+".jpg");
try{
var fs:FileStream=new FileStream;
fs.open(fl,FileMode.WRITE);
fs.writeBytes(ba,0,ba.length);
fs.close();
}
catch(e:Error){
Main.instance.tf.text = e.message;
}
Thanks in advance,
Android application storage directories are as follows:
Directory in which the app is installed (read-only)
Private storage directory for the app
User’s home directory
User’s document directory
User’s desktop directory
Temporary storage directory
Temporary file