Originally Posted by carbonyle
Thanks for this How-TO!
So basicaly that mean we can restrict acces to certain websites from our phone?
eg: adding this line
and I'll no longer be able to browse XDA from my phone?
Keep writing such How-To, like this one and the one to sign update.zip, I found this interessant and usefull
*BRIEF EXPLANATION OF HOSTS FILE FOR Non-technical folks* aka HOSTS 101
You are basically telling your phone (same works on your computer, FYI), that for a specific address, go to a specific location. We point it to 127.0.0.1 (this is a standard computer setting that is commonly known as localhost - it's defined as the device itself) as it is the most simple but you can also point things elsewhere. 126.96.36.199 and 192.168.1.1 will both work as well. You can't just put 0, you have to put all 4 parts of the numerical (IP) address. as in xxx.xxx.xxx.xxx. (you know, like 192.168.1.1 or whatever your IP is at whatismyip.com).
You're not really defining a site though, you're more defining everything that connects to that address. So you're not really blocking an ad specifically, you're blocking where the ad is downloaded aka that specific website/server. The list is huge because there are tons of sites that post ads, and lots of them have multiple names. Meanwhile, since it's a just a text list having a huge list doesn't affect your performance at all unless you had about 10-50 times more sites than the current host file has, which is like 20 thousand. So with maybe 200 thousand to 5 million, it might affect it - but that's super unlikely to be necessary. Remember, you already have a host list, we're just modifying it. This affects any connections on your device, not just the browser. Applications that say "open this website" will basically check the hosts file first, as well. So that's how you can block admob, etc. Remember, sites pay money monthly to have an address that you can go to over the net, so these kinds of things don't change that often and adding another 1 or 2 is not a difficult matter.
For those who want to, you can also make a specific word go to a location as well. You could add for example google = 188.8.131.52 . This would mean you don't need to add www or .com at the end, that merely typing google and pressing go would send the device to google.com. Considering we have bookmarks anyway, this is useless on a pc but probably more useful on a phone. When you do this without putting it in your host file, you get to google anyway, but it takes longer. Reason is that your phone does a search for the word/words you're looking for and then either takes you to the site or takes you to google search results for that word.