title: writing dumpstate to file android
body: <p>I need the bugreport option that you can use in adb to go to a file on the sd in my app. I found <a href="https://stackoverflow.com/questions/6257557/android-using-execbugreport">Android; using exec(&quot;bugreport&quot;)</a> that explains that you can not run bugreport in the regular shell and that you need to run dumpstate, dumpsys, and logcat separately to get the same result. That is fine and I understand that, but I can not get dumpstate or dumpsys to write to the file. The below works fine to write the logcat using logcat -d -f, but does not work for the other two. I have tried dumpstate -f , dumpstate -d -f  and dumpstate > to get it work, but still does not write anything to the file. Is there something I am missing to make this work?<br>
  This is where I am creating the file on the sd</p>
  
  <pre><code>File folder = new File(Environment.getExternalStorageDirectory()+"/IssueReport/");
      if (folder.isDirectory() == false) {
          folder.mkdir();
      }
      log = new File(Environment.getExternalStorageDirectory()+"/IssueReport/log.txt");
  </code></pre>
  
  <p>and here is where I am writing the file to the location</p>
  
  <pre><code>private void submit() {
      try {
         log.createNewFile(); 
         String cmd = "dumpstate "+log.getAbsolutePath();
         Runtime.getRuntime().exec(cmd);
      } catch (IOException e) {
      e.printStackTrace();
      }
  </code></pre>