Read and write permissions to the Android root folder
Are there any permissions
that I can/must declare in my app
If I want the application to be able to scan the entire “/” folder
(e.g. recursively searching all .txt
files)?
So far, all I get is null
(when File.listFiles
is called).
No matter what permissions I try. I think I missed something.
Solution
You cannot do anything with the root directory on a non-rooted device unless you root your device because third-party applications will run as normal users and do not have root privileges.
However, according to https://developer.android.com/reference/android/Manifest.permission, android.permission.FACTORY_TEST
can give you root access.
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”
Note, however, that this can only be used by the manufacturer by modifying the firmware, and this does not apply to any third-party libraries or applications.