title: Saving a BitmapDrawable or Bitmap
body: <p>Okay, so I have a code, that take an image of the current view, and turns it into a bitmap, then I end up here,</p>
  
  <pre><code>Bitmap bm = view.getDrawingCache();
  BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
  </code></pre>
  
  <p>now, what I'm trying to do, is take a picture of what the current view looks like, but from here, I can easily put <code>bitmapDrawable</code> into an ImageView, but thats not what I want, I'd like to go from here, to saving it. What can I do? I found out one way, using</p>
  
  <pre><code>FileOutputStream fos;
    try {
     fos = super.openFileOutput("output.png",MODE_WORLD_READABLE);
     bm.compress(CompressFormat.PNG, 75, fos);
  
        fos.flush();
        fos.close();
    } catch (FileNotFoundException e) {
     e.printStackTrace();
    } catch (IOException e) {
     e.printStackTrace();
  </code></pre>
  
  <p>}<br>
  but when I do this, I end up with a NullPointerException at</p>
  
  <pre><code>bm.compress(CompressFormat.PNG, 75, fos);
  </code></pre>
  
  <p>am I missing something?</p>
  
  <p>Okay, now it makes it through the above code, then makes it past <code>fos.close();</code> to finish, but then nothing happens, its not saved, not on my phone, nothing</p>