MobDojoStart learning free

Android App Security · Storing Data Safely · Lesson 1 of 5

App Storage vs Shared Storage

See where an app's files live, who else can read them, and what survives an uninstall.

12 min60 XPFree lab

Where an app keeps a file

You saw in Mobile Fundamentals that every Android app lives in a sandbox with its own private folder. Real apps have a few more places to put files, and that choice decides who else can read them.

App-specific internal storage is the private folder. For QuickNotes it sits under /data/data/com.example.quicknotes/, with a files/ folder for things the app keeps and a cache/ folder for temporary data. Google's developer guide says other apps can't access these files, and on Android 10 and higher this storage is encrypted. It needs no permission, and it's the right home for sensitive data.

App-specific external storage is a second private folder, kept under Android/data/ in the phone's shared storage area. Despite the word "external", on most phones it's on the same built-in storage chip, not a memory card. Since Android 11, other apps can't open it. On older versions, an app with storage permission could sometimes read it, so Google recommends internal storage for anything sensitive.

Shared storage is for files meant to be shared or to outlive the app. Photos, videos and music are tracked by a system index called MediaStore. Documents and downloads live in folders like Download, at /storage/emulated/0/Download/. Other apps can get at shared files, but only through the doors the system provides. You'll see those doors in the next task.

On the simulated phone, save passwords.txt to each location and let Gallery Cleaner try to read it, with All files access turned off. Then try uninstalling QuickNotes and see which copy is left.

Scoped storage and the all-files exception

Before Android 10, an app with the storage permission could read almost everything in shared storage, including other apps' files under Android/data/. Android 10 introduced scoped storage. Apps that target Android 10 or newer get their own app-specific folders and the media files they created, and not much else by default. With Android 11, apps that target it could no longer opt out, and the old write-storage permission stopped granting them any extra access.

Under scoped storage, reaching files the app didn't create goes through a door the system controls:

The exception is All files access, a special permission (named MANAGE_EXTERNAL_STORAGE) added in Android 11. You turn it on per app in Settings, with a switch like "Allow access to manage all files". It lets an app read and write nearly all of shared storage. Even then, it can't open other apps' private folders, internal or under Android/data/. Google Play allows it only when it's tied to an app's core purpose, such as file managers, backup apps and antivirus apps. A photo cleaner asking for it deserves a hard look.

Uninstalling is the other big difference. App-specific files, internal and external, are deleted along with the app. Files in shared storage stay behind, so a password list saved to Downloads outlives the app that made it.

Test yourself

Can you answer these?

  1. With All files access off, when can Gallery Cleaner read the copy of passwords.txt saved in Downloads?
  2. You give Gallery Cleaner All files access. Which copies of passwords.txt can it now read on its own?

Answer them in the app to earn 60 XP.

Answer in the app