android.os.StatFs

Here are the examples of the java api class android.os.StatFs taken from open source projects.

1. NativeHelper#getInstallPathFreeMegaBytes()

Project: lildebi
File: NativeHelper.java
public static long getInstallPathFreeMegaBytes() {
    String path;
    StatFs stat;
    long freeSizeInBytes;
    File parent = new File(image_path).getParentFile();
    try {
        path = parent.getCanonicalPath();
    } catch (IOException e) {
        e.printStackTrace();
        path = parent.getAbsolutePath();
    }
    stat = new StatFs(path);
    freeSizeInBytes = stat.getAvailableBlocks() * (long) stat.getBlockSize();
    return freeSizeInBytes / 1024 / 1024;
}

2. SketchUtils#getTotalBytes()

Project: Sketch
File: SketchUtils.java
/**
     * ??????????
     */
@SuppressWarnings("unused")
public static long getTotalBytes(File dir) {
    if (!dir.exists() && !dir.mkdirs()) {
        return 0;
    }
    StatFs dirStatFs = new StatFs(dir.getPath());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return dirStatFs.getTotalBytes();
    } else {
        return (long) dirStatFs.getBlockCount() * dirStatFs.getBlockSize();
    }
}

3. RootToolsInternalMethods#hasEnoughSpaceOnSdCard()

Project: RedEnvelopeAssistant
File: RootToolsInternalMethods.java
/**
     * Checks if there is enough Space on SDCard
     *
     * @param updateSize size to Check (long)
     * @return <code>true</code> if the Update will fit on SDCard, <code>false</code> if not enough
     * space on SDCard. Will also return <code>false</code>, if the SDCard is not mounted as
     * read/write
     */
public boolean hasEnoughSpaceOnSdCard(long updateSize) {
    RootTools.log("Checking SDcard size and that it is mounted as RW");
    String status = Environment.getExternalStorageState();
    if (!status.equals(Environment.MEDIA_MOUNTED)) {
        return false;
    }
    File path = Environment.getExternalStorageDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return (updateSize < availableBlocks * blockSize);
}

4. StorageHelper#getSize()

Project: Omni-Notes
File: StorageHelper.java
/**
     * Returns a directory size in bytes
     */
@SuppressWarnings("deprecation")
public static long getSize(File directory) {
    StatFs statFs = new StatFs(directory.getAbsolutePath());
    long blockSize = 0;
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            blockSize = statFs.getBlockSizeLong();
        } else {
            blockSize = statFs.getBlockSize();
        }
    // Can't understand why on some devices this fails
    } catch (NoSuchMethodError e) {
        Log.e(Constants.TAG, "Mysterious error", e);
    }
    return getSize(directory, blockSize);
}

5. VDUtility#getSDCardRemainCanWrite()

Project: NewsMe
File: VDUtility.java
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public static boolean getSDCardRemainCanWrite(Context context, long remainSize) {
    String path = getSDCardDataPath(context);
    StatFs statFS = new StatFs(path);
    long blockSize = 0L;
    if (getSDKInt() >= 18) {
        blockSize = statFS.getBlockCountLong();
    } else {
        blockSize = statFS.getBlockSize();
    }
    long availableBlock = 0L;
    if (getSDKInt() >= 18) {
        availableBlock = statFS.getAvailableBlocksLong();
    } else {
        availableBlock = statFS.getAvailableBlocks();
    }
    long size = blockSize * availableBlock;
    if (size > remainSize) {
        return true;
    }
    return false;
}

6. AndroidUtil#getAvailableCacheSlots()

Project: mapsforge
File: AndroidUtil.java
/**
     * Get the number of tiles that can be stored on the file system.
     *
     * @param directory where the cache will reside
     * @param fileSize  average size of tile to be cached
     * @return number of tiles that can be stored without running out of space
     */
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static long getAvailableCacheSlots(String directory, int fileSize) {
    StatFs statfs = new StatFs(directory);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return statfs.getAvailableBytes() / fileSize;
    }
    // problem is overflow with devices with large storage, so order is important here
    // additionally avoid division by zero in devices with a large block size
    int blocksPerFile = Math.max(fileSize / statfs.getBlockSize(), 1);
    return statfs.getAvailableBlocks() / blocksPerFile;
}

7. StatFsHelper#getAvailableStorageSpace()

Project: fresco
File: StatFsHelper.java
/**
   * Gets the information about the available storage space
   * either internal or external depends on the give input
   * @param storageType Internal or external storage type
   * @return available space in bytes, 0 if no information is available
   */
