|
|
|
|
|
- Overview
- The different storage types
- Internal storage
- External storage
- External storage management according to Android version: limitations
- WLanguage functions available for managing the different storage areas
The file system on the devices running Android is divided into two main storage areas: - an "internal" area.
- an "external" or "shared" area.
The different storage types Internal storage 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. It is generally called "/data/data/<Full package name of the application>. For example: /data/data/fr.pcsoft.MyApplication. The files contained in this directory are not accessible by other applications. When uninstalling the application, the files created in this directory and in its sub-directories are automatically deleted by the system. External storage 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. It is possible to find several external storage areas on the same device: for example, one corresponds to the "external" partition of the permanent memory and the other 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. - The name of this directory is generally in the form: <external storage root>/Android/data/<Full package name of the application>. For example: /mnt/sdcard/Android/data/en.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.
External storage management according to Android version: limitations Starting with Android 4.4 (KitKat)on external storage space corresponding to removable memory (SDCard), applications can only create, modify or delete files in their own directory. 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. Permissions: - 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 constants (with SysDirExternalStorage, for example) to avoid errors. Note: Applications running Android 10 and generated with WINDEV Mobile will run as usual (if you use patch 118661 or WINDEV Mobile 25 Update 4). 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:
- public directories such as "Documents", "Download", "Images", etc.: use SysDirExternalStorage with ssePublicXXX constants.
- application-specific directories: use the SysDirExternalStorage function with sseAppXXX constants.
- in public directories, an application can only access (in read or write mode) the files that it has created.
Note: if the application is uninstalled and then reinstalled, it will no longer have access to files created by the previous installation in public directories on external storage.
For more details, see Android 11: Changes in the behavior of applications.
New in version 2025From Android 13to access shared audio, video and image media files (i.e. those not belonging to the application), the following permissions are required: - READ_MEDIA_VIDEO
- READ_MEDIA_IMAGES
- READ_MEDIA_AUDIO
These permissions are automatically added when the following functions are present in the code of your Android application: | | AlbumPicker | Permissions required: - READ_MEDIA_VIDEO
- READ_MEDIA_IMAGES
| AlbumSave | Permissions required: - READ_MEDIA_VIDEO
- READ_MEDIA_IMAGES
| PhotoRunApp | Permissions required: - READ_MEDIA_VIDEO
- READ_MEDIA_IMAGES
| sysCacheExternalStorage | Permissions required: - READ_MEDIA_VIDEO
- READ_MEDIA_IMAGES
- READ_MEDIA_AUDIO
| SysDirStorageCard | Permissions required: - READ_MEDIA_VIDEO
- READ_MEDIA_IMAGES
- READ_MEDIA_AUDIO
| sysRepExternalStorage | Permissions required: - READ_MEDIA_VIDEO
- READ_MEDIA_IMAGES
- READ_MEDIA_AUDIO
| VideoStartApp | Permissions required: - READ_MEDIA_VIDEO
- READ_MEDIA_IMAGES
|
When the application is published on the Google store with these permissions, it is necessary to justify their use in the Google Play console to have the right to publish. From version 2025 Update 1If these permissions are required in your application, a pictogram is displayed in the permissions step of the application generation wizard. This pictogram indicates that justifications will be required for publication on the store.
You can remove these permissions from the generation wizard ("Remove" button), so that they are no longer requested at runtime when one of the above functions is used, and there is no longer any warning on the store. If these permissions are not present, the application will only be able to access media files not belonging to it on external storage via the URISelect function. WLanguage functions available for managing the different storage areas Several WLanguage functions can be used to manage and identify the different storage spaces: | | fCacheDir | Returns the path of directory that will be used to store the data in cache on the internal storage space of application. | fCurrentDir | Returns the path of the directory that will be used to store the private files of the application in the internal storage area. Example: /data/data/en.pcsoft.MyApplication/files | fDataDir | Returns the path of the directory that will be used to store the database files of the application in the internal storage area. Example: /data/data/en.pcsoft.MyApplication/database | fExeDir | Returns the root path of the application directory in the internal storage area. Example: /data/data/en.pcsoft.MyApplication | SysCacheExternalStorage | Returns the path of directory that will be used to store the data in cache on the external storage space of application. | SysDirExternalStorage | Returns the path of the directory that will be used to store files in the external storage space of the Android device. | SysDirStorageCard | Returns the path of the root directory of the primary external storage space. Example: /mnt/sdcard | SysMemoryExternalStorage | Returns the amount of available memory on the external storage area of the device. | SysNbExternalStorage | Returns the number of external storage spaces found on an Android device. | SysRemovableExternalStorage | Used to find out whether the external storage space corresponds to the movable memory (SD Card). | SysSpace | Returns the free space or the total space of the primary external storage space. | SysStatusExternalStorage | Returns the availability status of the external storage space of the device. | SysStatusStorageCard | Returns the availability status of the primary external storage area: available/read-only/unavailable. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|