Can't create folder in extsd card

廉价感情. 提交于 2019-12-01 13:23:26

问题


I have an android tablet where external SD card called "/mnt/extsd" and its internal storage called "/mnt/sdcard".

When I am try to create a folder in "/mnt/sdcard" by the following code. Application successfully creates folder in root directory, while I try to create folder in "/mnt/extsd" it toast an exception "open failed: EACCESS (Permission denied)"

    // 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() + "");
    }

Manifest

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

Any help from you guys will be very appreciable. Please HELP...:(


回答1:


If Environment.getExternalStorageDirectory() returns /mnt/sdcard/, then that is the external storage that you should be using in your application. While your device may have other mount points (e.g., /mnt/extsd/), those are not part of the Android SDK and will be more or less unique to your specific device. You will need to contact your device's manufacturer to ask them if there is a way you can use /mnt/extsd/ from a regular SDK application.

If you have root access, you might be able to work around this by changing permissions on /mnt/extsd/, but that is not really a programming topic and therefore is beyond the scope of StackOverflow.



来源:https://stackoverflow.com/questions/11604220/cant-create-folder-in-extsd-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!