Permission for reading/writing to the root folder in Android

我的未来我决定 提交于 2019-12-05 13:47:31

Unless you root your device, it is impossible to do any operations on the root directory on a non-rooted device because a third party app will run as a normal user and won't have the root permissions.

However, according to https://developer.android.com/reference/android/Manifest.permission, android.permission.FACTORY_TEST can give you the root permission.

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"

But note this can only be used by manufacturers by modifying the firmware, and this is not for any third part libraries or applications.

Are there any permissions I can/must declare in my app?

No. In order to access the root (/) folder your app must have a root permission which a user app can't have.

If your device is rooted, you can try to elevate the root rights from within the app which isn't a trivial task.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!