Read and Write Android external storage


#1

Hi,

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.

android.permission.READ_EXTERNAL_STORAGE
android.permission.WRITE_EXTERNAL_STORAGE

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

Is there a way to make it happen?

Thanks.


Android studio won't let me build on SDK version lower than 25
#2

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.


#3

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


#4

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

/Users/lee/Development/cpp/JUCE/Projects/MIDISynth-Circuit/Builds/Android/app/src/main/java/com/sigabort/midisynthcircuit/MIDISynthCircuit.java
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.


#5

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?

Thanks.


#6

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


#7

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.


#8

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.


#9

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


#10

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