The Death of External Storage

When Q Beta 1 was released, the biggest change for developers in Android 10 — by far — was what Google calls “scoped storage”. In a nutshell, your ability to work with files and the filesystem was substantially curtailed. As a result, you had to adapt your app within a few months, to be ready by the time Android 10 shipped.

Everything will be affected in Android R, but there are steps that you can take to opt out of the changes for Android 10, at least until you are ready. And apps with a targetSdkVersion of 28 or lower will be unaffected… but eventually you are going to need to raise that level, at least if you plan on shipping your app through the Play Store.

Hence, if your app requests the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permissions, you are going to want to start adapting your app to the changes. One of the problems from the Q Beta 1 announcement was the short timeframe that we had for adapting; you do not want to be stuck with a similar short timeframe in 2020.

Introducing the Filter

In Android 1.0 through 9.0, external storage was relatively simple. All apps could access it with permission, and starting with Android 4.4 apps could access parts of it without permission (e.g., getExternalFilesDir() on Context). What the user saw and what all the apps saw were the same.

Scoped storage — when your app has to start working with it — changes this completely.

What Your App Sees

Your app can work with the external and removable storage location roots supplied by Context, just as it did in previous releases. So, getExternalFilesDir(), getExternalCacheDir(), and others work as they have.

Everything else, such as Environment.getExternalStorageDirectory() and Environment.getExternalStoragePublicDirectory(), is inaccessible. You can neither read nor write. In fact, those Environment methods are now deprecated — even though they will still return the correct values, those values are useless, as you cannot use those locations.

A side effect of this is that you cannot see, let alone modify, the files created by other apps on external storage.

What Other Apps See

Other apps are limited in the same way yours is. You cannot see those apps’ files on external storage, and they cannot see yours, when using normal filesystem APIs.

Pre-installed apps from the device manufacturer represent a notable exception. Usually device manufacturers have ways of granting pre-installed apps more rights.

What the User Sees

Technically, there is no impact on the user. External storage can be seen using a desktop OS and a USB cable as before.

From a practical standpoint, the user will see fewer files in traditional locations, like Documents/, as fewer apps can write there.

And the user’s on-device ability to see what is on external storage will be limited by the app that is used.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.