How can you detect if the device is rooted in the app? [duplicate]
Possible Duplicate:
Determine if running on a rooted device
On Launch of the application, I want to detect if the device running is rooted. Is there proper way of detecting it?
I don't think trying to write a file to '\data' to see if rooted is a good solution. (Since even rooted devices may have that path unprivileged)
At the end of the day, you can't. A rooted device may be modified in any way, and thus can completely hide whatever it wants from you. In practice you could look at some of the standard root builds to find features they have or characteristics you can look at... but there is no way to guarantee that whatever you do will actually detect a "rooted" device.
you could try to do
Process proc = Runtime.getRuntime ().exec ( "su" );
if that throws an exception or proc is null then they don't have root
精彩评论