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>/

In order to be able to debug your app, AI2 saves the assets for → Companion on devices with

  • Android ≥ 10 (API ≥ 29):
/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/
  • Android < 10 :
/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/AppInventor/assets/

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 with FileScope=Legacy). 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
/sdcard/ or
file:///storage/emulated/0/  or
file:///sdcard/
file:///mnt/sdcard/

To access the external storage, READ_/WRITE_EXTERNAL_STORAGE permission is required.

2.1. App-specific directory
In addition, there may be an app-specific directory (ASD) which can be created with

Note: The ASD is now usually created automatically or, in the case of old devices (with API < 19, Android 4.4), only when it is needed (i.e. appropriate blocks are used).

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: 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 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
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 .

image

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

EDIT (May 11, 2022):

Storage Permissions on Android 10 & 11
Since AI2 & Kodular 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:

How to access to non-media & media files on Android 11+
How to access non-media & media files on Android 11+


EDIT (Sept 8, 2023): → targetSdkVersion = 33

On August 31, 2023 new apps and updates must target SDK 33 (Android 13):

Starting with Android 13, READ_EXTERNAL_STORAGE is replaced by 3 other permissions, separately for images, audio and video:

  • READ_MEDIA_IMAGES
  • READ_MEDIA_AUDIO
  • READ_MEDIA_VIDEO
So the "old" storage permissions could be then declared like this:
<uses-permission android:maxSdkVersion="32" android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:maxSdkVersion="29" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

On August 31, 2024 new apps and updates must target SDK 34 (Android 14).


On Android 11+, files (except in ASD & PrivateDir) can only be stored in:

1. Non-media files:

- /Documents and/or 
- /Download.

2.1 Media file (video)

- /Movies
- /Documents, 
- /Download - and only with FileScope=Legacy:
- /Pictures, 
- /DCIM (last two don't work with FileScope=Shared -> bug!)

2.2 Media file (image)

- /Pictures, 
- /DCIM, 
- /Documents, 
- /Download.

2.3 Media file (audio)

- /Music, 
- /Documents, 
- /Download.

and of course in subdirectories of these Shared folders.


EDIT, Aug 2025:
Regarding READ_MEDIA_IMAGES and/or READ_MEDIA_VIDEO permissions (on Android 13+) see also here:

Source: https://developer.android.com/distribute/play-policies?hl=en

33 Likes
File location of saved data files
TaifunFile Extension can't read from sd card
Problema salvataggio pdf
File component problem - reading paths with spaces
Content URI is wrong when app restart
[PAID] GDrive: Just a Google Drive(App Data Folder) extension [$8 or INR 551]
How do I save file to phone?
Upload video to google drive
Refresh Gallery
Pro camera: The pro custom camera
Deleting text in a txt file without losing the file (using a Bluestacks emulator)
Permission popup doesn't show up
Error 908: The permission WRITE_EXTERNAL_STORAGE has been denied. Please enable it in the Settings app
Save a sound recorder recording on the user's cell phone
Saving Image to Gallery
Saving Image to Gallery
Share cannot find specified mp3 in device
Crear ruta de descarga a partir de Android 10
Доступ к файлам на андроид 10+ (Download the file to Android 10+)
[FREE] Device 💻 - Get device info!
Store sensor data string to a text file
Help with generating a sheet file from various labels
Download Multiple Files with subfolders
How do I play a big video (> 5 MB) from the ASD or the assets
Download Multiple Files with subfolders
Android 11 and Storage-File
Εrror 2101:Τhe file/filename.txt coult not be found
Append and read csv file
Parsing HTML file from SDCard
Reading Files from Internal Storage
Path to Assets?
how do I change the SDK version to 30?
KML File storage
Release nb187: Copy a text file / image from assets to shared storage (→ Android 10+)
FAQ Section: Files
Taifun Camera Not working after new release
Saving data format
Sound Recorder Error 802 and Error 908 Permissions issue still persists
Files Acces with file component
Reading fields from a csv file
A little bit offtopic: searching files in Android 11 filesystem
Notification "Sorry, File To Resize Does not Exist." Help
File and Directories
Read file from phone memory
How to ask a question (open new topic)
How do you read from a txt file?
3D Model Loader Extension
Guardar archivo
Copy to shared Folder "Download" when using TaifunFile not works
Copy to shared Folder "Download" when using TaifunFile not works
Files and folders
Insert files into the extension using Rush. JavaScript from extension
Android 11 issue related to cordova
Getting a run time error as failure from system when iam trying to share around 10 thousand line of data which is present in the text box or label to my Google drive
Problems with moving an image file to the asd
Use new "scope" properties File
Storing a simple file outside of the application specific directory (ASD)
Not one of standard directories
Cannot generate QR Code
Saving and reading files with android 11
Send data to text file then read with a different App
Export list data into CSV Form
Cloud db error no such file or directory
Search mp3 and play it
File explorer or file manager
Player - Device Audio, Loop - Play Streaming
Java Runtime error (CustomWebView)
Unresolved issue with Android 13+ permissions
[F/OS] ⚠️ DaffyDialog - Additional Features For The Notifier Component!
Screenshot Taifunsceenshot extension
Crear 2 archivo en una sola carpeta / Create 2 file in a single folder
Apk jukebox no go I not understand
Datei Speichern, es wird keine Datei erzeugt
TaifunSqlite1.Export - will not execute
Writing data in a .csv file not working
Canvas Background Image saves ok from Companion but not from APK
Error 802 when recording , how do I fix?
Where does APP Inventor store images
Taifun FTP extension no longer working after Kodular upgrade
Problema con grabador de sonido
How Save a Image to own Storage with TinyDB
Save few Images, upload them file by file and then delete them
Error 2103 guardar archivos
Save file to internal storage
Permiso para descargar cvs
How to access non-media & media files on Android 11+
java.io.FileNotFoundException on fileInputStream
Take a screenshot
SAF: App Inventor implementation of Storage Access Framework
Taifun File Error, Open Failed EPERM (Operaion not permitted)
Smbmanager issue
Getting a run time error as failure from system when iam trying to share around 10 thousand line of data which is present in the text box or label to my Google drive
Dateipfad vom Datei Manager direkt öffnen
Image to CloudDB
App no reconoce carpetas o archivos de mi dispositivo
Drawing app undo & redo button
Error when move canvas image
File non Memorizzato in TinyDB
How do you input image to webviewer?
Deleting text in a txt file without losing the file (using a Bluestacks emulator)
Picture upload causes AI companion to crash
1) Read .csv file from phone, 2) Seach for a keyword 'Apple4321' 3) If keyword found, then look for the nearest word if it is 'send' 4) If the word 'send' is found do some action like 'play music'
File non Memorizzato in TinyDB
I want to save a file in the desired path
Load documents into app
How do you input image to webviewer?
ImagePicker Android 12
Path of file in \file name.txt in device with 10 or higher android version
WebViewer1 access to local files on tablet
SAF: App Inventor implementation of Storage Access Framework
Unable to find data file
Can't search and save csv files? - File component - FileScope (Android11)
Take a screenshot
Taifun camera extension images saving to gallery
Tinydb backup & restore
Take screenshot of screen and save to device
[FREE] Take screenshot of components, arrangement and screen | Extension ComponentToImage
Pick Pdf file on Android12
Rename photo and upload to an ftp account
How to read these jpg file in phone directory as image component
Permission acces filesystem after last App Inventor Update API Level 33
Copy file to ASD with SAF - Error
Write to external storage *confused*
Data file sharing between two applications
Using .csv from Shared Folder(Documents)
File Error 2102
Hi, you have told me to see the topics but the blocks doesn't works
Playing wave files sequentially issue
Trouble Saving .csv Files
Transferred from Google Sheets Test Server to aia server. Save to PDF no longer works
Write to external storage *confused*
Storing,Viewing and Deleting List and then Sorting in Firebase
Read .pdf File from Documents Folder
Salvare in MicroSd
RE: Setting permissions in Extension Manifest File?
TaifunFTP does not find file
File Sharing help - issue with TaifunSharing extension
TaifunFile1 CopyAsync - info
Wie kann ich eine PDF Datei vom lokalen Ordner mit einer externen App öffnen?
Getting permission for storage in internal memory in my app
Getting permission for storage in internal memory in my app
Get the path of → ASD (app-specific dir) & → private data dir (internal storage)
Error code and wont save list
How can I save data from Arduino using Bluetooth directly to a database?
Image Zoom with fingers
Edit csv file strored in the internal storage of the mobile
Reset button results in error with creating a csv file in internal storage
Edit csv file strored in the internal storage of the mobile
Options to read CSV external file into App
I cannot save a file in any directory
Media not existent on Build .apk
Export file as excel, csv, save as csv, no SD card, extension can do that
Help loading a local html file on a WebViewer with WebView.loadUrl()
App with DB offline
How do you send a pdf to the system pdfviewer?
Creating multiple page PDF
:red_square: [FREE] SimpleSqlite - an extension for working with SQLite Databases
Having trouble with my app reading files on my phone
Error 701: unable to load /storage/emulated/0/My Documents/Recordings/app_inventor1690233521187.3gp
Spinner won't list the files in a directory properly
Apk crashes but ai companion works without issue
How do you play a video?
Aparece este error 2101 the file /doc.txt could not be found
:framed_picture: Base64 Tools - five little ones ;)
File component - File.Exists does not work for files in the assets with the APK - bug
Comment effacer des images (How do you delete images?)
Data Security - files only available for my App
DATAFILE - How do you create columns and rows and then save etc.?
Crear o grabar o descargar archivo en carpeta download del movil (regarding record or download file in mobile download folder)
Error 701 when loading file from external storage
Can't search and save csv files? - File component - FileScope (Android11)
java.lang.IllegalArgumentException: URI scheme is not "file"
Where is outside storage?
How do I read int mem?
How do I read int mem?
Create My App Album
How do you copy a text file from root directory to ASD?
Companion and APK: How to access files on Android
Load mp3 Problems
TinyDB. Restore after app reinstall or wipe date
How do I save text in .txt file in internal storage?
How do you read mp3 from sd card in mobile phone and play it?
No se puede compartir archivos, Error 908: The permission WRITE_EXTERNAL_STORAGE has been denied
How do I customize location save (Taifunscreenshot)?
I need a little help on 2 issues
Where are the files stored?
[PAID] Server Socket Pro Extension
Simple file storage, Android phone, help needed
Save CSV data / list as a file
Save CSV data / list as a file
Unable to create a .txt file inside internal storage
Save CSV data / list as a file
Where are the files saved when the application is compiled?
[FREE] ASD Downloader Extension - Download and manage files in ASD
How do you get a list of nonmedia files with component "call file1.ListDirectory.."?
Request/ask permission for Read External Storage denied
Its possible update app without reinstall but replacing the storage files?
Why is the input gambar not entered in the following MySQL database table?
Having problems with ask permission
How can i get internal storage access?
Mp3Tags extension
Error 908 The permission
Browse ( File Picker ) button to import or pick csv & text coordinate file from mobile and draw them on (Bing Maps) map
Browse ( File Picker ) button to import or pick csv & text coordinate file from mobile and draw them on (Bing Maps) map
Cache cleaner app help
MIT App Storage Capacity
Where are canvas files saved to by default when using the block call-Canvas.SaveAs?
SAF / MFile Tests
Help in storing files
I want to save a file in the desired path
How do I find the same files?
Reading directory using saf asd or file component and get image display in canvas
Use (Read, write) non media file
Copying File from Download Folder to ASD
How do you download image?
How do you download image?
New/Modified Apps No Longer Work / Compile
Confirm Existence of Directory?
Runtime Error with Canvas SaveAs -- null object reference
Transfer Listpicker tinydb data to new Phone
Create a folder and move a photo into it
Files no longer readable
Taifun file extension issue
Can't save the image
External permission
Any way to save files to /data/data?
Android and Chromebooks directory
New/Modified Apps No Longer Work / Compile
Qr : Read and Create Qr/Bar Code offline
SAF: App Inventor implementation of Storage Access Framework
MFile - a modified version of Sunny's `EFile` extension - Shared folders - storage permissions - Android 11+
Create a folder and move a photo into it
Trying to adjust an old project
Problem with Saving Photos in MIT App Inventor – File Naming and Numbering
Db backup to SD
Xiaomi14 with Android 15 exact file path to .csv file to be addressed for reading
Open Source • Background Tasks: Itoo 🚀
SimpleSQLite1, File1, Filescope and ASD...Retrieving the data from the table
View Files On The app
Asset path when using Companion vs. after building the app (Extension development)
I cant select the url from the list to load my webviewer this is my blocks
Reading and editing files on a removable SD card, Android 8
Pick an image, view it, copy it and get full access to it without SAF and/or storage permissions on Android 11+
Download folder path android11
Action Required: Your app is not compliant with Google Play Policies
[Free]DjFilePicker extension
Off topic discussion about storage permissions
Off topic discussion about storage permissions
Off topic discussion about storage permissions
Media player - weird behaviour
Lectura de pdf extension pura vida
Android 10 vs. 15
Image Picker failure to find image
Error message using extension HttpClient.PostForm
Help test nb202
Salvataggio lettura e visualizzazione file su memoria interna android Save, read, and display files on Android internal memory
[Free] Image Convertor: extension to convert image format jpg / png / webp (and much much more)
How do you create a new file using file picker and write to it?
Test php no result
Test php no result
Test php no result
I need help with file uploading to the app
How when and where text files are stored
Proyecto con TinyDB no carga el aplicativo .apk en el celular ni tablet
Downloaded image not displaying [SOLVED]
No se guardan mis archivos de texto en mi carpeta
How do I delete a file?
[Free] JewelFilePicker Extension : Pick Any Type Of File From Storage
Looking for assistance in understanding File Blocks usage
Soundrecording help
Problem with VIDEO permission, with and without VideoPlayer
Csv files in apk package
How do you read an "alien" file from Download under SDK 30?
I want to open a pdf file in app inventor
Domanda circa salvaggio file
Create My App Album
I want to add image in my application and later i want to share. i have uploaded image but while using apk fie it is showing file could not be found
Asking permission until it's granted - currently only asks twice
Writing text line to GETASD1 folder
Off topic discussion about storage permissions
Pro camera: The pro custom camera
Sharing a tinydb between apps
Error 2101 with the .APK
How do I create a folder in the internal memory, and inside it put 2 pdfs?
Is there a default exit from the SAF OpenSingleFile method if no file available in directory
[PAID] SFTPClient: An extension to use SSHv2 [$6 or INR 350]
I'm having problems with the file system/file structure on Android/AI2
I want to open a pdf file in app inventor
Open File Error 2102
My MP3 Player (MP3 Player)
Create My App Album
How do you read a text file(like .txt) in sdcard?
Question about Files, Scopes and Android Levels (US and EU)

