The internal storage area is found in the non-volatile and non-removable memory of the device (called permanent memory). This internal storage area mainly contains the system files of the OS.
The applications are installed in this storage area by default. Some applications can be installed on the external storage area with some restrictions.
The internal storage area is always available for an application even if the device is connected by USB to a computer for example.
An application can create, modify or delete files in its own directory only (found in the internal storage area). This directory is automatically created when installing the application. In most cases, it is named "/data/data/<Name of full application package>. For example: /data/data/fr.pcsoft.MyApplication. The files found in this directory cannot be accessed by the other applications.
When uninstalling the application, the files created in this directory and in its sub-directories are automatically deleted by the system.
The external storage area can be found:
- in the permanent memory of the device,
- and/or in the movable memory (SD Card storage card).
Some devices divide their permanent memory into two partitions, the first one dedicated to the internal storage and the other one to the external storage. Therefore, even the devices without location for a SDCard include two distinct storage areas.
Several external storage areas can be found on the same device: for example, the first one corresponds to the "external" partition of the permanent memory while the other one corresponds to the SDCard. In this case, we talk of primary external storage area, secondary external storage area, etc. The choice for assigning the primary storage area to such or such location depends on the manufacturer.
The external storage area may not be accessible for an application at a given time. This is the case for example when the application is connected to the computer in USB mass storage mode.
An application can access in read mode AND in write mode to all the files and directories found on the external storage area(s) of the device.
Each application can have its own directory in each one of the external storage areas of the device.
- In most cases, the name of this directory has the following format : <root external storage>/Android/data/<Name of full application package>. For example: /mnt/sdcard/Android/data/fr.pcsoft.MyApplication.
- This directory must contain the private application files that do not have to be shared with other applications (even though any application can access them).
- This directory can contain sub-directories with preset system names for storing different types of files (music, film, documents, download, etc.). A proper use of these preset directories allows for a better support of these files by the system.
- The files found in the application directory are not automatically scanned by the system (even though this can be explicitly asked). For example, the photos saved in this directory will not be listed in the photo albums of the device.
- This directory as well as the data found in it will be automatically deleted when uninstalling the application.
Remark: From Android 4.4 (KitKat), on the external storage space corresponding to movable memory (SDCard), the applications can create, modify or delete files in their own directory only. The other files of the external storage space are accessible in read-only.
If an application owns public files that must be shared with other applications, we advise you to store them outside its own directory. In this case, the files will not be deleted when uninstalling the application.
The primary storage space of the device can contain directories with preset system names for storing different types of public files (music, film, documents, download, etc.). A proper use of these preset directories allows for a better support of the files by the system. In particular, these directories are regularly scanned by the system in order to be listed and proposed when selecting media for example.
- The READ_EXTERNAL_STORAGE permission is required to access the files found in the external storage space in read mode. This permission is automatic on the devices running an Android version earlier than version 4.4.
- The WRITE_EXTERNAL_STORAGE permission is required to access the files found in the external storage space in write mode (creation, modification, deletion). This permission implicitly grants the read rights.
From Android 4.4 (KitKat), these permissions are not longer required to access the files found in the application directory.
From Android 10
, applications must access files located in their own directories only. Any attempt to access files outside of these directories (in read or write mode) may fail. It is recommended not to use ssePublicxxx
, for example) to avoid errors. Remark: Applications running on Android 10 and generated with WINDEV Mobile will run as usual (if you use patch 118661 or 250Update 4 of WINDEV Mobile).
When the application is used on a device that runs Android 11
, new restrictions appear:
- applications can no longer read or write files to the external storage outside of:
- in public directories, an application can only access (in read or write mode) the files that it has created.
Remark: if the application is uninstalled and then reinstalled, it will no longer have access to files created by the version previously installed in the public directories of the external storage.
For more details, see Android 11: Changes in the behavior of applications