As we all know we can block any websites from our computer using windows host files. If we are using wireless routers, then also we can block websites using routers, so we can prevent our children from accessing porn sites from their devices. But this is limited to wifi connection only, what if they activate a data plan on their mobile and start using such sites?
Well, you can edit & modify the android host files to block specific websites. You can monitor your child’s activity on android, to check which sites they browse most often. If you think the sites they are browsing are unsafe for your children, you can block that site using your computer by using the following tutorial.
Related: Block Ads on Android
Please note that the process requires a rooted phone. So you must root your device before you start the procedure. If you don’t know how to root your android device, just comment on your android device’s model number, name, and specification if any. We will write a tutorial on how to root your device here.
How to Modify Hosts File on Android:
This is the easiest way to edit the host’s file on your android device, you can use Android Debug Bridge(ADB). So set up & install the Android Debug Bridge Utility. Once you have done this, navigate into the folder where ADB is located and type cmd into the location bar, which will open a command prompt in the current folder.
Once the command prompt window opens, type “adb devices” without quotes to see what device is attached to your computer.
Now you will need to get the location of the Android Hosts file and download it so that you can modify it and add the sites that you want to get blocked on your android smartphone. Type the following command on the command prompt.
adb pull /system/etc/hosts F:\hosts
What the command does is, it will copy the android hosts file from system>etc>hosts and will copy it on your computer’s F drive.
Right-click on the host file copied in your F drive and open it with a notepad. Once it is opened, you will see the notepad file as shown in the image with some entries. Here you will add as many sites as you want.
Suppose you want to block the yahoo.com site, you will need to add 127.0.0.1 yahoo.com at the bottom. if you want to block thepiratebay , add another entry 127.0.0.1 thepiratebay.sx this way, when the user types thepiratebay.sx in the android device, it will be redirected to the local host and will not let the user browse that added site in that list.
You have modified the host file from your local drive of the computer. Now you will have to overwrite the hosts file on your android system>etc>hosts. So open the command prompt and type the following command to replace the old host file with a modified host file.
adb push F:\hosts /system/etc/
So it will transfer the file from the F drive of your computer and replace the old host’s file with the modified one.
See, we have blocked Facebook.com from the host’s file, so whenever a user will type facebook.com from the browser, it will not open.
You can also use the Hosts editor android app, which is available free on Google Play Store if you don’t want to edit it through your computer. You can easily modify your android’s host file using that host’s editor android app.