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

标签 android android-permissions android-version android-storage

关于 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().

我的应用程序只读取和写入 Android/data//files 目录。这是否意味着,只要我的应用在早于 19 的 Android 版本上运行,为了读取和写入此特定目录,我仍然需要在 list 中声明此权限?

最佳答案

Android 文档说 here :

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. So you can declare the permission should be requested only on the lower versions of Android by adding the maxSdkVersion attribute:

<manifest ...>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
                     android:maxSdkVersion="18" />
    ...
</manifest>

所以答案显然是

关于android - 我是否需要在 Android 4.1 及更早版本上明确声明 WRITE_EXTERNAL_STORAGE 权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44477827/

相关文章:

Android 应用程序不会在低于 targetSDKVersion 的版本上启动

android - 跨不同设备处理 EditText 中的输入键

android - 使用Mediacodec和Motorola mobile发出音频编码问题

java - 使用 BitmapFactory.decodeByteArray 制作动画时帧速率不均匀

java - 如何在 AlphaAnimation 运行时禁用按钮

android - 应用程序不适用于 Google Play 上的 Nexus 7

android - 谁能告诉我 "on O+ for instant apps"是什么意思?

android - 您是愿意使用测试 Build.VERSION.SDK_INT 还是反射来测试是否存在?

android - “允许 [app name] 调用和管理电话”权限和 READ_PHONE_STATE

android - 为什么HMS PushKit需要android.permission.REQUEST_INSTALL_PACKAGES