Ionic 2, File.createDir not works


#1

Hi, i want create a file in my ionic 2 app.
I add cordova-plugin-file for that, and i test on android device emulator with AVD manager.

My code :

let targetPath = cordova.file.documentsDirectory;
console.log(targetPath); // print: file:///data/data … /files/, it’s okay
try {
File.createDir(targetPath, ‘toto.txt’, true).then((data) => …,
(data) => …);
}
catch (e) {
console.log(e); // throw an exception
}

An exception is throwed by try catch :
TypeError: Object function(name, localURL, type, lastModifiedDate, Size) … has no method createDir.

But i follow this doc http://ionicframework.com/docs/v2/native/file/, and there an function static createDir.
What is the problem?

Thanks!


#2

I resolved this problem : i add correct import to FIle.
Now File.createDir do a reject, and return a FileError with error : JSON_Error…