Writing files to system directory


Last Updated:

  1. Swiftwork

    Swiftwork New Member This Topic's Starter

    Joined:
    Jan 21, 2010
    Messages:
    3
    Likes Received:
    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 (Text):
    1.  
    2.        try {
    3.             [URL="http://www.google.com/search?hl=en&q=allinurl%3ARuntime+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]Runtime[/URL].getRuntime().exec("su");
    4.             [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;
    5.             [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/");
    6.             if (root.canWrite()){
    7.                 [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");
    8.                 boolean append = true;
    9.                         [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);
    10.                 [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);
    11.                
    12.                 out.write("network");
    13.                 out.flush();
    14.                 out.close();
    15.                 } catch ([URL="http://www.google.com/search?hl=en&q=allinurl%3AIOException+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]IOException[/URL] e) {
    16.         }
    17.  
    But i get no output. My phone is rooted so that is not the issue. Any suggestions?
     

    Advertisement
  2. hayaku

    hayaku New Member

    Joined:
    Feb 10, 2010
    Messages:
    4
    Likes Received:
    0
    /system filesystem probably was mounted as read only. you will need to remount to write to it if that's the case
     
  3. hayaku

    hayaku New Member

    Joined:
    Feb 10, 2010
    Messages:
    4
    Likes Received:
    0
    also, you should output the exception so you can see what it's complaining about
     

Share This Page

Loading...