Android: how to kill an external application and reset its data
<p>I have seen bits and pieces around but nothing complete (or that worked). Essentially I want to kill an external application and wipe all of its data, essentially resetting the program back to its initial install state. </p>

<p>I am trying this for skype (for example):</p>

<pre><code>try {
                    Process proc = Runtime.getRuntime().exec("su");

                    proc = Runtime.getRuntime().exec("pidof com.skype.raider");
                    BufferedReader reader = new BufferedReader( new InputStreamReader(proc.getInputStream()),8192);

                    char[] buffer = new char[8192];
                    StringBuffer output = new StringBuffer();
                    int read = 0;
                    while ((read = reader.read(buffer)) &gt; 0) {
                          output.append(buffer, 0, read);
                    }
                    reader.close();
                    proc.getErrorStream().close();
                    proc.getOutputStream().close();
                    proc.waitFor();


                    proc = Runtime.getRuntime().exec("kill " + output.toString());
                    proc.waitFor();


                    proc = Runtime.getRuntime().exec("rm -r /data/data/com.skype.raider/*");
                    proc.waitFor();

                } catch (Exception ex) {
                    //Log.i(TAG, "Error", ex);
                }
</code></pre>

<p>BTW: All of those commands work fine in ADB...</p>
