是否有任何我可以/必须在我的应用程序中声明的权限,
如果我希望应用程序能够扫描整个“/”文件夹
(例如,以递归方式搜索所有 .txt
文件)?
到目前为止,我得到的只是 null
(调用 File.listFiles
时)
无论我尝试什么权限。我想我错过了什么。
最佳答案
除非您对您的设备进行 root,否则无法对非 root 设备上的根目录执行任何操作,因为第三方应用程序将以普通用户身份运行并且不具有 root 权限。
然而,根据https://developer.android.com/reference/android/Manifest.permission , android.permission.FACTORY_TEST
可以给你root权限。
FACTORY_TEST added in API level 1
public static final String FACTORY_TEST
Run as a manufacturer test application, running as the root user. Only available when the device is running in manufacturer test mode.
Not for use by third-party applications.
Constant Value: "android.permission.FACTORY_TEST"
但请注意,这只能由制造商通过修改固件来使用,这不适用于任何第三方库或应用程序。
关于java - Android 根文件夹读写权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52212997/