title: AS3: How to take JPG / PNG screenshot and save it to SDCard directories of Android mobile
body: <p>I made an Android mobile app by taking a screenshot and saving it into JPG / PNG format and saved to directory SDCard / Internal storage on android mobile. </p>
  
  <p>When I tried it on desktop all went right with no problem. After I publish and install the <code>.apk</code> into mobile Android, if I hit save button iI get an error like this </p>
  
  <blockquote>
    <p>"Unfortunately, My application has stopped."</p>
  </blockquote>
  
  <p>Can anyone help me about this error?</p>
  
  <p>This my code :</p>
  
  <pre><code>import flash.events.MouseEvent;
  import flash.display.MovieClip;
  import flash.display.DisplayObject;
  import com.adobe.images.JPGEncoder;
  
  btn_save.addEventListener(MouseEvent.CLICK, save_image);
  function save_image(e:MouseEvent):void
  {
     btn_back.visible = false;
     btn_save.visible = false;
     var qImageData:BitmapData = new BitmapData(540, 960);
     qImageData.draw(stage);
     var qEncoder:JPGEncoder = new JPGEncoder(100);
     var qBytes:ByteArray = qEncoder.encode(qImageData);
     var qfile:FileReference = new FileReference();
     var names:String = "Image_name";
     qfile.save(qBytes, names+".jpg");
     btn_back.visible = true;
     btn_save.visible = true;
  }
  </code></pre>
  
  <p>thanks.</p>