Android saving to external SD card?

萝らか妹 提交于 2019-12-06 01:49:51

This operation will fail if you don't have the following permissions in your AndroidManifest.xml file:

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

Make sure to put them within the top-level <manifest> tag, not the <application> tag where your activities are specified.

I had a problem similar to this before. It turned out that I had to manually create the directory first on the SD card before calling code such as Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);

Check if the absolute path exists on your file explorer for that directory. If it doesn't, then create it via adb shell and then give it a try again. This solved my problem, but it may not necessarily solve yours, give it a try though!

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