Why createFile() method can not create file


#1

My development platform is Android 5.0.2, and I followed API document of $cordovaFile carefully, the following is my code snippet:

$cordovaFile.createFile(cordova.file.dataDirectory, “test.txt”, true)
.then(function (success) {
console.log(‘OK’);
}, function (error) {
console.log(error.code)
});

In fact, I got ‘OK’, but I can’t find file test.txt in foler files. Can anybody help me? Thanks a lot in advance.


#2

i got the same doubt, did you find the solution?


#3

Are you looking at the right place? You can do console.log(cordova.file.dataDirectory) to see where was your file created


#4

My console.log(cordova.file.dataDirectory) print : file:///data/data/com.ionicframework.myapp423380/files/ , but in the windows explorer ( Galax\Phone\Android\data\com.ionicframework.myapp423380\files ) not appears any file… thanks


#5

what is console.log(success) show you?


#6

02-16 09:55:39.922 8962-8962/com.ionicframework.myapp423380 I/chromium﹕ [INFO:CONSOLE(57)] “[object Object]”, source: file:///android_asset/www/js/controllers.js