-3

I am following the code snippet given here in this guide. The following lines (particurly the last if block in the following lines) are presenting a problem:

File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES), "MyCameraApp");

    // This location works best if you want the created images to be shared
    // between applications and persist after your app has been uninstalled.

    // Create the storage directory if it does not exist
    if (! mediaStorageDir.exists()){
        if (! mediaStorageDir.mkdirs()){
            Log.d("MyCameraApp", "failed to create directory");
            return null;
        }
    }

The problem is that return null; in the snippet above is always executed.

This means that mediaStorageDir.mkdirs() always returns false.

The question is why and what can I do to fix it?

Solace
  • 8,612
  • 22
  • 95
  • 183

1 Answers1

0

do you have set

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

in your Manifest file?

Richard R
  • 873
  • 6
  • 20