Android Utililty Methods Directory Size Get

List of utility methods to do Directory Size Get

Description

The list of methods to do Directory Size Get are organized into topic(s).

Method

longfolderSize(File directory)
folder Size
long length = 0L;
if (directory != null) {
    File[] files = directory.listFiles();
    if (files == null) {
        return 0L;
    File[] arrayOfFile1;
    int j = (arrayOfFile1 = files).length;
...
longgetDirLength(File dir)
get Dir Length
if (dir.isFile())
    throw new IOException("BadInputException: not a directory.");
long size = 0;
File[] files = dir.listFiles();
if (files != null) {
    for (int i = 0; i < files.length; i++) {
        File file = files[i];
        long length = 0;
...
longsizeOfDirectory(File directory)
size Of Directory
if (!directory.exists()) {
    String message = directory + " does not exist";
    throw new IllegalArgumentException(message);
if (!directory.isDirectory()) {
    String message = directory + " is not a directory";
    throw new IllegalArgumentException(message);
long size = 0;
File[] files = directory.listFiles();
if (files == null) { 
    return 0L;
for (File file : files) {
    size += sizeOf(file);
return size;
longsizeOf(File spec)
Gets the size of a file or directory, in bytes.
long size = 0;
if (spec.isDirectory()) {
    String[] children = spec.list();
    for (int i = 0; i < children.length; i++) {
        size += sizeOf(new File(spec, children[i]));
} else {
    size = spec.length();
...
longgetDirectorySize(File f)
get Directory Size
if (f == null || !f.exists() || !f.isDirectory()) {
    return 0;
long size = 0;
File[] flist = f.listFiles();
if (flist != null) {
    for (int i = 0; i < flist.length; i++) {
        if (flist[i].isDirectory()) {
...