I know this is possible in android API version 21, but I want to do it in the API version 19 or earlier. To achieve this task, I have to get root permissions. I don't know how to get root permission. How can this be achieved?
What you need to do is something like:
Process root = Runtime.getRuntime().exec("su");
That causes SuperUser to show, which lets you either Allow or Block it from root access. This approach might not work if the user is not rooted. Here is a way you can test it.