How to edit a hosts file in Android

OK, back to questions, finally. A longtime reader asked me how to edit a hosts file in Android, which is an old trick in Windows.
Editing a hosts file is really two questions: Do you really want to edit it, or do you want to replace it?

If you want to edit it, the answer, as usual, is a cliché: There’s an app for that. Root the device–I’ll talk about that tomorrow–search the Play store for “hosts,” and try the various editors to see which one you like the most.

If you want to replace it, the easiest way to do so is to download the file using a computer–a good one to use is http://www.malwaredomainlist.com/hostslist/hosts.txt, which will block access to many sites known to be hosting malware–rename the file to “hosts” with no extension, write it to your SD card (either by putting the SD card into a PC, or by plugging the device into a USB port), then use a file manager such as ES File Explorer to copy the downloaded file over /system/etc/hosts. Again, you have to be root. When you go to overwrite the existing hosts file, the device will prompt you for root access.

If you edit the file on your computer before writing it to your Android device, be sure to use a text editor that will leave the line breaks in Unix format.

One thought on “How to edit a hosts file in Android

  • October 31, 2013 at 11:45 am
    Permalink

    Ahh, thank you Dave! I was about ready to start, ahem, rooting around the internet to learn how to root my device and replace the hosts file with the one on my Windows machines which has been carefully compiled after years of work. Why you ask? Why root the devices? To get rid of the ads! The ads alone are annoying, but the amount of data in them probably exceeds that in the pages themselves! If you pay per Mb, that, ahem, adds up rather quickly.

    As I understand it, rooting is generic process of replacing the devices ROM with one of your own.
    How do you know which or whose replacement ROM to pick?

Comments are closed.

%d bloggers like this:
WordPress Appliance - Powered by TurnKey Linux