android - how to read wpa_supplicant.conf file -
can me read /data/misc/wifi/wpa_supplicant.conf
file in android device through android app programmatically.
i tried below code read information stored in wpa_supplicant.conf
file , display information in textview.but 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.
please make sure have remount partition. otherwise, have no permission read / write here.
you can try following before further operation on folder.
runtime.getruntime().exec("system/bin/mount -o rw,remount -t rootfs /data"); runtime.getruntime().exec("system/bin/chmod 777 /data/misc/wifi");
Comments
Post a Comment