Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I request root access in Android?

Tags:

android

root

I need to get root access for rooted devices, and I was wondering how I can request root access. I need the access for the file system. Thanks a lot.

like image 441
Michell Bak Avatar asked Sep 03 '11 21:09

Michell Bak


People also ask

How do I get Root access on my Android?

In most versions of Android, that goes like this: Head to Settings, tap Security, scroll down to Unknown Sources and toggle the switch to the on position. Now you can install KingoRoot. Then run the app, tap One Click Root, and cross your fingers. If all goes well, your device should be rooted within about 60 seconds.


2 Answers

Just exec the command su and within that Process you have root priviliges:

Process p = Runtime.getRuntime().exec("su"); 

See this blog post for full example.

like image 152
dacwe Avatar answered Oct 18 '22 00:10

dacwe


WARNING

THIS METHOD IS NO LONGER VALID From 5.0

Most root devices use Superuser or SuperSU, if you wanna root ability in your app, you should claim superuser permission in your app manifest.

<uses-permission android:name="android.permission.ACCESS_SUPERUSER" /> 

More detailed information, you should check HOW-To SU by Chainfire (The author of SuperSU) and look into the example source libsuperuser(https://github.com/Chainfire/libsuperuser)

like image 22
liuyix Avatar answered Oct 18 '22 02:10

liuyix