Thank you @Anke your tutorial really helped me :star_struck: :+1:

4 Likes

Despite the limitations of android 11, is it still possible to write to any directory after obtaining write and read permissions?

No, when AI2 targets API 30 (targetSdkVersion = 30) it is no longer possible.

I understand that ASD does not require permissions. However, the permissions for writing and reading in Android will remain. If android completely blocks reading and writing to any folder, what then will these permissions be for?

Another question. Will the ASD directory be accessed only from the application? What about file managers, they won't be able to read files created by my application?

See here:

Summary

Yes.

Maybe, but try to open the ASD on your (Android 11) device:
No files available.
I can see them connecting the device via USB to my PC.

So how will cameras, scanner handlers, create pdf, word, excel and much more work? File manager programs will also cease to exist? In my opinion, it is too much of a blockage. I like systems with freedom like on a PC and not limited to the maximum.

2 Likes

not any, but some...

everything is explained in the link, @Anke already provided

in short: it will be more complicated...

I agree...

Taifun

2 Likes

So I don't think we can say "you can't" You can, but it's more complicated. But I think our Java programmers who make extensions will be able to handle it :wink: . It was a shame when google bought an android. Now they tell people how to use the phone, they will soon be telling how to live ... although they already know too much about our lives ...

5 Likes

