My Android app needs to store 15 GB of data, so it needs to use removable storage. 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
Runtime.getRuntime().exec("ps");
but I have read that this solution is not reliable... So I tried with
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
for (RunningAppProcessInfo tasks : manager.getRunningAppProcesses()) {
System.out.println(" ########## " + tasks.processName + " #######");
}
but I don't see any fsck
. Actually, using ps
I see it as being executed as
/system/bin/fsck.exfat -R -f /dev/...
Is the only way using Runtime.getRuntime().exec("ps")
?
Thanks!
L.
EDIT
The command Environment.getExternalStorageState()
does not work for me. After unmounting/mounting the SD card, with the code below, I get AT THE SAME TIME, MOUNTED
and /system/bin/fsck.exfat -R -f /dev/...
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();
}
This is the output I get:
PS:mounted ### root [...] D /system/bin/fsck.exfat /dev/...