i'm trying to write onto the "/data/myFolder" folder on the android virtual device during test and to do that, i do:
String[] cmd ={"su", "mkdir", dir};
int out = 99;
try {
Process p = Runtime.getRuntime().exec(cmd);
out = p.waitFor();
BufferedInputStream in = new BufferedInputStream(p.getErrorStream());
byte[] bytes = new byte[4096];
while (in.read(bytes) != -1) {
}
in.close();
logger.info("exit status:" + out);
} catch (IOException e) {
logger.severe("IOException " + e.getMessage());
e.printStackTrace();
} catch (InterruptedException e) {
logger.severe("InterruptedException " + e.getMessage());
e.printStackTrace();
}
if (out != 0) {
logger.severe("Folder " + dir + " not created,exit status: " + out);
}
or i've tried
String cmd ={"su mkdir" + dir};
but the exit status is 1 and it not create any folder. using su mkdir /data/myFolder from adb shell works fine. Why this code? what means? (i know it means that something went wrong, but what? didn't find any documentation about android mkdir exit code values). Thank's