title: android - save image into gallery
body: <p>i have an app with a gallery of images and i want that the user can save it into his own gallery.
  I've created an option menu with a single voice "save" to allow that but the problem is...how can i save the image into the gallery?</p>
  
  <p>this is my code:</p>
  
  <pre><code>@Override
          public boolean onOptionsItemSelected(MenuItem item) {
              // Handle item selection
              switch (item.getItemId()) {
              case R.id.menuFinale:
  
                  imgView.setDrawingCacheEnabled(true);
                  Bitmap bitmap = imgView.getDrawingCache();
                  File root = Environment.getExternalStorageDirectory();
                  File file = new File(root.getAbsolutePath()+"/DCIM/Camera/img.jpg");
                  try 
                  {
                      file.createNewFile();
                      FileOutputStream ostream = new FileOutputStream(file);
                      bitmap.compress(CompressFormat.JPEG, 100, ostream);
                      ostream.close();
                  } 
                  catch (Exception e) 
                  {
                      e.printStackTrace();
                  }
  
  
  
                  return true;
              default:
                  return super.onOptionsItemSelected(item);
              }
          }
  </code></pre>
  
  <p>i'm not sure of this part of code:</p>
  
  <pre><code>File root = Environment.getExternalStorageDirectory();
                  File file = new File(root.getAbsolutePath()+"/DCIM/Camera/img.jpg");
  </code></pre>
  
  <p>is it correct to save into the gallery?
  unfortunately the code doesn't work :(</p>