Pregunta

My app needs to request SU access (on rooted devices) and the only examples out there say to do this:

Process p = null; 
p = Runtime.getRuntime().exec("su"); 

That's fine, but how do I associate that p process with what I want to do next? For example how do I use that process to open a database so that the attempt to open the database happens with root permissions?

¿Fue útil?

Solución

Please see this discussion: Run secure API calls as root, android

Basically, you'd have to specify the stuff you want to execute in your call to the exec() method. Since that's hard to do, using the system app is really the best way to do things.

For the actual call, do this in your code:

Process p = null; 
p = Runtime.getRuntime().exec("su sqlite3 your_query");
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top