title: Save bitmap to location
body: <p>I am working on a function to download an image from a web server, display it on the screen, and if the user wishes to keep the image, save it on the SD card in a certain folder. Is there an easy way to take a bitmap and just save it to the SD card in a folder of my choice?</p>
  
  <p>My issue is that I can download the image, display it on screen as a Bitmap. The only way I have been able to find to save an image to a particular folder is to use FileOutputStream, but that requires a byte array. I am not sure how to convert (if this is even the right way) from Bitmap to byte array, so I can use a FileOutputStream to write the data.</p>
  
  <p>The other option I have is to use MediaStore :</p>
  
  <pre><code>MediaStore.Images.Media.insertImage(getContentResolver(), bm,
      barcodeNumber + ".jpg Card Image", barcodeNumber + ".jpg Card Image");
  </code></pre>
  
  <p>Which works fine to save to SD card, but does not allow you to customize the folder.</p>