exactly... we will try to help to provide a solution as easy as possible... :muscle:
Taifun

2 Likes

Yes, read some comments here, then you know what users think of it.

3 Likes

That won't be a Windows or Apple Computer then :wink:

4 Likes

Me2.

Yes, but the wind is changing right now (also for Windows, Apple & Co) and wonderful times of freedom are coming (without lies, electoral fraud, oppression, C-restrictions, opinion terrorism, ...) - I've been very confident for a long time ... (many will be very surprised).

It all depends on the US election and this has already been decided.
Does anyone want to bet for whom?

1 Like

Very Helpful! Thank you!
But shame on Google for scoped storage...

2 Likes

I think Windows is less restrictive when it comes to file systems and accessing them, installing applications, etc.
Google is moving towards controlling its users and wants to be present even where it is not needed. Well, but you know - money and masking for the "good of users".

1 Like

By the way, does anybody know when will AI2 target API 30? Is there any announcement about this?

Yes, AI2 has to target API 30 before August 2021, because targetSdkVersion=30 is required for

  • new apps from → August 2021 and
  • updates from → November 2021

You must also publish apps with the (new) Android App Bundle ( AAB ) format.

Thank you, but i'm curious about the AI2 team plan to implement it, not the deadline, but never mind, i'm starting to prepare my apps for this change.
One more question.

The ASD can only be accessed by your app and is automatically removed when the app is uninstalled.

What about reinstall without uninstall? Logically it is stays in case of app update, but i ask to be sure.