Is there way to clear the dns cache of android device pogrammatically??.I search lot on google but didnt find anything regarding this.
Asked
Active
Viewed 1.0k times
6
-
http://stackoverflow.com/questions/2101762/android-flush-dns – Daniel Mar 12 '13 at 14:49
-
sorry my bad I forgot to add word programmatically in my question – greenfxpips.com Mar 12 '13 at 15:10
1 Answers
1
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;
}

Henrique de Sousa
- 5,727
- 49
- 55
-
1On Android 4.3, at least, you can open an `adb shell` console, and give the command `ndc resolver flushdefaultif` which will be shown as "command succeeded" (while `ndc resolver flushdefault` is "500 0 Resolver unknown command") ... and when you ping your dynamic server from an `adb shell` again, it will still fail. – Jon Shemitz Feb 25 '14 at 21:34