0

I need to save picture to a Gallery, just to a normal place where the Photos are going. On SO I've found that Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) is internal, no matter that it says ExternalStorage. But mkdirs always return me false.

 String mediaStorage  =
                Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() + "/Camera";
        File mediaStorageDir = new File(mediaStorage);
        if (!mediaStorageDir.exists()) {
            if (!mediaStorageDir.mkdirs()) {
                Toast.makeText(MainActivity.activity, "failed to create directory", Toast.LENGTH_SHORT).show();
                return null;
            }
        }

Is there an easy way to save pics to an internal Gallery directory?

In case, my manifest has :

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
UmarZaii
  • 1,355
  • 1
  • 17
  • 26
Vlad Alexeev
  • 2,072
  • 6
  • 29
  • 59

0 Answers0