title: Android: Write to /sys/ directory
body: <p>I'm developing an application that is not intended to be released as a standard app. It'll be run on a single rooted device.</p>
  
  <p>I require the ability to write to a file in the /sys/ directory. The file in question is owned by root and has -rw-rw-rw- permissions.</p>
  
  <p>I am aware that there may be restrictions on the VM my code runs within that prohibit writing to this area of the file system, but I have observed another application apparently do this.</p>
  
  <p>Is this possible? How might it be achieved? It doesn't matter if the phone needs to be rooted (the dev one I'm using is).</p>
  
  <hr>
  
  <p>I've looked into simply using a FileWriter to write to the file, causing the following error on <code>.flush()</code>:</p>
  
  <pre><code>java.io.IOException: Invalid argument
  at org.apache.harmony.luni.platform.OSFileSystem.writeImpl(Native Method)
  </code></pre>
  
  <p>I've also tried executing a shell command from Java, both with and without "su". Which returned "request rejected" and "Permission Denied" respectively.</p>
  
  <pre><code>Process process = Runtime.getRuntime().exec("echo 'hello' &gt; /sys/file");
  </code></pre>
  
  <p>Lastly I've tried using the NDK and JNI in case C some how magically managed to write to this file. When attempting to <code>fflush</code> to this file I receive an EOF (meaning an error has occured).</p>
  
  <hr>
  
  <p>All suggestions greatly welcome!</p>