Java Code Examples for android.os.Environment.getRootDirectory()

The following are Jave code examples for showing how to use getRootDirectory() of the android.os.Environment class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: easyfilemanager   File: ExternalStorageProvider.java   View Source Code Vote up 6 votes
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    synchronized (mRootsLock) {
        for (RootInfo root : mRoots.values()) {
            final RowBuilder row = result.newRow();
            row.add(Root.COLUMN_ROOT_ID, root.rootId);
            row.add(Root.COLUMN_FLAGS, root.flags);
            row.add(Root.COLUMN_TITLE, root.title);
            row.add(Root.COLUMN_DOCUMENT_ID, root.docId);
            row.add(Root.COLUMN_PATH, root.path);
            if(ROOT_ID_PRIMARY_EMULATED.equals(root.rootId)
                    || root.rootId.startsWith(ROOT_ID_SECONDARY)
                    || root.rootId.startsWith(ROOT_ID_PHONE)) {
                final File file = root.rootId.startsWith(ROOT_ID_PHONE)
                        ? Environment.getRootDirectory() : root.path;
                row.add(Root.COLUMN_AVAILABLE_BYTES, file.getFreeSpace());
                row.add(Root.COLUMN_CAPACITY_BYTES, file.getTotalSpace());
            }
        }
    }
    return result;
}
 
Example 2
Project: simple-share-android   File: ExternalStorageProvider.java   View Source Code Vote up 6 votes
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    synchronized (mRootsLock) {
        for (RootInfo root : mRoots.values()) {
            final RowBuilder row = result.newRow();
            row.add(Root.COLUMN_ROOT_ID, root.rootId);
            row.add(Root.COLUMN_FLAGS, root.flags);
            row.add(Root.COLUMN_TITLE, root.title);
            row.add(Root.COLUMN_DOCUMENT_ID, root.docId);
            row.add(Root.COLUMN_PATH, root.path);
            if(ROOT_ID_PRIMARY_EMULATED.equals(root.rootId)
                    || root.rootId.startsWith(ROOT_ID_SECONDARY)
                    || root.rootId.startsWith(ROOT_ID_PHONE)) {
                final File file = root.rootId.startsWith(ROOT_ID_PHONE)
                        ? Environment.getRootDirectory() : root.path;
                row.add(Root.COLUMN_AVAILABLE_BYTES, file.getFreeSpace());
                row.add(Root.COLUMN_CAPACITY_BYTES, file.getTotalSpace());
            }
        }
    }
    return result;
}
 
Example 3
Project: FireFiles   File: ExternalStorageProvider.java   View Source Code Vote up 5 votes
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    synchronized (mRootsLock) {
        for (RootInfo root : mRoots.values()) {
            final RowBuilder row = result.newRow();
            row.add(Root.COLUMN_ROOT_ID, root.rootId);
            row.add(Root.COLUMN_FLAGS, root.flags);
            row.add(Root.COLUMN_TITLE, root.title);
            row.add(Root.COLUMN_DOCUMENT_ID, root.docId);
            row.add(Root.COLUMN_PATH, root.path);
            if(ROOT_ID_PRIMARY_EMULATED.equals(root.rootId)
                    || root.rootId.startsWith(ROOT_ID_SECONDARY)
                    || root.rootId.startsWith(ROOT_ID_PHONE)) {
                final File file = root.rootId.startsWith(ROOT_ID_PHONE)
                        ? Environment.getRootDirectory() : root.path;
                row.add(Root.COLUMN_AVAILABLE_BYTES, file.getFreeSpace());
                row.add(Root.COLUMN_CAPACITY_BYTES, file.getTotalSpace());
            }
        }
    }
    return result;
}