获取手机缺口中的应用程序目录

Nee*_*raj 10 cordova

使用手机间隙构建的文件api,我想获得应该存储所有文件的应用程序目录.

我需要使用什么命令?

dav*_*ids 4

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);
Run Code Online (Sandbox Code Playgroud)

使用此代码,您将在全局变量“rootFS”中存储应用程序根目录的 DirectoryEntry 对象。您可以像这样获取该文件夹的路径:

rootFS.fullPath
Run Code Online (Sandbox Code Playgroud)

  • 我遇到了同样的问题!我正在 Samsung sII 上使用phonegap build 和 Android - 我最终位于 filesystem.root (/sdcard) 而不是应用程序文件夹:(对此还有更多建议吗? (2认同)