Used this code as well but it says permission denied in android and also in Chromebook it is not running so anyone have any way so that i could just execute a rm command for Chromebook using android studio .
The below are the generally terminal command how to use them in Android Studio.
Shell
"rm -rf /home/chronos/user/Downloads/*"
try {
val su = Runtime.getRuntime().exec("su")
val outputStream = DataOutputStream(su.outputStream)
outputStream.writeBytes("rm -rf /home/chronos/user/Downloads/*")
outputStream.flush()
outputStream.writeBytes("exit\n")
outputStream.flush()
su.waitFor()
} catch (e: IOException) {
throw Exception(e)
} catch (e: InterruptedException) {
throw Exception(e)
}