[英]Do I need to explicitly declare WRITE_EXTERNAL_STORAGE permission on Android 4.1 and earlier?
Regarding the WRITE_EXTERNAL_STORAGE, the Android docs state that 关于WRITE_EXTERNAL_STORAGE,Android文档指出
Starting in API level 19, this permission is not required to read/write files in your application-specific directories returned by getExternalFilesDir(String) and getExternalCacheDir(). 从API级别19开始,读/写由getExternalFilesDir(String)和getExternalCacheDir()返回的应用程序特定目录中的文件不需要此权限。
My app only reads and writes to the Android/data//files directory. 我的应用仅读取和写入Android / data // files目录。 Does that mean that, in order to read and write to this specific directory whenever my app runs on Android versions earlier than 19, I still will need to declare this permission in the manifest? 这是否意味着,只要我的应用在19之前的Android版本上运行,为了读写此特定目录,我仍然需要在清单中声明此权限?
Android doc says here : Android文档在这里说:
Beginning with Android 4.4, reading or writing files in your app's private directories does not require the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permissions. 从Android 4.4开始,读取或写入应用程序专用目录中的文件不需要READ_EXTERNAL_STORAGE或WRITE_EXTERNAL_STORAGE权限。 So you can declare the permission should be requested only on the lower versions of Android by adding the maxSdkVersion attribute: 因此,您可以通过添加maxSdkVersion属性来声明只应在较低版本的Android上请求该权限:
<manifest ...> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> ... </manifest>
So the answer is explicitly YES . 因此,答案是明确的YES 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.