0

我正在使用phonegap for android应用程序来获取外部卡,

我正在使用此代码:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Hello World</title>
        <link rel="stylesheet" href="css/index.css" type="text/css" />
        <script src="js/jquery.js" type="text/javascript"></script>
        <script src="cordova.js" type="text/javascript"></script>
        <script type="text/javascript">
            window.appRootDirName = "app";
            document.addEventListener("deviceready", onDeviceReady, false);

            function onDeviceReady() {
                console.log("device is ready");
                window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
                alert(window.appRootDir.fullPath);

            }

            function fail() {
                console.log("failed to get filesystem");
            }



            function gotFS(fileSystem) {
                console.log("filesystem got");
                window.fileSystem = fileSystem;
                fileSystem.root.getDirectory(window.appRootDirName, {
                    create: true,
                    exclusive: false
                }, dirReady, fail);
            }

            function dirReady(entry) {
                window.appRootDir = entry;

                console.log("application dir is ready");
            }



        </script>
    </head>
    <body>


    </body>
</html>

它的回报file://mnt/sdcard/app- 这是我的内部电话存储路径外部路径是file://mnt/ext_card/app

如何在 phonegap 中获取外部卡路径?

4

1 回答 1

0

最后我发现我们无法获取外部 SD 卡路径,

Environment.getExternalStorageState();

它仅返回内部 SD 卡路径

参考: http: //developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()

于 2013-09-25T12:50:23.580 回答