Accessing raw partition in Android using Java
<p>I have a partition in Android that's not mounted because it doesn't have a file system, and I need to write a string into it.  I tried three different methods, and only the first (from adb) works.  I need to do this under program control, which is what the second and third methods do, but both fail.  I tried adding system permissions to my app, but that didn't help.  Do I need root permission to do this from a program?</p>

<p><strong>First Method -</strong></p>

<pre><code>adb shell "echo test &gt; /cache/command"
adb shell dd if=/cache/command of=/dev/block/mmcblk3p3 bs=4096 seek=1
</code></pre>

<p><strong>Second Method -</strong></p>

<pre><code>java.lang.Process p = Runtime.getRuntime().exec(
"dd if=/cache/command of=/dev/block/mmcblk3p3 bs=4096 seek=1");
</code></pre>

<p><strong>Third Method -</strong> </p>

<pre><code>File fileName = new File("/dev/block/mmcblk3p3");
String cmd = "test";
FileOutputStream fos = new FileOutputStream(fileName);
fos.write(cmd.getBytes(), 4096, cmd.length());
fos.flush();
</code></pre>

<p>The second method gives no feedback, even though it failed to work.  The third method gives the following output:</p>

<pre><code>W/System.err( 1014): java.io.FileNotFoundException: 
/dev/block/mmcblk3p3 (Permission denied)
</code></pre>
