Android File Path Get getDrive(File file)

Here you can find the source of getDrive(File file)

Description

get Drive

Declaration

public static File getDrive(File file) 

Method Source Code

//package com.java2s;
import java.io.File;

public class Main {
    public static File getDrive(File file) {
        File drive = null;/*from  w  ww.ja va2s .c om*/
        for (File dr : File.listRoots()) {
            if (file.getAbsolutePath().toLowerCase()
                    .startsWith(dr.getAbsolutePath().toLowerCase())) {
                drive = dr;
                break;
            }
        }
        return drive;
    }
}

Related

  1. getCanonicalFile(File file)
  2. getPathLastIndex(String fileName)
  3. getPathLastIndex(String fileName, int fromIndex)
  4. getRoot(File file)