Getting application directory in phone gap

后端 未结 2 827
鱼传尺愫
鱼传尺愫 2020-12-19 02:37

Using the file api of phone gap build, I want to get the application directory in which all files should be stored.

What command do I need to use?

2条回答
  •  再見小時候
    2020-12-19 02:51

    function gotFS(fileSystem) {
        console.log("got filesystem");
        // save the file system for later access
        console.log(fileSystem.root.fullPath);
        window.rootFS = fileSystem.root;
    }
    
    document.addEventListener('deviceready', function() {                
        window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
    }, false);
    

    With this code you'll have a DirectoryEntry object for the root directory of your app stored in the global variable "rootFS". You can get the path of that folder like this:

    rootFS.fullPath
    

提交回复
热议问题