首页 > 解决方案 > 如何解决 java.io.IOException: No such file or directory or Permission denied issue on execution sh file from android in windows machine

问题描述

我需要使用 android 程序中的命令行选项执行 sh 文件。我尝试使用 Runtime.getRuntime().exec。我试图将命令作为字符串以及字符串 [] 传递。但问题仍然存在。我已经在清单文件中授予了在外部存储中读写的权限。

我尝试使用诸如

  1. getContext().getFilesDir() +
  2. “/数据/用户/0//文件/...”
  3. Environment.getExternalStorageDirectory() +
  4. 我们系统中的路径,例如 C:\Users\...

我尝试使用 cp、rm、ls....以及我实际需要的命令.. 对于上述所有试验,发生了 IO 异常。(权限被拒绝或没有这样的文件或目录)

你能知道一个可能的解决方案来摆脱这个错误并在 android 程序中使用命令行执行 sh 文件。

先感谢您

标签: androidpermission-denied

解决方案


推荐阅读