Ionic Native - File - listDir in Android always shows assigned root

I am building a simple file explorer that shows folders, files, and It allows navigation between directories.

I am using “Native File” to do that work. But I experimented different behaviours between iOS and Android. I place the root of the explorer in “documentsDirectory” for iOS and “dataDirectory” or “externalDataDirectory” for Android.

The method that I am using is listDir. It has a very simple usage.

listDir(path, dirName)
Returns: Promise<Entry[]> Returns a Promise that resolves to an array of Entry objects or rejects with an error.

When I tryied it with iOS device, it worked perfectly. I navigated through the directories without any problem.

When I did it with Android device. I retrieved directories and files of the “assigned root”. But when I tried navigate inside directories inside that “root”, it always send me to the “assigned root” instead. It don’t allows to me navigate to other directories than the “assigned root”.

First I thought that It was a permissions error, but I can create directories inside that directories by using “createDir(path, dirName, replace)” and check them that they exists by using “checkDir(path, dir)”.

The structure Directories are:
dataDirectory or externalDataDirectory

  • NewFolder1
    • NewFolder1.1
    • NewFolder1.2
  • NewFolder2

But when I try to get directories into “NewFolder1”, It gets to me:

  • NewFolder1
  • NewFolder2

There’s someone with that problem?
Or any idea of what can happens here?

Root path:
Destination path:

They resolved with the same Entry[]. Zero kind of errors.

Native File version: 4.3.3

I see no one have a solution. But I thing that is a serious problem.

Short description is: listDir method of Native File Plugin doesn’t works properly on Android.

Action: When is created a directory by using createDir and then it checks inside by using listDir.

It expects: Get a list with its own files.

What really do: It always get a list of files of its own parent folder.

It only happens on Android devices, iOS with the same code it is working correctly.

I leave a repo with an simple file explorer with that behaviour.

Finally I solved this issue by using properly the method listDir of the Ionic Native File plugin.

listDir(path: string, dirName: string)

iOS allows:
this.file.listDir('some/path/directory', '');

But Android don’t. It needs to explicitly fill both input parameters:
this.file.listDir('some/path/', 'directory');