Reputation: 11
Can anyone help me to read /data/misc/wifi/wpa_supplicant.conf
file in android device through android app programmatically.
I tried the below code to read information stored in wpa_supplicant.conf
file and display information in a textview.but it returns nothing.
try
{
Process psProc = Runtime.getRuntime().exec(new String[]{"su","-c"});//root
File path=Environment.getDataDirectory();
File myFile = new File("/data/misc/wifi/wpa_supplicant.conf");
FileInputStream fIn = new FileInputStream(myFile);
BufferedReader myReader = new BufferedReader(
new InputStreamReader(fIn));
String aDataRow = "";
String aBuffer = "";
while ((aDataRow = myReader.readLine()) != null) {
aBuffer += aDataRow + "\n";
}
tv.setText(aBuffer);
myReader.close();
Toast.makeText(getBaseContext(),"Done reading SD 'TextAreaAppender.java'",
Toast.LENGTH_SHORT).show();
}
catch (Exception e)
{
Toast.makeText(getBaseContext(), e.getMessage(),Toast.LENGTH_LONG).show();
tv.setText(e.getMessage());
}
Textview displays nothing.
Upvotes: 1
Views: 4917
Reputation: 11
Please make sure you have remount the partition. Otherwise, you have no permission to read / write here.
You can try following before further operation on that folder.
Runtime.getRuntime().exec("system/bin/mount -o rw,remount -t rootfs /data");
Runtime.getRuntime().exec("system/bin/chmod 777 /data/misc/wifi");
Upvotes: 1