I have a java file that have this piece of code to list the files in the cache directory of an app and it works well.
String command[] = {"adb","shell","run-as",pack,"ls","cache/"};
Process process = Runtime.getRuntime().exec(command);
InputStream o_out = process.getInputStream(); //covert o_out to String to get the files name
Now i want to this code to run on directly on android devices, but it fails because the command was wrong, any idea?