# Android, cordova-file-plugin, success save message but the file not exists

**URL:** <https://forum.ionicframework.com/t/android-cordova-file-plugin-success-save-message-but-the-file-not-exists/228459>\
**Category:** Ionic Framework\
**Created:** [November 9, 2022, 9:28pm UTC](https://forum.ionicframework.com/t/android-cordova-file-plugin-success-save-message-but-the-file-not-exists/228459 "2022-11-09T21:28:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aboelhaithem](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@aboelhaithem](https://forum.ionicframework.com/u/aboelhaithem)\
**Post date:** [November 9, 2022, 9:28pm UTC](https://forum.ionicframework.com/t/android-cordova-file-plugin-success-save-message-but-the-file-not-exists/228459/1 "2022-11-09T21:28:46Z")

</div>

I’m using the codova-file-plugin to save a CSV file to the storage. The saving process works well on android version 9, but on newer versions like 11 and 12, I receive the successful save message but don’t find the file in the storage.

```auto
Ionic:

   Ionic CLI : 6.17.0 (C:\Users\elhaithem\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework : @ionic/angular 5.7.0
   @angular-devkit/build-angular : 12.1.4
   @angular-devkit/schematics : 12.1.4
   @angular/cli : 12.1.4
   @ionic/angular-toolkit : 4.0.0

Capacitor:

   Capacitor CLI : 3.2.2
   @capacitor/android : 3.5.1
   @capacitor/core : 3.2.2
   @capacitor/ios : not installed

Utility:

   cordova-res : 0.15.3
   native-run : 1.4.1

System:

   NodeJS : v14.17.3 (C:\Program Files\nodejs\node.exe)
   npm : 6.14.13
   OS : Windows 10

```

```auto
this.file.writeFile(this.file.externalDataDirectory, fileName, csv)
      .then(
        res => {
          const msg = 'Die CSV-Datei wurde erfolgreich exportiert und ist unter "Eigene Dateien" ' +
            'auf Ihrem Gerät verfügbar.';
          this.toastsService.showSuccessMessage(msg);
        }
      )
      .catch(
        err => {

          this.file.writeExistingFile(this.file.dataDirectory, fileName, csv)
            .then(
              _ => {
                const msg = 'Die CSV-Datei wurde erfolgreich exportiert und ist unter "Eigene Dateien" ' +
                  'auf Ihrem Gerät verfügbar.';
                this.toastsService.showSuccessMessage(msg);
              }
            )
            .catch(
              error => {
                let msg;
                if (error.code == 5) {
                  msg = 'Eine Datei mit diesem Namen kann nicht gespeichert werden. ' +
                    'Bitte versuchen Sie es erneut, nachdem Sie den aktuellen Bestellnamen bearbeitet haben.';
                } else {
                  msg = '[' + error.code + '] Der Export der CSV-Datei ist fehlgeschlagen! Bitte versuchen Sie es erneut.';
                }
                this.toastsService.showFailureMessage(msg);
              }
            );
        }
      );

```

---

<div class="post-metadata">

**Author:** ![julio-ionic](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@julio-ionic](https://forum.ionicframework.com/u/julio-ionic)\
**Post date:** [November 10, 2022, 9:35am UTC](https://forum.ionicframework.com/t/android-cordova-file-plugin-success-save-message-but-the-file-not-exists/228459/2 "2022-11-10T09:35:45Z")

</div>

External storages are no longer accessible starting on Android 10, unless you request a permission for [total filesystem access](https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE), which is dangerous and google might not approve your app if you use it unless you give a good explanation about why you need it.

So it’s probably a bug on the plugin, it should error instead of succeed.

---

<div class="post-metadata">

**Author:** ![aboelhaithem](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@aboelhaithem](https://forum.ionicframework.com/u/aboelhaithem)\
**Post date:** [November 10, 2022, 10:49am UTC](https://forum.ionicframework.com/t/android-cordova-file-plugin-success-save-message-but-the-file-not-exists/228459/3 "2022-11-10T10:49:04Z")

</div>

@julio-ionic Thank you for the explanation. I already noticed that and used an external file manager to access the app folder, and I already found the saved files.  
The question now is how can I save the file in an accessible folder.

---

<div class="post-metadata">

**Author:** ![aboelhaithem](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@aboelhaithem](https://forum.ionicframework.com/u/aboelhaithem)\
**Post date:** [November 10, 2022, 2:47pm UTC](https://forum.ionicframework.com/t/android-cordova-file-plugin-success-save-message-but-the-file-not-exists/228459/4 "2022-11-10T14:47:27Z")

</div>

The correct answer is

```auto
this.file.externalRootDirectory + '/Documents/'

```

This will save the file directly in the Documents Folder