@SuppressLint("DeprecatedMethod")
public long getAvailableStorageSpace(StorageType storageType) {
    ensureInitialized();
    maybeUpdateStats();
    StatFs statFS = storageType == StorageType.INTERNAL ? mInternalStatFs : mExternalStatFs;
    if (statFS != null) {
        long blockSize, availableBlocks;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            blockSize = statFS.getBlockSizeLong();
            availableBlocks = statFS.getAvailableBlocksLong();
        } else {
            blockSize = statFS.getBlockSize();
            availableBlocks = statFS.getAvailableBlocks();
        }
        return blockSize * availableBlocks;
    }
    return 0;
}

8. FileDownloadUtils#getFreeSpaceBytes()

Project: FileDownloader
File: FileDownloadUtils.java
public static long getFreeSpaceBytes(final String path) {
    long freeSpaceBytes;
    final StatFs statFs = new StatFs(path);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        freeSpaceBytes = statFs.getAvailableBytes();
    } else {
        //noinspection deprecation
        freeSpaceBytes = statFs.getAvailableBlocks() * (long) statFs.getBlockSize();
    }
    return freeSpaceBytes;
}

9. EasyMemoryMod#getTotalInternalMemorySize()

Project: easydeviceinfo
File: EasyMemoryMod.java
/**
   * Gets total internal memory size.
   *
   * @return the total internal memory size
   */
public long getTotalInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize;
    long totalBlocks;
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
        blockSize = stat.getBlockSizeLong();
        totalBlocks = stat.getBlockCountLong();
    } else {
        blockSize = stat.getBlockSize();
        totalBlocks = stat.getBlockCount();
    }
    return (totalBlocks * blockSize) / (1024 * 1024);
}

10. EasyMemoryMod#getAvailableInternalMemorySize()

Project: easydeviceinfo
File: EasyMemoryMod.java
/**
   * Gets available internal memory size.
   *
   * @return the available internal memory size
   */
public long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize;
    long availableBlocks;
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
        blockSize = stat.getBlockSizeLong();
        availableBlocks = stat.getAvailableBlocksLong();
    } else {
        blockSize = stat.getBlockSize();
        availableBlocks = stat.getAvailableBlocks();
    }
    return (availableBlocks * blockSize) / (1024 * 1024);
}

11. StorageUtils#getFreeSpaceAvailable()

Project: AntennaPod
File: StorageUtils.java
/**
     * Get the number of free bytes that are available on the external storage.
     */
public static long getFreeSpaceAvailable(String path) {
    StatFs stat = new StatFs(path);
    long availableBlocks;
    long blockSize;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        availableBlocks = stat.getAvailableBlocksLong();
        blockSize = stat.getBlockSizeLong();
    } else {
        availableBlocks = stat.getAvailableBlocks();
        blockSize = stat.getBlockSize();
    }
    return availableBlocks * blockSize;
}

12. AbstractDiskStorage#getUsedSpace()

Project: android-simple-storage
File: AbstractDiskStorage.java
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
@Override
public long getUsedSpace(SizeUnit sizeUnit) {
    String path = buildAbsolutePath();
    StatFs statFs = new StatFs(path);
    long availableBlocks;
    long blockSize;
    long totalBlocks;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        availableBlocks = statFs.getAvailableBlocks();
        blockSize = statFs.getBlockSize();
        totalBlocks = statFs.getBlockCount();
    } else {
        availableBlocks = statFs.getAvailableBlocksLong();
        blockSize = statFs.getBlockSizeLong();
        totalBlocks = statFs.getBlockCountLong();
    }
    long usedBytes = totalBlocks * blockSize - availableBlocks * blockSize;
    return usedBytes / sizeUnit.inBytes();
}

13. AbstractDiskStorage#getFreeSpace()

Project: android-simple-storage
File: AbstractDiskStorage.java
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
@Override
public long getFreeSpace(SizeUnit sizeUnit) {
    String path = buildAbsolutePath();
    StatFs statFs = new StatFs(path);
    long availableBlocks;
    long blockSize;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        availableBlocks = statFs.getAvailableBlocks();
        blockSize = statFs.getBlockSize();
    } else {
        availableBlocks = statFs.getAvailableBlocksLong();
        blockSize = statFs.getBlockSizeLong();
    }
    long freeBytes = availableBlocks * blockSize;
    return freeBytes / sizeUnit.inBytes();
}

14. RootToolsInternalMethods#hasEnoughSpaceOnSdCard()

Project: android-autostarts
File: RootToolsInternalMethods.java
/**
     * Checks if there is enough Space on SDCard
     *
     * @param updateSize size to Check (long)
     * @return <code>true</code> if the Update will fit on SDCard, <code>false</code> if not enough
     * space on SDCard. Will also return <code>false</code>, if the SDCard is not mounted as
     * read/write
     */
public boolean hasEnoughSpaceOnSdCard(long updateSize) {
    RootTools.log("Checking SDcard size and that it is mounted as RW");
    String status = Environment.getExternalStorageState();
    if (!status.equals(Environment.MEDIA_MOUNTED)) {
        return false;
    }
    File path = Environment.getExternalStorageDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return (updateSize < availableBlocks * blockSize);
}

15. RootToolsInternalMethods#hasEnoughSpaceOnSdCard()

Project: afwall
File: RootToolsInternalMethods.java
/**
     * Checks if there is enough Space on SDCard
     *
     * @param updateSize size to Check (long)
     * @return <code>true</code> if the Update will fit on SDCard, <code>false</code> if not enough
     *         space on SDCard. Will also return <code>false</code>, if the SDCard is not mounted as
     *         read/write
     */
public boolean hasEnoughSpaceOnSdCard(long updateSize) {
    RootTools.log("Checking SDcard size and that it is mounted as RW");
    String status = Environment.getExternalStorageState();
    if (!status.equals(Environment.MEDIA_MOUNTED)) {
        return false;
    }
    File path = Environment.getExternalStorageDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return (updateSize < availableBlocks * blockSize);
}

16. ReportUtils#getTotalInternalMemorySize()

Project: acra
File: ReportUtils.java
/**
     * Calculates the total memory of the device. This is based on an inspection of the filesystem, which in android
     * devices is stored in RAM.
     *
     * @return Total number of bytes.
     */
public static long getTotalInternalMemorySize() {
    final File path = Environment.getDataDirectory();
    final StatFs stat = new StatFs(path.getPath());
    final long blockSize;
    final long totalBlocks;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        blockSize = stat.getBlockSizeLong();
        totalBlocks = stat.getBlockCountLong();
    } else {
        //noinspection deprecation
        blockSize = stat.getBlockSize();
        //noinspection deprecation
        totalBlocks = stat.getBlockCount();
    }
    return totalBlocks * blockSize;
}

17. ReportUtils#getAvailableInternalMemorySize()

Project: acra
File: ReportUtils.java
/**
     * Calculates the free memory of the device. This is based on an inspection of the filesystem, which in android
     * devices is stored in RAM.
     *
     * @return Number of bytes available.
     */
public static long getAvailableInternalMemorySize() {
    final File path = Environment.getDataDirectory();
    final StatFs stat = new StatFs(path.getPath());
    final long blockSize;
    final long availableBlocks;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        blockSize = stat.getBlockSizeLong();
        availableBlocks = stat.getAvailableBlocksLong();
    } else {
        //noinspection deprecation
        blockSize = stat.getBlockSize();
        //noinspection deprecation
        availableBlocks = stat.getAvailableBlocks();
    }
    return availableBlocks * blockSize;
}

18. Utils#getUsableSpace()

Project: volley
File: Utils.java
/**
     * Check how much usable space is available at a given path.
     * 
     * @param path
     *            The path to check
     * @return The space available in bytes
     */
