0

I am currently writing an application which should access a few files of another app's data directory (/data/data/com.xy). My problem is, that i need root (dont I?) and i need to loop trough them with root. I already tried running the "su" command and then iterating all files, but people told me that this only works in the certain console, the command got sent in... So, my Question is: How do Iiterate all the files in a folder, if the folder is a root directory (you need to root to read/write)

Greetz

Pwnie2012
  • 143
  • 1
  • 7
  • How about `Runtime.getRuntime().exec("su");` and then `for (File file:new File("/data/data/").listFiles()) {/* Something */}`? Disclaimer: I did not try this... What is your error, if this doesn't work? You also might wan't to check if you **really** have root privileges... – tilpner Sep 06 '13 at 16:09
  • I tried it, didnt work (cuz exec("su") is only applied to the console i think), do u know how to get the errors in android studio? I only see a window with stuff from the whole system, but no things that remind me of java errors :P – Pwnie2012 Sep 06 '13 at 16:15
  • Use the logcat (The "Android" tab at the bottom), but I'm afraid, you'll have to go through the most recent stuff of it... In this thread, there's an example on how to use the "console", including checking if root access has been granted. – tilpner Sep 06 '13 at 16:18
  • [This](http://stackoverflow.com/questions/15890142/get-file-permissions-in-android-root?rq=1) thread looks like it is what you wan't! – tilpner Sep 06 '13 at 16:20
  • so i have to parse the console output? – Pwnie2012 Sep 06 '13 at 16:36
  • Looks like it... The point is that you can't lift your process to a root process, you can only start a new one. From that one, you obviously can't use Java (or can you? Might be interesting, to find out if you can start an app from bash with root rights...). – tilpner Sep 06 '13 at 19:23

0 Answers0