Thursday 15 March 2012

Cordova File api : getFile issue in android -



Cordova File api : getFile issue in android -

environment : android

within app im creating file @ location "/data/data/com.my.app/changes/123456789/123456789.json" , have cross checked file exists using custom cordova android plugin.

when trying access file using cordova file api shown below. api fails giving 1000 code.

var path = "/changes/123456789/123456789.json" window.requestfilesystem(localfilesystem.persistent, 0, function(filesystem){ console.log('in got fs'); filesystem.root.getfile(path,{create:true, exclusive: false}, function(fileentry){ console.log('gotfileentry'); }, function(err){ console.log('gotfileentry fail'); console.log('err.code'); console.log(err.code); } ); }, function(){ console.log('fail'); } );

im getting error code "1000" believe "file not found".

as per new plugin docs path file should relative filesystem root. think issue way im passing file path.

the same working when tested on ios device, issue android.

please allow me know im going wrong. im totally stuck. help highly appreciated.

thanks in advance.

hi after lot of digging cordova file api , help post , able access files in android.

used

window.resolvelocalfilesystemurl(cordova.file.datadirectory, function(dir) { console.log("got main dir",dir); dir.getfile("log.txt", {create:true}, function(file) { console.log("got file", file); }); });

to file entry in android. works fine ios also.

android cordova cordova-plugins cordova-3.5

No comments:

Post a Comment