Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing data/app fails despite granted su permissions
    primarykey
    data
    text
    <p>Currently I am trying to get a quick overview of all installed apps on my phone by creating a ListView based on a string array consisting of all files contained within the data/app &amp; system/app directories:</p> <p>My code is as follows:</p> <pre><code>public void onCreate(Bundle icicle) { super.onCreate(icicle); Process p; try { // Preform su to get root privledges p = Runtime.getRuntime().exec("su"); // Attempt to write a file to a root-only DataOutputStream os = new DataOutputStream(p.getOutputStream()); os.writeBytes("echo \"Do I have root?\" &gt;/system/sd/temporary.txt\n"); // Close the terminal os.writeBytes("exit\n"); os.flush(); try { p.waitFor(); if (p.exitValue() != 255) { File dir = new File("./system/app"); File dir2 = new File("./data/app"); String[] values = this.both(dir.list(), dir2.list()); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, values); setListAdapter(adapter); } else { Toast.makeText(this, "not root", Toast.LENGTH_LONG).show(); } } catch (InterruptedException e) { Toast.makeText(this, "not root", Toast.LENGTH_LONG).show(); } } catch (IOException e) { Toast.makeText(this, "not root", Toast.LENGTH_LONG).show(); } </code></pre> <p>}</p> <p>(taken from <a href="http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/" rel="nofollow">http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/</a>)</p> <p>The both method looks as follows:</p> <pre><code> private String[] both(String[] first, String[] second) { List&lt;String&gt; both = new ArrayList&lt;String&gt;(first.length + second.length); Collections.addAll(both, first); Collections.addAll(both, second); return both.toArray(new String[both.size()]); } </code></pre> <p>However, my application keeps crashing. By removing the respective part of the code I was able to find out the reason is indeed the "new File("./data/app");" part.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload