PhoneGap's navigator.fileMgr always undefined

时间秒杀一切 提交于 2019-12-11 04:43:16

问题


I'm building iOS app with PhoneGap, need to write and read text file to the device.

I followed the steps found here: http://docs.phonegap.com/en/2.0.0/guide_getting-started_ios_index.md.html#Getting%20Started%20with%20iOS

Everything works fine, except I cannot use any of the API (I tried file and notification). I am calling: alert(navigator.fileMgr) but it's always undefined.

I am calling that in the deviceready callback function.

I think I missed some important steps, could anyone have experience in this give me some link/guide/help?

Thanks in advance!


回答1:


I'm not sure where you are getting your info but navigator.fileMgr does not exist anymore and hasn't for a long time. We've implemented the W3C File API:

http://docs.phonegap.com/en/2.0.0/cordova_file_file.md.html#File

To get the root path of the file system you would do:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {
    console.log("File system root = " + fileSys.root.fullPath);
}, function() {
    console.log("Could not get file system");
});

Examples of how to read/write files are also available on the docs site.



来源:https://stackoverflow.com/questions/12170379/phonegaps-navigator-filemgr-always-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!