migueljuan
migueljuan

Reputation: 477

How can I determine the files system type of external storage in Android?

I'm writing an application that writes a file to a USB flash drive (via USB OTG), which will then be removed from the phone and used elsewhere (which only supports FAT32). I need to be able to determine if the external storage is formatted correctly, and if not, I need to tell the user.

If I connect a FAT32 formatted drive, calling mount on the android shell only indicates "fuse" as the file system:

/dev/fuse /storage/usbotg fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

Is there a way to determine the filesystem, either via command line or programatically?

Upvotes: 0

Views: 2528

Answers (1)

fechidal89
fechidal89

Reputation: 723

you get list of mount command:

ArrayList<String> listMount = new ArrayList<String>();
Process p=null;

    try {
         p = Runtime.getRuntime().exec("mount");
         BufferedReader in2 = new BufferedReader(new InputStreamReader(p.getInputStream()));
         String line;
         while ((line = in2.readLine()) != null) {  
            listMount.add(line);
         }
    } catch (Exception e) {
         // manage exception
    }

In listMount have the output of mount. Search your /dev and check that this is vfat (filesystem FAT or FAT32). if only see 'fuse' I believe android only recognizes your devices USB OTG and not the final USB.

fuse is used for mount other filesystem type like NTFS.

Upvotes: 1

Related Questions