title: Understanding command through adb shell and through code - Android
body: <p>I am trying to give <code>BATTERSTATS</code> permission to an app. When I run the command from a PC - it works just fine:</p>
  
  <pre><code>adb shell pm grant com.example.sample.myapplication android.permission.BATTERY_STATS
  </code></pre>
  
  <p>But the same <code>pm grant</code> command does not work when run from Android app:</p>
  
  <pre><code>java.lang.Process process = Runtime.getRuntime().exec("pm grant com.example.sample.myapplication android.permission.BATTERY_STATS");
  </code></pre>
  
  <p>Does it require root permission to give this permission?
  If it is so, why it does not require the device to be rooted to run it via <code>adb shell</code>?</p>
  
  <p>I am new to Android, please explain a bit more clearly what is happening inside and how to proceed. </p>