@SuppressWarnings("deprecation")
@TargetApi(9)
public static long getUsableSpace(File path) {
    if (Utils.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

19. Util#getUsableSpace()

Project: Ushahidi_Android
File: Util.java
/**
     * Check how much usable space is available at a given path.
     * 
     * @param path The path to check
     * @return The space available in bytes
     */
@SuppressLint("NewApi")
public static long getUsableSpace(File path) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

20. DeviceUtils#getAllSize()

Project: ToolsFinal
File: DeviceUtils.java
/**
     * ??SD??
     * @return
     */
public static long getAllSize() {
    if (!existSDCard()) {
        return 0l;
    }
    File path = Environment.getExternalStorageDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getBlockCount();
    return availableBlocks * blockSize;
}

21. DeviceUtils#getAvailaleSize()

Project: ToolsFinal
File: DeviceUtils.java
/**
     * ????????
     * @return
     */
public static long getAvailaleSize() {
    if (!existSDCard()) {
        return 0l;
    }
    //??sdcard????
    File path = Environment.getExternalStorageDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

22. SketchUtils#getAvailableBytes()

Project: Sketch
File: SketchUtils.java
/**
     * ???????????
     */
public static long getAvailableBytes(File dir) {
    if (!dir.exists() && !dir.mkdirs()) {
        return 0;
    }
    StatFs dirStatFs = new StatFs(dir.getPath());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return dirStatFs.getAvailableBytes();
    } else {
        return (long) dirStatFs.getAvailableBlocks() * dirStatFs.getBlockSize();
    }
}

23. ImageCache#getUsableSpace()

Project: RoMote
File: ImageCache.java
/**
     * Check how much usable space is available at a given path.
     *
     * @param path The path to check
     * @return The space available in bytes
     */
@TargetApi(VERSION_CODES.GINGERBREAD)
public static long getUsableSpace(File path) {
    if (Utils.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

24. General#isCacheDiskFull()

Project: RedReader
File: General.java
public static boolean isCacheDiskFull(final Context context) {
    final StatFs stat = new StatFs(getBestCacheDir(context).getPath());
    return (long) stat.getBlockSize() * (long) stat.getAvailableBlocks() < 128 * 1024 * 1024;
}

25. StorageUtils#getTotalInternalMemorySize()

Project: popcorn-android-legacy
File: StorageUtils.java
/**
     * @return Total internal memory
     */
public static int getTotalInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    int blockSize = stat.getBlockSize();
    int totalBlocks = stat.getBlockCount();
    return totalBlocks * blockSize;
}

26. StorageUtils#getAvailableInternalMemorySize()

Project: popcorn-android-legacy
File: StorageUtils.java
/**
     * @return Available internal memory
     */
public static int getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    int blockSize = stat.getBlockSize();
    int availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

27. AndroidUtil#getAvailableInternalRomSize()

Project: NewsMe
File: AndroidUtil.java
public static long getAvailableInternalRomSize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long totalBlocks = stat.getBlockCount();
    long availBlocks = stat.getAvailableBlocks();
    return availBlocks * blockSize;
}

28. Utils#getUsableSpace()

Project: mobile-android
File: Utils.java
/**
     * Check how much usable space is available at a given path.
     * 
     * @param path The path to check
     * @return The space available in bytes
     */
@SuppressLint("NewApi")
public static long getUsableSpace(File path) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

29. MizLib#getFreeMemory()

Project: Mizuu
File: MizLib.java
@SuppressWarnings("deprecation")
public static long getFreeMemory() {
    StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
    if (hasJellyBeanMR2())
        return stat.getAvailableBlocksLong() * stat.getBlockSizeLong();
    else
        return stat.getAvailableBlocks() * stat.getBlockSize();
}

30. RemoteImageView#freeSpaceOnSd()

Project: jamendo-android
File: RemoteImageView.java
private int freeSpaceOnSd() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    double sdFreeMB = ((double) stat.getAvailableBlocks() * (double) stat.getBlockSize()) / MB;
    return (int) sdFreeMB;
}

31. FileUtils#getFreeBytes()

Project: GanWuMei
File: FileUtils.java
/**
     * ???????????????????????byte
     *
     * @return ???? SDCard?????????????
     */
public static long getFreeBytes(String filePath) {
    // ???sd??????????sd?????
    if (filePath.startsWith(getSDCardPath())) {
        filePath = getSDCardPath();
    } else {
        // ???????????????????????
        filePath = Environment.getDataDirectory().getAbsolutePath();
    }
    StatFs stat = new StatFs(filePath);
    long availableBlocks = (long) stat.getAvailableBlocks() - 4;
    return stat.getBlockSize() * availableBlocks;
}

32. TransferManager#getCurrentMountAvailableBytes()

Project: frostwire-android
File: TransferManager.java
static long getCurrentMountAvailableBytes() {
    StatFs stat = new StatFs(ConfigurationManager.instance().getStoragePath());
    return ((long) stat.getBlockSize() * (long) stat.getAvailableBlocks());
}

33. SystemUtil#getFreeDiskSize()

Project: CtsVerifier
File: SystemUtil.java
public static long getFreeDiskSize(Context context) {
    StatFs statFs = new StatFs(context.getFilesDir().getAbsolutePath());
    return (long) statFs.getAvailableBlocks() * statFs.getBlockSize();
}

34. DirectoryManager#freeSpaceCalculation()

Project: crosswalk-cordova-android
File: DirectoryManager.java
/**
     * Given a path return the number of free KB
     * 
     * @param path to the file system
     * @return free space in KB
     */
private static long freeSpaceCalculation(String path) {
    StatFs stat = new StatFs(path);
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize / 1024;
}

35. DirectoryManager#freeSpaceCalculation()

Project: cordova-android-chromeview
File: DirectoryManager.java
/**
     * Given a path return the number of free KB
     * 
     * @param path to the file system
     * @return free space in KB
     */
private static long freeSpaceCalculation(String path) {
    StatFs stat = new StatFs(path);
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize / 1024;
}

36. DirectoryManager#freeSpaceCalculation()

Project: cordova-amazon-fireos
File: DirectoryManager.java
/**
     * Given a path return the number of free KB
     * 
     * @param path to the file system
     * @return free space in KB
     */
private static long freeSpaceCalculation(String path) {
    StatFs stat = new StatFs(path);
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize / 1024;
}

37. WelcomeActivity#enoughSpaceInInternalStorage()

Project: ChatSecureAndroid
File: WelcomeActivity.java
private static boolean enoughSpaceInInternalStorage(File f) {
    StatFs stat = new StatFs(f.getParent());
    long freeSizeInBytes = stat.getAvailableBlocks() * (long) stat.getBlockSize();
    // 512 MB
    return freeSizeInBytes > 536870912;
}

38. SystemLib#getMemoryInternalAvail()

Project: Cafe
File: SystemLib.java
/**
     * get available internal memory
     * 
     * @return byte value, can be formated to string by formatSize(long size)
     *         function<br/>
     *         e.g. 135553024
     */
public long getMemoryInternalAvail() {
    StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

39. CustomExceptionHandler#getTotalInternalMemorySize()

Project: Anki-Android
File: CustomExceptionHandler.java
private long getTotalInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long totalBlocks = stat.getBlockCount();
    return totalBlocks * blockSize;
}

40. CustomExceptionHandler#getAvailableInternalMemorySize()

Project: Anki-Android
File: CustomExceptionHandler.java
private long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

41. Utils#readSystemAvailableSize()

Project: android_tv_metro
File: Utils.java
public static long readSystemAvailableSize() {
    String path = "/data";
    StatFs sf = new StatFs(path);
    long blockSize = sf.getBlockSize();
    Log.d("block size", "block size: " + blockSize);
    //long blockCount = sf.getBlockCount();
    //Log.d("available count", "available count: " + sf.getAvailableBlocks());
    long availCount = sf.getAvailableBlocks();
    Log.d("available count", "available count: " + availCount);
    return blockSize * availCount / 1024;
}

42. Utils#readSystemAvailableSize()

Project: android_tv_metro
File: Utils.java
public static long readSystemAvailableSize() {
    String path = "/data";
    StatFs sf = new StatFs(path);
    long blockSize = sf.getBlockSize();
    Log.d("block size", "block size: " + blockSize);
    //long blockCount = sf.getBlockCount();
    //Log.d("available count", "available count: " + sf.getAvailableBlocks());
    long availCount = sf.getAvailableBlocks();
    Log.d("available count", "available count: " + availCount);
    return blockSize * availCount / 1024;
}

43. SDUtil#getFreeBytes()

Project: AndroidStudyDemo
File: SDUtil.java
/**
     * ???????????????????????byte
     *
     * @param filePath
     * @return ???? SDCard?????????????
     */
public static long getFreeBytes(String filePath) {
    // ???sd??????????sd?????
    if (filePath.startsWith(getSDCardPath())) {
        filePath = getSDCardPath();
    } else {
        // ???????????????????????
        filePath = Environment.getDataDirectory().getAbsolutePath();
    }
    StatFs stat = new StatFs(filePath);
    long availableBlocks = (long) stat.getAvailableBlocks() - 4;
    return stat.getBlockSize() * availableBlocks;
}

44. system#getTotalInternalDataSize()

Project: AndroidQuickUtils
File: system.java
/**
     * @return The total storage in MegaBytes
     */
@SuppressWarnings("deprecation")
public static Long getTotalInternalDataSize() {
    StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
    long size = (long) stat.getBlockCount() * (long) stat.getBlockSize();
    return size / sdcard.BYTES_TO_MB;
}

45. system#getAvailableInternalDataSize()

Project: AndroidQuickUtils
File: system.java
/**
     * @return The available storage in MegaBytes
     */
@SuppressWarnings("deprecation")
public static Long getAvailableInternalDataSize() {
    StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
    long size = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
    return size / sdcard.BYTES_TO_MB;
}

46. IOUtils#getUsableSpace()

Project: androidkit
File: IOUtils.java
/**
	 * ??????????
	 * 
	 * @param path
	 * @return ???????????
	 */
public static long getUsableSpace(File path) {
    final StatFs sf = new StatFs(path.getPath());
    return (long) sf.getBlockSize() * (long) sf.getAvailableBlocks();
}

47. CacheCommonUtil#getUsableSpace()

Project: androidkit
File: CacheCommonUtil.java
/**
	 * ????????????????
	 * 
	 * @param path
	 *            ??????
	 * @return ??????????????
	 */
public static long getUsableSpace(File path) {
    final StatFs stats = new StatFs(path.getPath());
    return stats.getBlockCount() * stats.getAvailableBlocks();
}

48. ImageCache#getUsableSpace()

Project: AndroidDynamicLoader
File: ImageCache.java
/**
     * Check how much usable space is available at a given path.
     *
     * @param path The path to check
     * @return The space available in bytes
     */
@TargetApi(9)
public static long getUsableSpace(File path) {
    if (Utils.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

49. ImportUtilities#freePercentage()

Project: android-xbmcremote
File: ImportUtilities.java
/**
     * Returns free space in percent.
     * @return Free space in percent.
     */
public static double freePercentage() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    long availableBlocks = stat.getAvailableBlocks();
    long totalBlocks = stat.getBlockCount();
    return (double) availableBlocks / (double) totalBlocks * 100;
}

50. ImportUtilities#totalSpace()

Project: android-xbmcremote
File: ImportUtilities.java
/**
     * Returns total size of SD card in bytes.
     * @return Total size of SD card in bytes.
     */
public static long totalSpace() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    long blockSize = stat.getBlockSize();
    long totalBlocks = stat.getBlockCount();
    return totalBlocks * blockSize;
}

51. ImportUtilities#freeSpace()

Project: android-xbmcremote
File: ImportUtilities.java
/**
     * Returns number of free bytes on the SD card.
     * @return Number of free bytes on the SD card.
     */
public static long freeSpace() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

52. Utilities#getFreeSpaceInternal()

Project: Android-Remote
File: Utilities.java
/**
     * Get the free space on the internal storage device
     *
     * @return The free space in byte
     */
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static double getFreeSpaceInternal() {
    StatFs stat = new StatFs(App.getApp().getFilesDir().getPath());
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return (double) stat.getAvailableBlocks() * (double) stat.getBlockSize();
    } else {
        return (double) stat.getAvailableBlocksLong() * (double) stat.getBlockSizeLong();
    }
}

