我是否需要在 Android 4.1 及更早版本上明确声明 WRITE_EXTERNAL_STORAGE 权限?
Do I need to explicitly declare WRITE_EXTERNAL_STORAGE permission on Android 4.1 and earlier?
关于 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 版本上运行,为了读取和写入此特定目录,我仍然需要在清单中声明此权限?
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>
所以答案明确是。
关于 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 版本上运行,为了读取和写入此特定目录,我仍然需要在清单中声明此权限?
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>
所以答案明确是。