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

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.

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
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);
              }
            );
        }
      );

External storages are no longer accessible starting on Android 10, unless you request a permission for total filesystem access, 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.

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

The correct answer is

this.file.externalRootDirectory + '/Documents/'

This will save the file directly in the Documents Folder