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

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

问题描述

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

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天全站免登陆