I need to do it for security testing purpose of an app. I have a rooted emulator which runs 7.1.1, It is rooted, I changed hosts file by using echo command, root file explorer, adb push and every else way I could. But it doesn't reflect in my chrome or any other browser. I looked into chrome's local DNS cache, I cleared it, still doesn't work. I added new entry like
(one space and new line at end)
But after entering facebook.com, I don't get website of xx.yy.zz.aa instead I get genuine one. I have tried all the previous answers but it doesn't work, surprisingly what works is when I put 127.0.0.1 i.e localhost instead of any other websites in place of ip. Then it routes to localhost. I very much need to route genuine website to ip I choose for testing my security jars works or not.
Is there any way to achieve this, if not in chrome any other browser. Or is there any way to disable global DNS and use local DNS only.
Help appreciated very much.
PS : hosts file gets changed successfully. Old answers don't work anymore