简体   繁体   English

我是否需要在Android 4.1及更低版本上明确声明WRITE_EXTERNAL_STORAGE权限?

[英]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.

相关问题 为什么我需要在Android Lollipop上使用getExternalCacheDir()的WRITE_EXTERNAL_STORAGE权限? - Why do I need the WRITE_EXTERNAL_STORAGE permission with getExternalCacheDir() on Android Lollipop? Android:我是否需要 WRITE_EXTERNAL_STORAGE 才能让 com.squareup.picasso 使用磁盘缓存? - Android: Do I need WRITE_EXTERNAL_STORAGE in order com.squareup.picasso to use disk cache? WRITE_EXTERNAL_STORAGE权限 - WRITE_EXTERNAL_STORAGE Permission 我是否必须声明WRITE_EXTERNAL_STORAGE和READ_EXTERNAL_STORAGE? - Do I have to declare both WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE? File.mkdirs() 是否需要 WRITE_EXTERNAL_STORAGE 权限 - Does File.mkdirs() need WRITE_EXTERNAL_STORAGE permission android:installLocation =“ preferExternal”和WRITE_EXTERNAL_STORAGE权限 - android:installLocation=“preferExternal” and WRITE_EXTERNAL_STORAGE permission Android:设备不接受WRITE_EXTERNAL_STORAGE权限 - Android: WRITE_EXTERNAL_STORAGE permission not accepted by device WRITE_EXTERNAL_STORAGE 权限不在 Android 中询问 13 - WRITE_EXTERNAL_STORAGE permission Not asking in Android 13 android - 如果用户未授予 WRITE_EXTERNAL_STORAGE 权限,则关闭应用程序 - android - close app if user not granting WRITE_EXTERNAL_STORAGE permission Android中的Gdx.files.local和WRITE_EXTERNAL_STORAGE权限 - Gdx.files.local and WRITE_EXTERNAL_STORAGE permission in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM