delete Other Networks - Android android.net.wifi

Android examples for android.net.wifi:WifiManager

Description

delete Other Networks

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.util.Log;
import java.net.InetAddress;
import java.util.List;

public class Main{

    public static void deleteOtherNetworks(WifiManager wifiManager,
            int networkId) {
        // Delete all other configs
        List<WifiConfiguration> configuredNetworks = wifiManager
                .getConfiguredNetworks();
        for (WifiConfiguration conf : configuredNetworks) {
            if (conf.networkId != networkId) {
                wifiManager.removeNetwork(conf.networkId);
            }/*from  w  w w. ja v  a  2 s  .c o m*/
        }
    }

}

Related Tutorials