在Android的EACCESS权限被拒绝 [英] EACCESS Permission denied in Android

查看:226
本文介绍了在Android的EACCESS权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在写在外接SD卡文件我得到否定的错误EACCESS许可。我已经设置权限 <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/> 但是,当我读的文件,我成功地能够读取它,但不能写入文件。我使用的写文件SD卡的code是:

While writing file in External SD card I am getting an error EACCESS permission denied. I have set the permission <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> But the when I read the file I am successfully able to read it but not able to write the file. The code that I am using for writing the file in SD card is:

String path="mnt/extsd/Test";

                try{
                    File myFile = new File(path, "Hello.txt");              //device.txt
                    myFile.createNewFile();
                    FileOutputStream fOut = new FileOutputStream(myFile);

                    OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
                    myOutWriter.append(txtData.getText());
                    myOutWriter.close();
                    fOut.close();
                    Toast.makeText(getBaseContext(),"Done writing SD "+myFile.getPath(),Toast.LENGTH_SHORT).show();
                } catch (Exception e) {
                    Toast.makeText(getBaseContext(), e.getMessage(),Toast.LENGTH_SHORT).show();
                    System.out.println("Hello"+e.getMessage());
                }
            }

对于外部存储卡的路径是 MNT / extsd / 。这就是为什么我不能够使用 Environment.getExternalStorageDirectory()。getAbsolutePath()这是给我一个路径 MNT / SD卡键,这条道路是在我的平板电脑内置存储路径。请说明为​​什么这是因此n我怎么能解决这个

The path for the external storage card is mnt/extsd/. Thats why I am not able to use Environment.getExternalStorageDirectory().getAbsolutePath() which is giving me a path mnt/sdcard and this path is for internal storage path in my tablet. Please suggest why this is so n how can I resolve this

推荐答案

我记得的Andr​​oid得到了,因为蜂窝部分多存储支持,以及主存储(从Environment.getExternalStorageDirectory获得之一,通常是内部的一部分的eMMC卡)仍然由许可 WRITE_EXTERNAL_STORAG​​E 保护,但二级存储器(像真正的可移动SD卡)通过新的权限 Android的保护。 permission.WRITE_MEDIA_STORAG​​E ,保护级别为signatureOrSystem,另见的这篇文章

As I remember Android got a partial multi-storage support since Honeycomb, and the primary storage (the one you get from Environment.getExternalStorageDirectory, usually part of the internal eMMC card) is still protected by the permission WRITE_EXTERNAL_STORAGE, but the secondary storages (like the real removable SD card) are protected by a new permission android.permission.WRITE_MEDIA_STORAGE, and the protection level is signatureOrSystem, see also the discussion in this article.

如果是这种情况,那么,似乎不可能的正常应用程序,而无需一个平台签名写入任何真正的SD卡...

If this is the case then it seems impossible for an normal app to write anything to the real sdcard without a platform signature...

这篇关于在Android的EACCESS权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