0

我有一个 android 平板电脑,其中外部 SD 卡称为“/mnt/extsd”,其内部存储称为“/mnt/sdcard”。

当我尝试通过以下代码在“/mnt/sdcard”中创建一个文件夹时。应用程序成功在根目录中创建文件夹,而我尝试在“/mnt/extsd”中创建文件夹时出现异常“打开失败:EACCESS(权限被拒绝)”

    // create a File object for the parent directory
    File root_directory = new File("/mnt/extsd/abc/");
    // have the object build the directory structure, if needed.
    root_directory.mkdirs();
    // create a File object for the output file
    File outputFile = new File(root_directory, "abc_checking");
    // now attach the OutputStream to the file object, instead of a String representation
    try {
        FileOutputStream fos = new FileOutputStream(outputFile);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        Utility.showDialogue(getActivity(), e.getMessage() + "");
    }

显现

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

你们的任何帮助都将是非常可观的。请帮忙...:(

4

1 回答 1

2

如果Environment.getExternalStorageDirectory()返回/mnt/sdcard/,那么这就是您应该在应用程序中使用的外部存储。虽然您的设备可能有其他挂载点(例如,/mnt/extsd/),但这些不是 Android SDK 的一部分,并且对于您的特定设备或多或少是唯一的。您需要联系您的设备制造商,询问他们是否有可以/mnt/extsd/从常规 SDK 应用程序中使用的方法。

如果您具有 root 访问权限,则可以通过更改 的权限来解决此问题/mnt/extsd/,但这并不是真正的编程主题,因此超出了 StackOverflow 的范围。

于 2012-07-22T21:53:35.340 回答