Read and Write Android external storage


It seems the specifying the following two flags in manifest is not enough for android app to read and write from/to places like /storage/emulated/0/Music

I failed to read from the path like above.


I noticed there is a RuntimePermissions class. But I only see two enum in there.

Is there a way to make it happen?


I manually added some codes in the java file, similar to the recordAudio ones. And now the app prompts the permission asking.
Maybe juce could add this officially?


Thanks for reporting. This is now on the develop branch. See this commit.

This seems to have broken the default Min SDK Version of 10 - added in 16.

Error:(109, 85) error: cannot find symbol variable READ_EXTERNAL_STORAGE
Error:Execution failed for task ‘:app:compileDebug_DebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.

Hi Fabian,

Just checked the develop branch.

  1. The permissions are added, like you said. Great!

  2. But it has link error on some OpenSL code. I encountered this during a release build variant build. Maybe you can try it on one of your audio example app?


Everything works here. Have you re-built the Projucer and re-saved your project in the Projucer? Can you copy&paste the exact error?

Hi, I’ve added the Projucer flags and can read/write to File::SpecialLocationType::userHomeDirectory ok, but not to File::SpecialLocationType::userDocumentsDirectory.

One the demo app, this is showing as /storage/emulated/0/Documents.

If you are running this on a device with Android M or later you need to use the RuntimePermissions class to get the necessary permissions.

Thx - added those calls and works ok now - maybe needed earlier than Android O though as I’m currently on Nougat

Sorry yes, It’s needed since Android M. I’ve edited my post above.

1 Like