linux - Getting sd card directory in Android device -


There are codes written below to retrieve the SD card directory. I am using the command execution and have changed to read / proc / mounts. My question is, is this the right code?

Would not the expert on Linux OS be the same as the / proc / mount path for all devices? I think this code will be free from any command injection possibilities.

  // process process = new process builder (). Command ("mount"). Start (); // process.waitFor (); Reader = New buffed reader (new flamerdder ("/ proc / mounts")); String line; While ((Line = Reader. Readline ()) = Null {// Output Output Mount Command Logger. Debug ("{}", from the Line); If (line.startsWith ("/ dev / block / vold /")) {string {] token = line.split (""); If (tokens.length & gt; = 3 & amp; amp; amp; (token [2] .equals ("vfat") | token [2] .equals ("exfat")) {string path = token [ 1]; File file = new file (path); If (file.exists () & File.isDirectory ()) {logger.debug ("SD card detected {}", file.getPath ()); If (! File.canWrite ()) {logger.warn ("SD card path {} is reporting that it is not writable", file.getPath ()); }                          return path;   
  can get the directory of the SD card on any device through the environment.  


Comments