Getting the app data folder (cordova.file.dataDirectory)

While attempting to use the Cordova File Transfer plugin and I could not obtain the app data folder without some difficulty.

  1. When using “cordova.file.dataDirectory” I received the error “cannot find name ‘cordova’”
  2. Tried ‘typings install cordova’ with some luck. Received the error “no property File on type Cordova”
  3. Included ‘declare var cordova;’ at the top of my provider to override the typings. Works now.

Everything works but have I done this correctly? Seemed like a lot of work for something that should be trivial:

1 Like

Are you using ionic-native?

Using ionic-native for both “File” (cordova-plugin-file) and “Transfer” (cordova-plugin-file-transfer). As far as I can tell from the github repo, there is nothing similar to cordova.file.dataDirectory. Am I wrong?

My bad. Should be mainstreamed within a week or so, but if you would like to try it now, my implementation of the file plugin should have what you are looking for.

1 Like

Wow great, it’s already on your branch. Thanks!

Hi,

I am trying to use cordova.file.dataDirectory but my class can’t seem to recognise the variable despite importing File and Cordova from ionic-native. I am using the latest ionic 2 beta version (^1.3.9)

Is there anything else I need to do to get it to work apart from importing File, Cordova from ionic-native?

Many Thanks in advance.

it will not work on the browser unless you mock it: