当前位置: 首页>>代码示例>>Java>>正文


Java StatFs.getFreeBlocksLong方法代码示例

本文整理汇总了Java中android.os.StatFs.getFreeBlocksLong方法的典型用法代码示例。如果您正苦于以下问题:Java StatFs.getFreeBlocksLong方法的具体用法?Java StatFs.getFreeBlocksLong怎么用?Java StatFs.getFreeBlocksLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.StatFs的用法示例。


在下文中一共展示了StatFs.getFreeBlocksLong方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFreeStorageSpace

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * Gets the information about the free storage space, including reserved blocks,
 * either internal or external depends on the given input
 * @param storageType Internal or external storage type
 * @return available space in bytes, -1 if no information is available
 */
@SuppressLint("DeprecatedMethod")
public long getFreeStorageSpace(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.getFreeBlocksLong();
    } else {
      blockSize = statFS.getBlockSize();
      availableBlocks = statFS.getFreeBlocks();
    }
    return blockSize * availableBlocks;
  }
  return -1;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:StatFsHelper.java

示例2: getSDCardInfo

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获取SD卡信息
 *
 * @return SDCardInfo
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getSDCardInfo() {
    if (!isSDCardEnable()) return null;
    SDCardInfo sd = new SDCardInfo();
    sd.isExist = true;
    StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
    sd.totalBlocks = sf.getBlockCountLong();
    sd.blockByteSize = sf.getBlockSizeLong();
    sd.availableBlocks = sf.getAvailableBlocksLong();
    sd.availableBytes = sf.getAvailableBytes();
    sd.freeBlocks = sf.getFreeBlocksLong();
    sd.freeBytes = sf.getFreeBytes();
    sd.totalBytes = sf.getTotalBytes();
    return sd.toString();
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:21,代码来源:SDCardUtils.java

示例3: getSDCardFreeSize

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获取SD卡空闲空间大小(有多少空间还没被占用)
 *
 * @return
 */
public static long getSDCardFreeSize() {

    long freeBlockCount;
    long blockSize;

    if (isSDCardMounted()) {
        String dir = getSDCardBaseDir();
        //StatFs是从C语言引过来的
        StatFs statFs = new StatFs(dir);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            freeBlockCount = statFs.getFreeBlocksLong();//有多少块
            blockSize = statFs.getBlockSizeLong();//每块有多大
        } else {
            freeBlockCount = statFs.getFreeBlocks();//有多少块
            blockSize = statFs.getBlockSize();//每块有多大
        }


        return freeBlockCount * blockSize / 1024 / 1024; //总大小
    }
    return 0;
}
 
开发者ID:CodingCodersCode,项目名称:EvolvingNetLib,代码行数:29,代码来源:SDCardUtil.java

示例4: getSDCardInfo

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获取SD卡信息
 *
 * @return SDCardInfo
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getSDCardInfo() {
    SDCardInfo sd = new SDCardInfo();
    if (!isSDCardEnable()) return "sdcard unable!";
    sd.isExist = true;
    StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
    sd.totalBlocks = sf.getBlockCountLong();
    sd.blockByteSize = sf.getBlockSizeLong();
    sd.availableBlocks = sf.getAvailableBlocksLong();
    sd.availableBytes = sf.getAvailableBytes();
    sd.freeBlocks = sf.getFreeBlocksLong();
    sd.freeBytes = sf.getFreeBytes();
    sd.totalBytes = sf.getTotalBytes();
    return sd.toString();
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:21,代码来源:SDCardUtils.java

示例5: getSDCardInfo

import android.os.StatFs; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getSDCardInfo() {
    if (!isSDCardEnable()) return null;
    SDCardInfo sd = new SDCardInfo();
    sd.isExist = true;
    StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
    sd.totalBlocks = sf.getBlockCountLong();
    sd.blockByteSize = sf.getBlockSizeLong();
    sd.availableBlocks = sf.getAvailableBlocksLong();
    sd.availableBytes = sf.getAvailableBytes();
    sd.freeBlocks = sf.getFreeBlocksLong();
    sd.freeBytes = sf.getFreeBytes();
    sd.totalBytes = sf.getTotalBytes();
    return sd.toString();
}
 
开发者ID:ChangsenLai,项目名称:codedemos,代码行数:16,代码来源:SDCardUtil.java

示例6: getSDCardInfo

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * Get SD card info detail.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static SDCardInfo getSDCardInfo() {
    SDCardInfo sd = new SDCardInfo();
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        sd.isExist = true;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            File sdcardDir = Environment.getExternalStorageDirectory();
            StatFs sf = new StatFs(sdcardDir.getPath());

            sd.totalBlocks = sf.getBlockCountLong();
            sd.blockByteSize = sf.getBlockSizeLong();

            sd.availableBlocks = sf.getAvailableBlocksLong();
            sd.availableBytes = sf.getAvailableBytes();

            sd.freeBlocks = sf.getFreeBlocksLong();
            sd.freeBytes = sf.getFreeBytes();

            sd.totalBytes = sf.getTotalBytes();
        }
    }
    if (Log.isPrint) {
        Log.i(TAG, sd.toString());
    }
    return sd;
}
 
开发者ID:androidDaniel,项目名称:treasure,代码行数:31,代码来源:SdCardUtil.java

示例7: getSDCardInfo

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * Get SD card info detail.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static SDCardInfo getSDCardInfo() {
    SDCardInfo sd = new SDCardInfo();
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        sd.isExist = true;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            File sdcardDir = Environment.getExternalStorageDirectory();
            StatFs sf = new StatFs(sdcardDir.getPath());

            sd.totalBlocks = sf.getBlockCountLong();
            sd.blockByteSize = sf.getBlockSizeLong();

            sd.availableBlocks = sf.getAvailableBlocksLong();
            sd.availableBytes = sf.getAvailableBytes();

            sd.freeBlocks = sf.getFreeBlocksLong();
            sd.freeBytes = sf.getFreeBytes();

            sd.totalBytes = sf.getTotalBytes();
        }
    }

        Log.i(TAG, sd.toString());

    return sd;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:31,代码来源:SdCardUtil.java

示例8: getFreeSpaceSize

import android.os.StatFs; //导入方法依赖的package包/类
public static Long getFreeSpaceSize(StatFs statFs) {
    long freeSpaceSize = 0;
    try {
        if (VERSION.SDK_INT >= 18) {
            freeSpaceSize = statFs.getFreeBlocksLong() * statFs.getBlockSizeLong();
        } else {
            freeSpaceSize = ((long) statFs.getFreeBlocks()) * ((long) statFs.getBlockSize());
        }
    } catch (Throwable e) {
        LOG.w(TAG, "getScreenHeightWidth failed(Throwable): " + e.getMessage());
    }
    return Long.valueOf(freeSpaceSize);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:14,代码来源:SDKUtils.java


注:本文中的android.os.StatFs.getFreeBlocksLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。