I'm developing an app that backup the wifi configuration from any android device (rooted) so I want to know how to get the file location in the android device so can I deal with it.
I know there is a lot of location depending on your ROM or device
like /data/wifi/bcm_supp.conf
or /data/misc/wifi/wpa_supplicant.conf
but I want to get it dynamically .
The settings database is located at /data/data/com. android. providers. settings/databases/settings.
Users can find these details in two steps: Click Start, Settings, Network & Internet, and then select the Wi-Fi entry on the left list. Click the Advanced options entry below the last wireless network in the list. The wireless network's Properties will be listed at the bottom of the Wireless Network Connection page.
Wi-Fi is a Wireless Local Area Network (WLAN) used to exchange data wirelessly over a computer network. The PwrPak7, SMART7-I, SMART7-SI and SMART7-W have a Wi-Fi transceiver that works as a 2.4 GHz 802.11 Access Point (AP). On startup, the receiver automatically configures itself as an AP.
You need to create a 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 Wi-Fi manager settings:
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
wifiManager.add(conf);
And finally, you might need to enable it, so Android connects 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;
}
}
In case of WEP, if your password is in hex, you do not need to surround it with quotation marks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With