简体   繁体   English

在检查文件夹是否存在或列出其子文件夹之前,我是否必须检查 READ_EXTERNAL_STORAGE

[英]Do I have to check READ_EXTERNAL_STORAGE before checking if folder exists or listing its subfolders

I know that READ_EXTERNAL_STORAGE is needed to read files outside app storage, but how about folders.我知道读取应用程序存储之外的文件需要 READ_EXTERNAL_STORAGE ,但是文件夹怎么样。 The official documentation ( https://developer.android.com/reference/android/Manifest.permission#READ_EXTERNAL_STORAGE ) isn't very clear and other sources online are not helpful either.官方文档( https://developer.android.com/reference/android/Manifest.permission#READ_EXTERNAL_STORAGE )不是很清楚,其他在线资源也没有帮助。 Do I have to check this permission before I check if some specific folder exists and what subfolders does it have?在检查某些特定文件夹是否存在以及它有哪些子文件夹之前,我是否必须检查此权限?

As @blackapps suggested, checking if any folder exists works always without permission on API 23 device.正如@blackapps 所建议的那样,在 API 23 设备上检查是否存在任何文件夹总是无需许可。 Listing contents (subfolders) is more complicated:列出内容(子文件夹)更复杂:

  • root and its subfolders (/): works without permissions root 及其子文件夹 (/):无需权限即可工作
  • user storage root and its subfolders (/storage/emulated/0, /sotrage/sdcard1, ...): needs permission用户存储根目录及其子文件夹(/storage/emulated/0、/sotrage/sdcard1、...):需要权限

Still I'd like to know more universal answer.我仍然想知道更普遍的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在解压 obb 文件之前是否必须检查 READ_EXTERNAL_STORAGE? - Do I have to check READ_EXTERNAL_STORAGE before unzip obb file? 我是否必须声明WRITE_EXTERNAL_STORAGE和READ_EXTERNAL_STORAGE? - Do I have to declare both WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE? READ_EXTERNAL_STORAGE 显示权限,但不显示 READ_EXTERNAL_STORAGE - READ_EXTERNAL_STORAGE shows permission but not READ_EXTERNAL_STORAGE 即使我在清单中声明,Read_external_storage 权限也不起作用,不在 android 工作室中运行 - Read_external_storage permission is not working even i have declared in manifest,not running in android studio READ_EXTERNAL_STORAGE权限,尽管清单中有此权限,但应用程序崩溃 - READ_EXTERNAL_STORAGE permission, app crash despite I have this in manifest Android READ_EXTERNAL_STORAGE 权限不起作用 - Android READ_EXTERNAL_STORAGE permission not working 权限READ_EXTERNAL_STORAGE始终被拒绝 - Permission READ_EXTERNAL_STORAGE is always denied READ_EXTERNAL_STORAGE 无法解析或不是字段 - READ_EXTERNAL_STORAGE cannot be resolved or is not a field READ_EXTERNAL_STORAGE权限未请求权限 - READ_EXTERNAL_STORAGE permission not asking for permission 无法请求READ_EXTERNAL_STORAGE权限 - cannot request READ_EXTERNAL_STORAGE permission
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM