2014-09-03 57 views
-1

我需要在Android設備contente CD EXCUTE ADB shell中執行命令shell內容CD [倉庫] LS [ 「資源庫」] + Android中programmaticaly,如何在Android的programmaticaly

爲例LS:

Process process = Runtime.getRuntime().exec("cd data && cd data && cd condor.savtest && cd files && ls"); 

BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); 

謝謝

+0

你可以使用'ls data/data/condor.savtest/files'。但我建議使用java來列出目錄中的文件。 – BackSlash 2014-09-03 13:15:25

+0

我需要將txt文件複製到其他存儲庫Process process = Runtime.getRuntime()。exec(「cd data && cd data && cd condor.savtest && cd files && cp file.txt/system」); – user3083055 2014-09-03 13:34:07

+0

'cp data/data/condor.savtest/files/file.txt/system' ...但是如果沒有root權限,這種方法將無法工作。 – BackSlash 2014-09-03 13:34:48

回答

0

Runtime.exec()Runtime.exec()方法家族以某種方式期待您嘗試執行的命令及其參數。

就你而言,你正試圖執行一個shell命令行。不過,我想你的意圖是列出目錄中的文件,所以在這種情況下,你應該使用File.listFiles()

+0

我需要將txt文件複製到其他存儲庫Process process = Runtime.getRuntime()。exec(「cd data && cd data && cd condor.savtest && cd files && cp file.txt/system」); – user3083055 2014-09-03 13:16:08

相關問題