Scoped Storage Android: All you need to know

Vijay Mishra
The Android Cafe
Published in
3 min readAug 26, 2021

To understand scoped storage first let understand how storage on android works in general.

There are two types of storage:-

  1. Internal Storage
  2. External Storage

1 Internal Storage: Every application in android have their own private directory that no other application can access.

2 External Storage: Everything else other than internal storage is considered as External Storage/Shared Storage.

What is Scoped Storage?

Scoped storage was introduced in android 10 but is only mandatory from android 11 onwards. All apps can fully access their own directories and save media files in collections without requiring permission. But if we want to change files that our app doesn’t own we have to create requests to do so (We will look at how we can do this in the next blog).

Also instead of deleting the file, we can put the files in the trash so that the android system can automatically delete the file after 30 days or if required we can restore them.

Why Scoped Storage?

  1. When accessing external storage for writing any file we require WRITE_EXTERNAL_STORAGE permission which would write the in shared storage. Now if the user deletes the application all the files that were written to shared storage remain there taking up space.
  2. Most of the application that requires READ_EXTERNAL_STORAGE permission do only simple things with it such as accessing collections or request files for which they don’t need whole storage but they can.

How these problems are solved?

When using scoped storage the android system knows which application created which files and hence when the application is uninstalled the files are also removed. The below figure is used to illustrate the same.

Scoped storage for apps

What would happen to apps such as file explorer?

For all the applications that still require write and read permission for whole storage. New permission has been introduced MANAGE_EXTERNAL_STORAGE to access everything on a file system But, this permission needs manual review on google play submission so they will check if your application really needs that permission.

This permission can also be enabled or disabled by the user at any time.

That’s all for scoped storage introduction in the next blog we see some examples of how to use internal storage for saving, loading, and deleting files.

Until next time. Follow for more awesome upcoming content on android development. 👋 ☮️

More from me.

--

--