IOException: Permission denied

微信扫一扫,分享到朋友圈

IOException: Permission denied

I am trying to write a file to the external storage of the android. On the AndroidManifest.xml I’ve added (within the manifest tag)


then I tried:

File root = Environment.getExternalStorageDirectory();
File file = new File(root, xmlFilename);
file.createNewFile();

And then I get the exception. How may I resolve this?

Make sure your SD card is not mounted to your computer. If you have enabled USB storage, your SD card becomes read-only for Android.

Other then that, your application looks fine and should work.

Oh, and I would modify your code in a next way:

if(root.canWrite()){
    File file = new File(root, "file.xml");
    file.createNewFile();
}

微信扫一扫,分享到朋友圈

IOException: Permission denied

Xcode4: two entities with & ldquo; Required & rdquo; Relation and hellip&se...

上一篇

Crime blotter: California arrests, a Monster firing, and bulk thefts of new iPhones

下一篇

你也可能喜欢

IOException: Permission denied

长按储存图像,分享给朋友