title: How to save image in android gallery
body: <p>I try to save the image into WathsappIMG but when I go to image gallery android I don't see the image and the image there into the directory can be seen from ES File Explorer</p>
  
  <pre><code>OutputStream output;
         // Find the SD Card path
          File filepath = Environment.getExternalStorageDirectory();
  
        // Create a new folder in SD Card
       File dir = new File(filepath.getAbsolutePath()
                + "/WhatSappIMG/");
          dir.mkdirs(); 
  
       // Retrieve the image from the res folder
          BitmapDrawable drawable = (BitmapDrawable) principal.getDrawable();
          Bitmap bitmap1 = drawable.getBitmap();
  
          // Create a name for the saved image
          File file = new File(dir, "Wallpaper.jpg" );
  
          try {
  
              output = new FileOutputStream(file);
  
              // Compress into png format image from 0% - 100%
              bitmap1.compress(Bitmap.CompressFormat.JPEG, 100, output);
              output.flush();
              output.close();
  
          }
  
          catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  </code></pre>