I am creating an application that will access super user programmatically.Here i write some piece of code it will executes commands perfectly but my application was going to freezes and finally crashes after some time please help me with this. This is What i had did
public class MainActivity extends Activity {
Button files;
File path;
String directory_name;
EditText edit_text_files;
FileOutputStream fos;
String [] commands = new String[10];
boolean su;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try
{
Process process = Runtime.getRuntime().exec("su");
DataOutputStream data_out = new DataOutputStream(process.getOutputStream());
DataInputStream data_in = new DataInputStream(process.getInputStream());
data_out.writeBytes("mkdir mnt/udisk/samplefolder"+"\n");
data_out.flush();
data_out.writeBytes("exit \n");
data_out.flush();
process.waitFor();
}
catch(Exception e)
{
Log.e("Commands Exception :", "executing commands exception");
}