Example usage for android.os Environment getRootDirectory

List of usage examples for android.os Environment getRootDirectory

Introduction

In this page you can find the example usage for android.os Environment getRootDirectory.

Prototype

public static File getRootDirectory() 

Source Link

Document

Return root of the "system" partition holding the core Android OS.

Usage

From source file:com.codename1.impl.android.AndroidImplementation.java

/**
 * @inheritDoc/*from  w ww  .  j ava 2  s . c o m*/
 */
public String[] listFilesystemRoots() {

    if (!checkForPermission(Manifest.permission.READ_EXTERNAL_STORAGE,
            "This is required to browse the file system")) {
        return new String[] {};
    }

    String[] storageDirs = getStorageDirectories();
    if (storageDirs != null) {
        String[] roots = new String[storageDirs.length + 1];
        System.arraycopy(storageDirs, 0, roots, 0, storageDirs.length);
        roots[roots.length - 1] = addFile(Environment.getRootDirectory().getAbsolutePath());
        return roots;
    }
    return new String[] { addFile(Environment.getRootDirectory().getAbsolutePath()) };
}