In a nutshell when an Android device is rooted the system security and safeguards cannot be guaranteed. That's why we created RootBeer an open source root checking library for app developers to help verifying the integrity of the device.
However the RootBeer library by no means perfect it gives an indication of root and what you do with the information is up to you. Of course no root detection code can ever been 100% effective as when the user is root they are basically god on the device.
The project is hosted on github - https://github.com/scottyab/rootbeer/