简体   繁体   中英

fopen failed while writing into an external SDcard in Android native code

When I am trying to write into external SDcard from android native code, I am getting permission denied in fopen.

mFp = fopen("/storage/extSdCard/Output/test.txt", "wb");

if I print strerror(errno) it gives ->

fopen(/storage/extSdCard/Output/test.txt) failed: Permission denied

Please note that I have also given the permissions in my Application manifest :

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

and also :

String state = Environment.getExternalStorageState();
        if (Environment.MEDIA_MOUNTED.equals(state)) {
            return true;
        }

is returing true.

请检查外部存储设备是插入的外部卡还是设备随附的sdcard。如果它是设备本身随附的sdcard,请尝试将路径设置为“ / mnt / drive_path”,并检查您的本机方法是否为能够写入您的存储。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM