The Death of External Storage: The Beta 3 Status

UPDATE 2019-06-08: With Q Beta 4 out, the story changed yet again. I am leaving the original post here for historical reasons.


Last week brought us the Q Beta 3 release and Google I|O, and the changes that Google promised have largely come to pass. The Q Beta 3 documentation for scoped storage is a substantial improvement, and the Google I|O presentation on it was very welcome.

By default, apps with a targetSdkVersion of 29 Q will have “sandboxed” external storage: an independent location from the external storage from any other app. When sandboxed, your app has no ability to work with sandboxes of other apps via the filesystem, and your app has no ability to work with the “real” external storage that the user sees (again, via the filesystem). Instead, you are steered to the Storage Access Framework and possibly MediaStore for working with common content. Users can get to an app’s sandbox via Android/sandbox/, though it is unclear how many users will discover this. And the contents of the sandbox are removed when the app is uninstalled, just as with internal storage.

However:

  • Apps with a targetSdkVersion of 28 or lower will have normal external storage access by default

  • Apps can add android:allowExternalStorageSandbox="false" to the <application> element to opt out of the sandbox, ideally only while the app’s developers are making changes to deal with the sandbox (note: this attribute name might change in Q Beta 4)

This gives developers a more reasonable timeframe for adjusting to these changes. While Android R is likely to force the sandbox — at least on apps with newer targetSdkVersion values — that means we have closer to 15 months to make changes, not just 3.

As a community, we will need to work out the details for how to adapt everything. For example, there is confusion over updating the MediaStore for metadata changes. But now we have the time to do that.

This does not give you the luxury of sleeping on this work, though:

  • Apply android:allowExternalStorageSandbox="false" ASAP, lest your app ship to Android Q users before you have the time to test the sandbox behavior

  • Once Android Q ships — or using the Q Beta releases if you wish — budget the time to play with your app with android:allowExternalStorageSandbox="true" (opting into the sandbox) to see what all breaks and needs to get rebuilt

However, I am very grateful that Google elected to slow down this change and give us a clearer implementation for the near term.