我必须同时声明WRITE_EXTERNAL_STORAGE和READ_EXTERNAL_STORAGE吗? [英] Do I have to declare both WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE?

查看:623
本文介绍了我必须同时声明WRITE_EXTERNAL_STORAGE和READ_EXTERNAL_STORAGE吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

声明<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />是否足够?还是必须声明<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />? Javadocs忽略了这一重要信息.

Is it enough to declare <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> or do I also have to declare <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />? The Javadocs omit this important information.

推荐答案

READ_EXTERNAL_STORAGE仅在Jelly Bean(级别16)开始存在.根据文档,自Jelly Bean起,所有应用程序都具有该权限,即使未声明它:

READ_EXTERNAL_STORAGE only exists as of Jelly Bean (Level 16). According to the docs, all applications as of Jelly Bean have that permission, even without declaring it:

提供对外部存储的受保护的读取访问权限.在Android 4.1中 默认情况下,所有应用程序仍然具有读取访问权限.这将被更改 在将来的版本中要求应用程序明确请求 使用此权限进行读取访问.如果您的应用程序已经 请求写访问权限,它也会自动获得读访问权限. 有一个新的开发人员选项可以打开读取访问限制, 让开发人员针对Android将如何测试他们的应用程序 将来会表现出来.

Provides protected read access to external storage. In Android 4.1 by default all applications still have read access. This will be changed in a future release to require that applications explicitly request read access using this permission. If your application already requests write access, it will automatically get read access as well. There is a new developer option to turn on read access restriction, for developers to test their applications against how Android will behave in the future.

因此,您应该声明它是为了将来的兼容性,但这可能不是问题的根源,除非您使用的是Jelly Bean手机,并将开发人员选项设置为保护USB存储"选项.

So, you should declare it for future compatibility, but this might not be the source of your problem, unless you're using a Jelly Bean phone and set the developer option "Protect USB storage" option.

这篇关于我必须同时声明WRITE_EXTERNAL_STORAGE和READ_EXTERNAL_STORAGE吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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