title: Getting EACCES (Permission denied) when tried to modify the file /sys/class/power_supply/battery/capacity in android device
body: <p>I have a requirement to change the battery level of an android device,with my app. So I tried modifying the "capacity" file in " /sys/class/power_supply/battery/" directory.
  But when ran the code I see the following error:</p>
  
  <p><strong>java.io.FileNotFoundException: /sys/class/power_supply/battery/capacity: open failed: EACCES (Permission denied)</strong></p>
  
  <p>Below is the code which I tried with to edit the file.</p>
  
  <pre><code>Runtime.getRuntime().exec("sh /system/xbin/su");
  FileWriter fw= new FileWriter(new File("/sys/class/power_supply/battery/capacity"));
  fw.write("45");
  fw.close();
  </code></pre>
  
  <p>Here is the Manifest file:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test_app.qa"&gt;
  
  &lt;application android:allowBackup="true" android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher" android:theme="@style/AppTheme"&gt;
  
  &lt;/application&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_SETTINGS"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM"/&gt;
  &lt;uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /&gt;
  &lt;uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/&gt;
  &lt;instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
      android:label="test"
      android:targetPackage="com.test_app.module"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>Can anyone suggest me with a way to modify the file</p>