【问题标题】:Can't create folder in extsd card无法在 extsd 卡中创建文件夹
【发布时间】:2012-07-22 21:47:10
【问题描述】:

我有一个 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" />

你们的任何帮助都将非常感激。请帮忙...:(

【问题讨论】:

    标签: android permissions directory sd-card


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2012-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      • 2014-11-12
      • 2017-12-10
      相关资源
      最近更新 更多