I am working on a File manager, and I want to be able to get root access to the /data folder. I want to create and maintain File objects from that directory. How can I accomplish this? Here is what I tried so far..
if (RootTools.isRootAvailable()) {
File file = new File("/data");
//here is where the app crashed, and I got a null pointer exception.
} else {
// do something else
}
From Wikipedia
If you are using Roottools, this will be enough:
It's a simple root check, but once you run this code, you will see su prompt(if your device is rooted) and once you grant access to your app you will have the super user rights.
P.S.: You may need to change the /data folder permissions to be writable.