Possible Duplicate:
How to restrict Android device to not open some specific site e.g.youtube, facebook
I am developing an application where a feature is to stop users to use YouTube or facebook while they are using the application. By some finding I came to know that I have to edit /etc/hosts …. but how … thats what I want to know…
some one told me to make entries in this file to restrict specific websites but for that I need root privileges.
There is no way to edit the /etc/hosts files from application code (code that is installed from the market or on a device that hasn’t been rooted).
If the device has been rooted then you could just
suand then write new data to it, but on a production device you won’t have the necessary permission.EDIT: what may make more sense (and I don’t know how easy/difficult this will be in practice) is to use a custom DNS server that resolves IP addresses you want to ban. If you log in with
adb shellyou can run getprop which will list all the parameters. Find the DNS parameters and then do setprop {dns parameter name} {new dns ip} where you point to a dns server you control.