Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing the Dhcp and dns cache of android

Tags:

android

ip

dns

Is there way to clear the dns cache of android device pogrammatically??.I search lot on google but didnt find anything regarding this.

like image 557
greenfxpips.com Avatar asked Mar 12 '13 14:03

greenfxpips.com


1 Answers

As root, do in a shell:

ndc resolver flushdefaultif

And if you want to do it programatically, try this piece of code:

    public boolean reboot() {
    Process proc = null;
    try {
        proc = Runtime.getRuntime().exec("su");
        proc.getOutputStream().write(("ndc resolver flushdefaultif").getBytes());
        return proc.waitFor() == 0;
    } catch (IOException e) {
        e.printStackTrace();
    }
    catch (InterruptedException e) {
        e.printStackTrace();
    }

    return false;
}
like image 183
Henrique de Sousa Avatar answered Oct 03 '22 22:10

Henrique de Sousa