views:

64

answers:

2

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)

A: 

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

Ryan Conrad
A: 

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.

hackbod
is that mean a rooted device can also make below code:Process proc = Runtime.getRuntime ().exec ( "su" );fail?
jclova