Understanding Scoped Storage in Android: Protecting User Privacy and Device Security

Blair Fernandes
2 min readApr 2, 2023

--

Shipping container trucks in a parking lot
Photo by Marcin Jozwiak on Unsplash

Android is a popular operating system that allows users to store and access various types of files on their devices. However, not all apps need or should have access to all files on external storage. To protect user privacy and device security, Android introduced a new storage model called scoped storage.

Scoped storage limits the access of apps to specific directories and media types on external storage. Apps can only read and write their own files in their app-specific directory, and need permissions to access other apps’ media files. Apps can also use the MediaStore API to access common media types, such as photos, videos, and audio.

Scoped storage was introduced in Android 10, but apps could opt out of it by setting the requestLegacyExternalStorage flag in their manifest file. However, starting from Android 11, scoped storage is enforced for all apps that target API level 30 or higher. Apps that target lower API levels can still use scoped storage by enabling some app compatibility flags.

Scoped storage also supports Filesystem in Userspace (FUSE), which allows apps to access files using direct file paths instead of using the MediaProvider API. FUSE intercepts file operations in user space and applies scoped storage rules based on the policy to allow, deny, or redact access.

Scoped storage offers many benefits for users and developers. It improves user control and privacy by preventing apps from accessing sensitive or personal files without explicit consent. It also reduces file clutter and frees up device space by deleting app-specific files when the app is uninstalled. For developers, scoped storage simplifies file management and reduces compatibility issues across different devices and platforms.

To learn more about scoped storage and how to migrate your app to use it, you can refer to the official documentation and guides from Android Developers. If you have any questions or feedback, please leave a comment.

--

--

Blair Fernandes
Blair Fernandes

Written by Blair Fernandes

I am a passionate programmer 💻, geek 🤓 & an avid gamer🎮

No responses yet