• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Writing files to system directory

Swiftwork

Lurker
Jan 21, 2010
3
0
Hello Devs,
I am trying to write data to a system file located in /data/misc/wifi/wpa_suppant.conf using this code.

Code:
       try {
            [URL="http://www.google.com/search?hl=en&q=allinurl%3ARuntime+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]Runtime[/URL].getRuntime().exec("su");
            [URL="http://www.google.com/search?hl=en&q=allinurl%3AFile+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]File[/URL] root = [URL="http://www.google.com/search?hl=en&q=allinurl%3AEnvironment+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]Environment[/URL].getExternalStorageDirectory;
            [URL="http://www.google.com/search?hl=en&q=allinurl%3AFile+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]File[/URL] root = new [URL="http://www.google.com/search?hl=en&q=allinurl%3AFile+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]File[/URL]("/data/misc/wifi/");
            if (root.canWrite()){
                [URL="http://www.google.com/search?hl=en&q=allinurl%3AFile+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]File[/URL] textFile = new [URL="http://www.google.com/search?hl=en&q=allinurl%3AFile+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]File[/URL](root + "wpa_supplicant.conf");
                boolean append = true;
                        [URL="http://www.google.com/search?hl=en&q=allinurl%3AFileWriter+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]FileWriter[/URL] textWriter = new [URL="http://www.google.com/search?hl=en&q=allinurl%3AFileWriter+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]FileWriter[/URL](textFile, append);
                [URL="http://www.google.com/search?hl=en&q=allinurl%3ABufferedWriter+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]BufferedWriter[/URL] out = new [URL="http://www.google.com/search?hl=en&q=allinurl%3ABufferedWriter+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]BufferedWriter[/URL](textWriter);
                
                out.write("network");
                out.flush();
                out.close();
                } catch ([URL="http://www.google.com/search?hl=en&q=allinurl%3AIOException+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]IOException[/URL] e) {
        }
But i get no output. My phone is rooted so that is not the issue. Any suggestions?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones