Ionic: Save file to externalDataDirectory

Hi all ! Could anyone suggest please definitely … is it possible to save file on Android to externalDataDirectory ?

For pass I am using …

import {File} from ‘@ionic-native/file’;

this.file.externalDataDirectory, but file always save to this.file.dataDirectory. I have

memory cards in my android.

1 Like

From Android 5.0 onwards, the location of the external (removable) SD is no longer a fixed path. Instead, the serial number of the SD card is used in the path. For example, on my Samsung Galaxy S4 which is running Android 7.1.1, the physical external removable SD card path is /storage/4975-1401/.

In addition, the root of the external SD card (e.g. /storage/4975-1401/) is now read-only to Android apps. This means if your app needs to write to the SD card, it must do so in the application sandbox directory (e.g. /storage/4975-1401/Android/data/your.app.package.id/files).

cordova-plugin-file does not enable you to access the external (removable) SD card: for example cordova.file.externalRootDirectory returns file:///storage/emulated/0/.

it help.

1 Like

Please, follow this stackOverflow answer to retrieve the SD Card native path

Look the documentation: https://github.com/apache/cordova-plugin-file