I have a button that downloads an image to the phone gallery using Picasso library.. the image is downloaded but I can't save it to the gallery.. 

I'm trying to save the image to the DCIM folder using the following code : 

```
                if (bitmap != null) {
                    FileOutputStream out = null;
                    try {

                        String name = Environment
                                .getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
                                + "/"
                                + pageTitle
                                + "-img"
                                + System.currentTimeMillis() + "." + imgExt;

                        Log.d("Bitmap", "Name: " + name);

                        File f = new File(name);
                        out = new FileOutputStream(f);
                        bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);

                        Intent mediaScanIntent = new
                        Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                        Uri contentUri = Uri.fromFile(f);
                        mediaScanIntent.setData(contentUri);
                        SinglePageActivity.this.sendBroadcast(mediaScanIntent);

                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        try {
                            if (out != null) {
                                out.close();
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                } else {
                    Log.d("Bitmap", "Null image");
                }

```

But I get the following exception : 

> 
> java.io.FileNotFoundException:
>  /storage/sdcard/DCIM/offer11-img1438046842226.jpg: open failed: EACCES
>  (Permission denied)
>  Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
> 
> 
> 

on this line :

```
out = new FileOutputStream(f);

```

Also is there a more efficient way to save the image to the gallery directly ? 

Thanks