Some basics on Android storage system

From an Android point of view there are an → Internal Storage and an → External Storage.

1. Internal Storage
In the Internal Storage, the app package is saved:

/data/data/<packageName>/

which can only be accessed with a rooted device.

2. External Storage
The root directory of the External Storage is:

/storage/emulated/0/  or
file:///mnt/sdcard/ or
file:///storage/emulated/0/ 

To access the external storage, READ_ or WRITE_EXTERNAL_STORAGE permission is needed.

2.1. App-specific directory
In addition, there may be an app-specific directory (which can be created with Taifun’s File extension App Inventor Extensions: File | Pura Vida Apps or the FileTools extension FileTools : Some tools to work with files).

 /storage/emulated/0/Android/data/<packageName>/files/

which is saved in the External (private) Storage, but does not require READ_ / WRITE_EXTERNAL_STORAGE permissions.
This app-specific (private) folder can only be accessed by your app and is automatically removed when the app is uninstalled.

See: https://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE

2.2. External (removable / micro) SD card
There may also be another External Storage: a removable (micro) SD card, eg:

/storage/82C3-E96C/

that can only be read (on modern Android versions, since Android 4.4 / KitKat).

Note:
The root directory of the External Storage

/storage/emulated/0/

is displayed on the device as Internal Storage (unfortunately this is a bit ambiguous).

When targeting Android ≥ 10
https://developer.android.com/training/data-storage
Scoped storage
To give users more control over their files and to limit file clutter, apps that target Android 10 (API level 29) and higher are given scoped access into external storage, or scoped storage, by default. Such apps have access only to the app-specific directory on external storage , as well as specific types of media that the app has created.

https://developer.android.com/training/data-storage/use-cases

18 Likes

What is this internal storage?

And this?

I am confused
I need to learn from you.

For more details see here:

It is only accessible to apps and you can’t view it unless you root your device.

Except internal storage other storage(either phone storage or sdCard) spaces fall in this category.
There are two types of it:

  • Primary External Storage :- It is the phone storage.
  • Secondary External Storage :- It is the sdCard.
2 Likes

And what about the otg…

OTG also come in Secondary External Storage category but is managed by USB Manager.

1 Like

If supose we direct the app to download a file ,so by default it gets stored in the phone storage.[ By using this directory file:///storage/emulated/0/ …]
But if the phone storage is full will the app automatically detect and change its directory to External SD Card or we have to manually write the blocks for that ??

1 Like

See here:

1 Like

Oh I see,
So we have to do it manually ?

1 Like

Yes, before you can access the removable SD card, you first have to get the path.

1 Like

ok thx! ! !