Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy files to another package folder (root, su)

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?

like image 490
user2015552 Avatar asked Feb 16 '26 02:02

user2015552


2 Answers

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

Runtime.getRuntime().exec("su cat filepath1 > filepath2");
like image 104
Raghav Sood Avatar answered Feb 18 '26 14:02

Raghav Sood


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");
like image 40
nnarayann Avatar answered Feb 18 '26 14:02

nnarayann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!