title: How to know if fsck is running?
body: <p>My Android app needs to store 15 GB of data, so it needs to use <a href="https://commonsware.com/blog/2014/04/09/storage-situation-removable-storage.html" rel="nofollow">removable storage</a>. So I need to check if fsck is running while my app is loading (to quit if that is the case). Of course I can do a </p>
  
  <pre><code>Runtime.getRuntime().exec("ps");
  </code></pre>
  
  <p>but I have read that this solution is not reliable... So I tried with</p>
  
  <pre><code>ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  for (RunningAppProcessInfo tasks : manager.getRunningAppProcesses()) {
       System.out.println(" ########## " + tasks.processName + " #######");
  }
  </code></pre>
  
  <p>but I don't see any <code>fsck</code>. Actually, using <code>ps</code> I see it as being executed as</p>
  
  <pre><code>/system/bin/fsck.exfat -R -f /dev/...
  </code></pre>
  
  <p>Is the only way using <code>Runtime.getRuntime().exec("ps")</code>?</p>
  
  <p>Thanks!</p>
  
  <p>L.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The command <code>Environment.getExternalStorageState()</code> does not work for me. After unmounting/mounting the SD card, with the code below, I get AT THE SAME TIME, <code>MOUNTED</code> and <code>/system/bin/fsck.exfat -R -f /dev/...</code></p>
  
  <pre><code>String line;
  BufferedReader br;
  try {
      br = new BufferedReader(new InputStreamReader( Runtime.getRuntime().exec("ps").getInputStream()));
      while ((line = br.readLine()) != null) {
      if (line.contains("/fsck")) 
          System.out.println("### PS:" + Environment.getExternalStorageState() + " ### " +line);
  } catch (IOException e1) {
       e1.printStackTrace();
  }
  </code></pre>
  
  <p>This is the output I get:</p>
  
  <pre><code>PS:mounted ### root  [...] D /system/bin/fsck.exfat /dev/...
  </code></pre>