Android File.exists() 需要权限吗?

标签 android file android-permissions

我是否需要 Android 权限(READ_EXTERNAL_STORAGE)才能调用 exists() 方法? 在我测试的时候,我可以在未经允许的情况下在内部存储中获取 true 或 false。

如果在 sdcard 之类的外部存储中怎么办?

谢谢。

最佳答案

没有。

我测试过,无论READ/WRITE_EXTERNAL_STORAGE是否授予,即使用户点击never ask again拒绝读/写权限。 File.exists() 仍然可以正常工作。

在 Android 8.1.0 上测试

关于Android File.exists() 需要权限吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48016618/

相关文章:

android - Gradle 连接超时

android - 应用程序未经许可写入外部存储

file - Gradle - 将单个文件添加到 JAR

c# - 系统.IO.IOException : The process cannot access the file '.txt' because it is being used by another process

java - 无法使用文件提供程序共享图像 java.lang.SecurityException : Permission Denial: reading androidx. core.content.FileProvider uri

java.lang.SecurityException : BLUETOOTH permission crash.(仅限三星设备)

android - 主屏幕组件名称

java - Android Studio 中的断点 C++ 文件

java - (Project Tango)通过区域学习进行点云的旋转和平移

Java解析文本文件并获取单词和字符之间的所有单词