How to open a file from shared storage using the NDK in Android 11

  android, android-ndk

The permissions for accessing shared storage (/storage/emulated/0) are getting really really complicated and changing all the time. As I understand it when targeting Android 11 there is no way to opt out of scoped storage, which means you literally can’t ever do fopen("/storage/emulated/0/foo.dat");. Apparently the preferred way to open a file will be with the ACTION_OPEN_DOCUMENT but this just returns a content:// URI, which I can’t read using the NDK. I’m also unsure if you get to use that URI forever.

How are NDK libraries meant to access files in /storage/emulated/0 on Android 11?

Source: Android Questions

LEAVE A COMMENT