我正在尝试将文件写入SDCard,但我在logcat中收到错误:
01-24 09:03:33.647: W/System.err(3353): java.io.fileNotFoundException: /mnt/sdcard/fun/itisfun.txt: open Failed: EACCES (Permission denIEd) 01-24 08:24:28.007: W/System.err(3353): Caused by: libcore.io.ErrnoException: open Failed: EACCES (Permission denIEd) 01-24 09:03:33.756: W/System.err(3353):at libcore.io.Posix.open(Native Method)
在这里我的代码写入SDCard:
file root = null; try { // check for SDcard root = Environment.getExternalStorageDirectory(); Log.i(TAG,"path.." +root.getabsolutePath()); //check sdcard permission if (root.canWrite()){ file fileDir = new file(root.getabsolutePath()+"/fun/"); fileDir.mkdirs(); file file = new file(fileDir, "itisfun.txt"); fileWriter filewriter = new fileWriter(file); BuffereDWriter out = new BuffereDWriter(filewriter); out.write("I m enjoying......dude"); out.close(); }} catch(...) { ...}
表现:
<uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE" /><permission androID:name="androID.permission.INTERNET"></permission>
解决方法:
要写入Sdcard,您需要在清单文件中授予权限
<uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE" />
总结 以上是内存溢出为你收集整理的android – 写入sdCard时权限被拒绝全部内容,希望文章能够帮你解决android – 写入sdCard时权限被拒绝所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)