Edit your android hosts file the easy way.
I needed to edit the hosts file on my Nexus 5 so I could test a non-existent domain I use for development. The problem? File permissions. The solution? A free hosts editor app.
by Scot Ranney • September 07, 2016
This is going to be a short article because editing your hosts file on an Android device such as LG's Nexus 5 (rock solid awesome smart phone) is super quick and super easy. No ADB, no manual file permissions, nothing difficult.
The only requirement: your device must be rooted.*
Step 1 to editing your Android hosts file: install an app called Hosts Editor by Nilhcem.
Step 2: Open the app and update your Android hosts file.
In my case I needed to spoof my dev site, scotsscripts.smr.com, and once I added the IP address and the domain into the hosts list, it worked. No fuss, no mess, no hassle, it just plain worked.
*How to root your Android device: I used Chainfire's one-click rooting utility with great success.
For windows, I ran root-windows.bat
and moments later my phone was rooted. This method is much easier than going into ADB and doing everything by hand.
Note: you are responsible for anything that happens to your phone. I had good results with Chainfire but there is no guarantee anyone else will. Always back up your phone before doing ANYTHING like this!