$ cordovaFile.checkDir says the folder doesn't exist, but $ cordovaFile.createDir says the folder already exists

I am trying to work with the ngCordova File plugin as described here: http://ngcordova.com/docs/plugins/file/ , but I am getting strange behavior.

I am trying to create a folder if it doesn't already exist. I am testing its existence using:

$cordovaFile.checkDir(cordova.file.dataDirectory, 'inbound')

Now this returns NOT_FOUND_ERR

, so I try to create the folder later by calling:

$cordovaFile.createDir(cordova.file.dataDirectory, 'inbound', false);

But this returns PATH_EXISTS_ERR

Why would checkDir tell me that it doesn't exist, but then createDir tell me that it exists?

NOTE. This is an Android device.

+3


source to share


2 answers


These are promises, you use them like this:

$cordovaFile.checkDir(cordova.file.dataDirectory, "inbounds")
      .then(function (success) {
        // success
        alert("status " + success);


      }, function (error) {
        // error
      });

      



Have you customized your config.xml too?

<preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
<preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root" />

      

+2


source


Ok, I'm adding this as an answer, although the aorphevr started the whole rink. The problem I had in the first place was that I hadn't added the required lines to the config.xml file, which provided access to the device's file system.



Although I still had problems after that, the key point I was doing wrong was building and redeploying the app on top of the top install. Once I manually uninstalled the app and deployed it, it started working fine.

0


source







All Articles