Understanding SU request

强颜欢笑 提交于 2020-01-06 07:25:33

问题


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?


回答1:


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");


来源:https://stackoverflow.com/questions/7666349/understanding-su-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!