Android App Development – Root App

Hi there, today continuing on our series from last time, we are going to make a very very basic root app. Now before we start with the root app, we have to ask “What is root??” (Actually some people are out there, who don’t know  ). So basically you have your Android system permissions, permission that you accept  every time you install an android app. Well, what root does is allow you to bypass those permissions, basically your android device  instead of being stuck inside the box,  you issue a command that lets your android device to jump outside of that box and elevate your permission. Your device becomes Superuser. You see, linux has many layers of permissions just like real life, when you execute su –c, that’s the same as linux’s SUDO command that we all familiar with from running linux.

For eg-  hey mom, get me a chicken briyani..(Standard user permission)
Mom- No
Me to mom- Sudo,  get me a chicken biryani. (Permission Escillation)
Hell ya, i got my chicken biryani.. I am going to have lunch now..
So let’s continue from where we left..
But now, elevating your permission above what you are allowed to do normally can be kinda dangerous. If you don’t know exactly what you are doing, it can be pretty bad. For eg:
Me- Sudo Punch me on the face..
No no, I was kidding,  Ctr+c  Ctr+c..Sorry  I take back my command…

So never try this : sudo rm –rf / (I dont take any responsibility)
Now I just want to put this out here as disclaimer, I know JAVA a lot more  than I know android. So in my mind I can separate these two, you have java over one side and you have android over other side. Basically you work with android and you move it into JAVA. Now the cool thing about Java is that you can take applications that were written for desktop and pull the code right out and put them right into your android applications . Now its possible to certain level . So later I am going to show you exactly what I mean.
Also I can’t create tutorial on Java at this moment. Java is huge complex language. I have given you the basic tool link on my first tutorial to get started. In order to follow with this today’s tutorial, You are going to need.
1.  SDK setup
2.  Eclipse Setup
3.  Rooted android Device
4.  And,  A Diet coke  (Everyone knows developer run on caffeine  ).

Alright let’s get started.

Development :

Step 1: Setup your android project.  File > New > Android Project.  Name the Project name as RootApp. Choose SDK (I prefer 2.3.3 or 4.0.3). Press Next

Step 2 :  Set package Name as Com.RootApp , Select Minimum SDK as 10 for Gingerbred and 15 for ICS and hit finish.

Step 3: After setting up Project, open Main.xml (PATH: RootApp > res > layout > main.xml). Drag button from palette onto your layout screen  or modify the main.xml as shown in below figure.

Step 4: Open from the PATH: RootApp > src > com.RootApp > . It may look something like this:

Now I would like to stop here and take your one minute, You will find lot of times in object oriented programming that you will have a value inside a  method , inside a inner class and inside another class and it just keeps on going . That’s the object  oriented programming or language where you can create something that’s an object and manipulate little parts of that object, one at a time and you end up with a hole that is portable.. That’s how I understood OOPS. So here we will create new class called shell and then create object of shell class and use its method in our class..
Since we know that Android is an open source . so we can grab required class from other app (if project is open source )and can use it in our application, but don’t ever forget to give the credits to source .

Step 5:Now create new class inside your package com.RootApp  and name it as shell. You can download (or copy)  the shell class content  from  here and paste it in our shell class and then save it..

Step 6: Create an object of shell class inside and and use shell method as shown below:
Shell shell = new Shell();
Result= Shell.sudo(input)
Here input is the command which you write inside Textbox to execute.

RootAppActivity code:

package com.RootApp;

import com.RootApp.Shell.ShellException;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class RootAppActivity extends Activity {
private Button RootAppButton;
private EditText inputCommand;
private TextView tvOutput;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
// getting button reference from layout
RootAppButton = (Button) findViewById(;
inputCommand = (EditText) findViewById(;
tvOutput = (TextView) findViewById(;

// lets make button to do something
RootAppButton.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
String input = inputCommand.getText().toString();
String result = “”;
// Instance of shell class
Shell shell = new Shell();
try {
result = shell.sudo(input);
} catch (ShellException e) {
// TODO Auto-generated catch block
} finally {



Step 7 :Save everything. Connect your Android Device to computer. Make sure USB Debugging is checked and you have rooted your phone. Press Ctrl+F11 and select Android Application then hit Ok. Following are the Screenshot of running app.

basic root app
root app
very basic root app

So guys, we have done it. Congrats, We have developed our first root app.