title: Saving Bitmap to external memory
body: <p>i am Saving a GIF into external memory, in my code i am getting the GIF from Drawable and I am able to save it to external memory Fine.But would any one please help me saving GIF from Bitmap of a GifImageView.</p>
  
  <pre><code>  protected void onCreate(Bundle savedInstanceState) {
      if (savedInstanceState != null)
          fileName = savedInstanceState.getString("fileName");
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      gif = (GifImageView) findViewById(R.id.ggg);
   save.setOnClickListener(new saveclick());
   }
  
  
        class saveclick implements Button.OnClickListener {
      @Override
      public void onClick(View v) {
  
        saveGIF();
                           }
                               }
  
                 private void saveGIF()
  {
      try
      {
          File file = new 
  
            File(Environment.getExternalStoragePublicDirectory
                                  (Environment.DIRECTORY_DOWNLOADS), "shared_gif_shai" + 
                    System.currentTimeMillis() +  ".gif");
  
          long startTime = System.currentTimeMillis();
  
  
         // InputStream is = new BufferedInputStream(new 
          FileInputStream("source.bitmap"));
          InputStream is =getResources().openRawResource(+R.drawable.aa);
  
          BufferedInputStream bis = new BufferedInputStream(is);
          //bitmap = BitmapFactory.decodeStream(bis);
  
  
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          //Log.d(TAG, "on do in background, create buffered array output 
          stream");
  
          byte[] img = new byte[1024];
  
          int current = 0;
  
  
          while ((current = bis.read()) != -1) {
              baos.write(current);
          }
  
  
  
          FileOutputStream fos = new FileOutputStream(file);
          fos.write(baos.toByteArray());
  
  
          fos.flush();
  
          fos.close();
          is.close();
  
      }
      catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>InputStream in this code is getting the GIF from drawable, is there any way to get the bitmap into inputStream? Thanks alot.</p>