Search code examples
androidnetwork-programmingadbandroid-wifi

removing saved wifi network using adb command in rooted device


How can I remove the saved wi-fi network from my rooted android device?

I have tried copying the custom wpa_supplicant.conf file to /data/misc/wifi/

>adb push wpa_supplicant.conf /data/misc/wifi/wpa_supplicant.conf

The file copied successfully but it won't remove the saved wi-fi network.

I have following content in the custom wpa_supplicant.conf

ctrl_interface=/data/misc/wifi/sockets
disable_scan_offload=1
driver_param=use_p2p_group_interface=1p2p_device=1use_multi_chan_concurrent=1
update_config=1
device_name=Tablet
manufacturer=MSI
model_name=550-18900(MiniTouch)
model_number=550-18900(MiniTouch)
serial_number=0123456789ABCDEF
device_type=10-0050F204-5
config_methods=physical_display virtual_push_button
pmf=1
external_sim=1

I also tried removing wpa_supplicant.conf file. I also tried turning off wifi and then pushing custom wpa_supplicant.conf file. I am not able to a removed the saved wifi network.


Solution

  • I found the alternative way to remove the saved network from rooted device. This can be achieved using wpa_cli command.

    $adb shell wpa_cli list_networks
    //this will show the list like following
    network id / ssid / bssid / flags
    0       worldink_wifi        any     [CURRENT]
    //now you can remove the network using its network id
    

    Then you can remove network using

    $adb shell wpa_cli remove_network 0
    //0 is network id