Here you can find the source of executeCommand(String command)
public static boolean executeCommand(String command)
//package com.java2s; /*/* w w w . ja va 2 s . co m*/ * Msim Ende * * Helps to switch between single and dual sim only for GT-I9082. Flexible code to show only if GT-I9082. * * Copyright (c) 2014 Ashish Shekar * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import android.util.Log; import java.io.IOException; import java.io.DataOutputStream; public class Main { public static final String APP = "MsimEnDeCommand"; public static boolean executeCommand(String command) { try { Process getRootAccess = Runtime.getRuntime().exec("su"); DataOutputStream getRootAccessDos = new DataOutputStream( getRootAccess.getOutputStream()); getRootAccessDos.writeBytes(command + "\n"); getRootAccessDos.writeBytes("exit\n"); getRootAccessDos.flush(); getRootAccess.waitFor(); if (getRootAccess.exitValue() == 1) { Log.e(APP, "CommandShell: SuperUser Access demied."); return false; } else { Log.i(APP, "CommandShell: SuperUser permission granted."); return true; } } catch (IOException e) { Log.e(APP, "CommandShell: Unable to execute command as superuser!"); return false; } catch (InterruptedException e) { Log.e(APP, "CommandShell: executeCommand method interrupted"); return false; } } }