1
任何人都可以通过android应用程序以编程方式帮助我在Android设备中读取/data/misc/wifi/wpa_supplicant.conf
文件。如何阅读wpa_supplicant.conf文件
我试过下面的代码来读取存储在wpa_supplicant.conf
文件中的信息并在textview中显示信息,但它什么都不返回。
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什么都不显示。
感谢replay..i会尝试这个.. – user3278265
@Junyong我写的授予超级用户access.i'v尝试这种代码的应用程序,但我得到许可被拒绝:/数据/其它/ WIFI /的wpa_supplicant .conf:打开失败:EACCES(权限被拒绝)。有没有解决方法? –