Run shell commands from android program
<p>This question has been asked here before but the solutions provided are not working..I am trying to display the contents of /data/dalvik-cache folder. I know that to do this we need to become su. I even did that but still i am unable to execute a shell command..</p>

<pre><code>package org.linuxconfidg.Example2;

import android.app.Activity;
import android.widget.*;
import android.os.Bundle;
import java.io.*;
public class Example2Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String lsreturn=myFunLs();
        TextView tv=new TextView(this);
        tv.setText("Hello Sindhu !! Try to get it \n"+lsreturn);
        setContentView(tv);
    }

    public String myFunLs()
    {

        try {
            // Executes the command.
            Process process;
            process = Runtime.getRuntime().exec("/system/bin/su");
            process = Runtime.getRuntime().exec("/system/bin/ls /data/dalvik-cache &gt; /data/local");
            pr
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(process.getInputStream()));
            int read;
            char[] buffer = new char[4096];
            StringBuffer output = new StringBuffer();
            while ((read = reader.read(buffer)) &gt; 0) {
                output.append(buffer, 0, read);
            }
            reader.close();

            // Waits for the command to finish.
            process.waitFor();

            return output.toString();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

}
</code></pre>

<p>Can anyone please help me out in finding out how to run linux commands in android application. I am testing this app in my emulator which is defaultly rooted</p>