53. Utilities#getFreeSpaceExternal()

Project: Android-Remote
File: Utilities.java
/**
     * Get the free space on the external storage device (like sd card)
     *
     * @return The free space in byte
     */
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static double getFreeSpaceExternal() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return (double) stat.getAvailableBlocks() * (double) stat.getBlockSize();
    } else {
        return (double) stat.getAvailableBlocksLong() * (double) stat.getBlockSizeLong();
    }
}

54. AndroidUtils#getFreeSpace()

Project: Android-Next
File: AndroidUtils.java
@SuppressWarnings("deprecation")
public static long getFreeSpace() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

55. ImageLoader#getUsableSpace()

Project: android-art-res
File: ImageLoader.java
@TargetApi(VERSION_CODES.GINGERBREAD)
private long getUsableSpace(File path) {
    if (Build.VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

56. CommonUtil#getRealSizeOnPhone()

Project: android-app
File: CommonUtil.java
/**
	 * get the space is left over on phone self
	 */
public static long getRealSizeOnPhone() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    long realSize = blockSize * availableBlocks;
    return realSize;
}

57. CommonUtil#getRealSizeOnSdcard()

Project: android-app
File: CommonUtil.java
/**
	 * get the space is left over on sdcard
	 */
public static long getRealSizeOnSdcard() {
    File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

58. ClassLoadFromBundle#getAvailableInternalMemorySize()

Project: ACDD
File: ClassLoadFromBundle.java
private static long getAvailableInternalMemorySize() {
    StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
    return ((long) statFs.getAvailableBlocks()) * ((long) statFs.getBlockSize());
}

59. BundlesInstaller#getAvailableSize()

Project: ACDD
File: BundlesInstaller.java
private long getAvailableSize() {
    StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
    return ((long) statFs.getAvailableBlocks()) * ((long) statFs.getBlockSize());
}