content: package com.aditya.filebrowser.fileoperations;
  
  import android.util.Log;
  
  import com.aditya.filebrowser.Constants;
  
  import java.io.BufferedReader;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.HashSet;
  import java.util.List;
  import java.util.StringTokenizer;
  
  public class GetRemovableDevice {
  
      private static final String TAG = "StorageUtils";
  
      public static class StorageInfo {
  
          public final String path;
          public final boolean internal;
          public final boolean readonly;
          public final int display_number;
  
          StorageInfo(String path, boolean internal, boolean readonly, int display_number) {
              this.path = path;
              this.internal = internal;
              this.readonly = readonly;
              this.display_number = display_number;
          }
  
          public String getDisplayName() {
              StringBuilder res = new StringBuilder();
              if (internal) {
                  res.append(Constants.INTERNALSTORAGE);
              } else if (display_number > 1) {
                  res.append(Constants.EXTERNALSTORAGE + display_number);
              } else {
                  res.append(Constants.EXTERNALSTORAGE);
              }
              if (readonly) {
                  res.append(" (Read only)");
              }
              return res.toString();
          }
      }
  
      public static List<StorageInfo> getStorageList() {
  
          List<StorageInfo> list = new ArrayList<StorageInfo>();
          BufferedReader buf_reader = null;
          try {
              HashSet<String> paths = new HashSet<String>();
              buf_reader = new BufferedReader(new FileReader("/proc/mounts"));
              String line;
              int cur_display_number = 1;
              Log.d(TAG, "/proc/mounts");
              while ((line = buf_reader.readLine()) != null) {
                  Log.d(TAG, line);
                  if (line.contains("vfat") || line.contains("/mnt")) {
                      StringTokenizer tokens = new StringTokenizer(line, " ");
                      String unused = tokens.nextToken(); //device
                      String mount_point = tokens.nextToken(); //mount point
                      if (paths.contains(mount_point)) {
                          continue;
                      }
                      unused = tokens.nextToken(); //file system
                      List<String> flags = Arrays.asList(tokens.nextToken().split(",")); //flags
                      boolean readonly = flags.contains("ro");
  
                       if (line.contains("/dev/block/vold")) {
                          if (!line.contains("/mnt/secure")
                                  && !line.contains("/mnt/asec")
                                  && !line.contains("/mnt/obb")
                                  && !line.contains("/dev/mapper")
                                  && !line.contains("tmpfs")) {
                              paths.add(mount_point);
                              list.add(new StorageInfo(mount_point, false, readonly, cur_display_number++));
                          }
                      }
                  }
              }
  
          } catch (FileNotFoundException ex) {
              ex.printStackTrace();
          } catch (IOException ex) {
              ex.printStackTrace();
          } finally {
              if (buf_reader != null) {
                  try {
                      buf_reader.close();
                  } catch (IOException ex) {}
              }
          }
          return list;
      }
  }