Copy files to another package folder (root, su)

2019-05-14 11:44发布

I have my application's package (com.my.package) and i'd like to be able to copy some files (a.txt, b.txt and c.txt) to another package (data/data/com.another.package/files). Now i've tried a few things i found, but none worked. Any help please?

2条回答
成全新的幸福
2楼-- · 2019-05-14 11:52

You need to get the Runtime and use the cat command.

Runtime.getRuntime().exec("su cat filepath1 > filepath2");
查看更多
Ridiculous、
3楼-- · 2019-05-14 12:13
Runtime.getRuntime().exec("su cat filepath1 > filepath2");

creates an empty file for me too. I have to use su -c instead

Runtime.getRuntime().exec("su -c cat filepath1 > filepath2");
查看更多
登录 后发表回答