• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

I am trying to give root access to my app and trying to copy a file to root directory, I need help

  • Thread starter Thread starter LeeSan
  • Start date Start date
L

LeeSan

Guest
try{java.lang.Process p =
Runtime.getRuntime().exec("su");
File src = new File("/storage/emulated/0/TEST.out");File dest = new File("/data/data/com.termux/files/home/file");
FileSystemUtils.copyRecursively(src,dest);}
 
try{java.lang.Process p =
Runtime.getRuntime().exec("su");
File src = new File("/storage/emulated/0/TEST.out");File dest = new File("/data/data/com.termux/files/home/file");
FileSystemUtils.copyRecursively(src,dest);}
what phone do you have? your phone will need to be rooted to gain root access. is your phone rooted?
 
More details about what phone model you have, which version of Android it's running, and if it is or isn't actually rooted will help to make relevant suggestions.
But offhand, if you go into your Settings >> Apps menu, find and open the Termux app listing, and in Permissions, check that Storage is enabled. Then when you start up Termux, run

apt update && apt upgrade

and then

termux-setup-storage

More details on this here:
https://wiki.termux.com/wiki/Termux-setup-storage
 
Back
Top Bottom