PhoneGap android应用程序需要获取外部sdcard路径,但它仅返回内部sdcard路径 [英] PhoneGap android app need to get external sdcard path, but its return only internal sdcard path

查看:58
本文介绍了PhoneGap android应用程序需要获取外部sdcard路径,但它仅返回内部sdcard路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i am using phonegap for android application to get external card,

我正在使用以下代码:

<!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

Its returns file://mnt/sdcard/app - this is my internal phone storage path the external path is file://mnt/ext_card/app

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

How can i get external card path in phonegap?

推荐答案

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

Finally i found we can't get the external SD Card Path,

Environment.getExternalStorageState();

它仅返回内部SD卡路径

Its returns only Internal SD Card path

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

这篇关于PhoneGap android应用程序需要获取外部sdcard路径,但它仅返回内部sdcard路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