Android Utililty Methods File Path Get

List of utility methods to do File Path Get

Description

The list of methods to do File Path Get are organized into topic(s).

Method

FilegetCanonicalFile(File file)
Convert a file to canonical form.
try {
    return new File(file.getCanonicalPath());
} catch (IOException e) {
    Log.util.debug("Could not create canonical path for %s: %s",
            file, e);
    return file;
FilegetDrive(File file)
get Drive
File drive = null;
for (File dr : File.listRoots()) {
    if (file.getAbsolutePath().toLowerCase()
            .startsWith(dr.getAbsolutePath().toLowerCase())) {
        drive = dr;
        break;
return drive;
intgetPathLastIndex(String fileName)
get Path Last Index
int point = fileName.lastIndexOf('/');
if (point == -1) {
    point = fileName.lastIndexOf('\\');
return point;
intgetPathLastIndex(String fileName, int fromIndex)
get Path Last Index
int point = fileName.lastIndexOf('/', fromIndex);
if (point == -1) {
    point = fileName.lastIndexOf('\\', fromIndex);
return point;
FilegetRoot(File file)
Returns the filesystem root for file.
Check.arg().notNull(file);
if (!file.exists())
    throw new IllegalArgumentException("file = " + file.getPath()
            + " is a non-existent path");
file = file.getCanonicalFile(); 
for (File parent = file.getParentFile(); parent != null; parent = file
        .getParentFile()) {
    file = parent;
...