#FridayHacks-How To Get Android Wifi Configuration File Location in Android

Android is an open source and Linux-based operating system for mobile devices such as smartphones and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies.
This tutorial will teach you basic on how to get the wifi configuration file location in android and will also take you through some advance concepts related to Android application development.

You need to create WifiConfiguration instance like this:

String networkSSID = "test";
String networkPass = "pass";

WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\"";   //
Then, for WEP network you need to do this:

conf.wepKeys[0] = "\"" + networkPass + "\"";
conf.wepTxKeyIndex = 0;
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);

For WPA network you need to add passphrase like this:

conf.preSharedKey = "\""+ networkPass +"\"";

For Open network you need to do this:

 conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);

Then, you need to add it to Android wifi manager settings:

WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
wifiManager.add(conf);

  And finally, you might need to enable it, so Android conntects to it:

   List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
 for( WifiConfiguration i : list ) {
  if(i.SSID != null && i.SSID.equals("\"" + networkSSID + "\"")) {
     wm.disconnect();
     wm.enableNetwork(i.networkId, true);
     wm.reconnect();

     break;
  }
}

 UPD: In case of WEP, if your password is in hex, you do not need to surround it wit

Leave a Reply

Your email address will not be published. Required fields are marked *