Some basics on Android storage system

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

1. Internal Storage
The Internal Storage can only be accessed with a rooted device.

1.1 The app package is saved in

/data/data/<packageName>/

1.2. The Private directory is

/data/user/0/<packageName>/files/

This private directory can be used with the File component to save / read text (setting the path without a slash). It can only be accessed by your app and is automatically removed when the app is uninstalled.

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 (ASD) which can be created with

Note: The ASD seems always automatically be created by Kodular (not with AI2).
The path of the ASD is:

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

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

See: Manifest.permission  |  Android Developers

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 devices with Android ≥ 4.4 / KitKat, API 19).

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

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.

See also here (when Kodular has to target → Android 11, → Aug 2021):

Conclusion: Remember in good time to adjust your file paths accordingly.

I would like to introduce these three basic terms:

Absolute path │ relative path │ full path

1. This path is an → absolute path:
/storage/emulated/0/Android/data/packageName/files/

2. This path is a → relative path:
/Android/data/packageName/files

Some components need a relative and others an absolute path.

3. And on top of that, some components or Android versions require a → full path:
file:///storage/emulated/0/Android/data/packageName/files/

I recommend these terms to distinguish the paths, for example:

  • relative path: /Download
  • absolute path: /storage/emulated/0/Download
  • full path: file:///storage/emulated/0/Download

Storage Permissions on Android 10 & 11 - EDIT (May 11, 2022)
Since Kodular & AI2 decided to declare requestLegacyExternalStorage=true in the Manifest (which is only ignored on Android 11+), storage permissions must also be requested on Android 10.

If you remove this from the Manifest, which I would recommend, no permission for the Shared folders would be required on Android 10 either. The storage permissions would then have to be declared as follows:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />

I generally prefer to request as few permissions as possible.
I don’t like permissions and my users even less.
:wink:

53 Likes
Writing in internal phone storage
How to access the assets?
Internal storage path is same in every android version
Kodular and memory card
Can a user access app's private directory?
Extension to download file(s) to ASD (app-specific directory) without WRITE permission
EFile : Only asks for permissions when required
Android 11 - Activity Starter issue
How do I show a picture in the internal storage in the app?
File component problem
How to check if an image exists in device storage by path
Help how to read csv
I want to get mp3 file from device
Internal and external storage blocks error (again)
Application Crashes due to java.lang.SecurityException:
How can pick or open pdf file in kodular
Any pdf to text extension or method?
Iam unable to share content uri file from share component
Kindly read and answer before delisting
How to share image please help me throw error
Problem with picking audio file
Extension to download file(s) to ASD (app-specific directory) without WRITE permission
Canvas background image not loading
Is 'canvas save' working now?
Is the file component working in Android 11?
Set image from storage not working , need help
[Free] Fetch - A powerful and simple download tool
Can't list all files in shared folder
Screenshot of surface view with a component on it
Component file generates the file in Package Name
Error 2103: file could not be created
Create a folder in assets
View image from device
Save and write to text or csv file
Files from assets to internal storage
How to access a file located outside the specific directory of the application?
Sharing component error on samsung a71 but on realme c17 work perfect
How To Downloads Files In Android 11 With Custom Folder?
Private Directory Storage Access
[FREE] ScanView -ZxingView Version 2- Extension
Web Post File doesn't work and doesn't send file
Web Post File doesn't work and doesn't send file
Save canvas on specific folder
Extract image from url of audio file
How to simply loading an image from file to static image component
Download Progress Stays at 0% (Not downloading)
How to make a list of Videos Files
[Free] Advance PDF Creator : Encrypt / Decrypt PDF , ImageToPDF , WebViewToPDF , Print PDF etc
Unable to Download Files in Android 11 (Stays at 0%)
Create a new folder in the directory
How to read a pdf file from ASD with Activity Starter?
How to mount images in layers?
How to read a pdf file from ASD with Activity Starter?
How do you solve the FireStorage User does not have permission to access this object error?
Export CSV File
Read CSV file in shared Documents foder
How to blur an image
Save veriable list to storage in csv formate
Pro camera: The pro custom camera‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌
How to save image after taking from camera component
Upload then read data
Extension to download file(s) to ASD (app-specific directory) without WRITE permission
Error saving a dictionary
File generate in companion but not in reak apk
File generate in companion but not in reak apk
Csv file cteate error
Create PDF file Extension. Layout to PDF
How to request and grant MANAGE_EXTERNAL_STORAGE permission
Code doesn't work... trying to read a text file
Code doesn't work... trying to read a text file
Error 908: permission not granted
How read csv file from internal storage
Error 908: permission not granted
Error 908: permission not granted
Access non-media and media files on Android 11+
Building File Permissions Extension
Store pdf file into tinydb
[FREE] Capture widget images
[FREE] Capture widget images
Image management (local load, rotate, local save)
Can't pick an excel file, then create a list from its components
After SDK33: required storage permissions on Android 13+ (READ_MEDIA_...) missing
FileTools : Some tools to work with files
Image management (local load, rotate, local save)
Show image into the second screen
Pick File Directory Android 11
Pdf Download Issue
How can i share image using activity
[FREE]DjGPXTool extension
Create new folder, upload file into it, and display in app
[FREE]DjGPXTool extension
Saving photos on your cell phone
Permission to write external storage denial
File saved by previous installation not recognized
Problem with Write_external_storage >10
Help with old app made with appy builder
How to delete a file in the internal storage
How to delete a file in the internal storage
How to get file path on android 11+
Taifun File - 'Delete' not working
[Free] Device Manager
FileTools : Some tools to work with files
Help me to find out the video path/folder
Android 14 problem
[FREE]DjGPXTool extension
FileTools : Some tools to work with files
permissions denied with android 14.
FileTools : Some tools to work with files
Is File required `ReadExternalStorage` and `WriteExternalStorage`?
Screenshot problem
Asking for help with ASD storage deleting issue
I can't read a .txt file that is on the device's internal storage
Permission issue
CustomWebView Extension Local files Problem ACCESS_DENIED on Companion
I am having difficulty saving a CSV list using the file function
Error 908 Permission Write_External_Storage has been Declared
Problem save file
FileTools : Some tools to work with files
Writing to external SD card
Writing in internal phone storage
ASD still asks for read/write permission
Can't save image from crop view extension
Is WRITE permission needed to edit a file in the ASD?
Can't resize image from sd card
How to save component image in external storage of device?
A problem in the file name with path
How to delete permanently file
EACCES (Permission denied)
When update API 30
How to add custom ttf file from sd card
Extension to download file(s) to ASD (app-specific directory) without WRITE permission
What name of assets folder
Sharing an Image from my phone
How to access the assets?
Open custom folder in file manager using kodular
File component could not error
Extension to download file(s) to ASD (app-specific directory) without WRITE permission
Download to "ApplicationSpecificDirectory"

What is this internal storage?

And this?

I am confused
I need to learn from you.

For more details see here:

1 Like

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.
4 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! ! !

Note: I just updated this guide.

3 Likes

I couldn’t do it myself :upside_down_face:, but @Peter made this topic a → Wiki.

2 Likes

How can I download files to this directory.

15 posts were split to a new topic: How to secure download files?

As far as I know, that is not possible. Only the File component can write in this dir.

1 Like

Maybe he can download files in asd and copy them to private dir.

Thanks all for good support, I am happy with App-Specific Directory.
I used this extension, https://community.kodular.io/t/extension-to-download-file-s-to-asd-app-specific-directory-without-write-permission/96891/
Thank you so much for this extension also.

2 Likes

I’ve added a full overview of the Android storage system - Scoped / Shared Storage (targetSdk=30, Aug 2021) - at the end of my guide.

6 Likes

Please, can anyone add in a guide some examples of code to save and read the files In mobiles with sdk 29 and 30 in a conditional way?

1 Like