i have the following function which should to return content of the wpa_supplicant.conf file.
I tried read file by this way:
public static String readTextFile() {
aBuffer = "";
try
{
Runtime.getRuntime().exec("su");
Runtime.getRuntime().exec("chmod +x /data/misc/wifi/wpa_supplicant.conf");
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 = "";
aBuffer = "";
while ((aDataRow = myReader.readLine()) != null) {
aBuffer += aDataRow + "\n";
}
myReader.close();
}
catch (Exception e)
{
Logger.e("Cannot read the file");
Logger.e(e.getMessage());
}
return aBuffer;
}
And i added into manifest file too:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
But when i trying to read the content of the file placed in the:
/data/misc/wifi/wpa_supplicant.conf
I always get the following exception:
/data/misc/wifi/wpa_supplicant.conf: open failed: EACCES (Permission denied)
Should i use instead of the inputStream Output stred of the shell command? Fxp:
tail /data/misc/wifi/wpa_supplicant.conf
How can i solve this issue please?
Many thanks for any advice.