RootBeer Sample APP
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/