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


Java StatFs.getBlockCountLong方法代码示例

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


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

示例1: getSDcardTotalSize

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获取手机SD卡总空间
 *
 * @return
 */
private static long getSDcardTotalSize()
{

    if (checkSdCard())
    {
        File path = Environment.getExternalStorageDirectory();
        StatFs mStatFs = new StatFs(path.getPath());
        long blockSizeLong = mStatFs.getBlockSizeLong();
        long blockCountLong = mStatFs.getBlockCountLong();

        return blockSizeLong * blockCountLong;
    } else
    {
        return 0;
    }
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:22,代码来源:CommonUtil.java

示例2: calculateDiskCacheSize

import android.os.StatFs; //导入方法依赖的package包/类
@TargetApi(JELLY_BEAN_MR2)
static long calculateDiskCacheSize(File dir) {
  long size = MIN_DISK_CACHE_SIZE;

  try {
    StatFs statFs = new StatFs(dir.getAbsolutePath());
    //noinspection deprecation
    long blockCount =
        SDK_INT < JELLY_BEAN_MR2 ? (long) statFs.getBlockCount() : statFs.getBlockCountLong();
    //noinspection deprecation
    long blockSize =
        SDK_INT < JELLY_BEAN_MR2 ? (long) statFs.getBlockSize() : statFs.getBlockSizeLong();
    long available = blockCount * blockSize;
    // Target 2% of the total space.
    size = available / 50;
  } catch (IllegalArgumentException ignored) {
  }

  // Bound inside min/max size for disk cache.
  return Math.max(Math.min(size, MAX_DISK_CACHE_SIZE), MIN_DISK_CACHE_SIZE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:Utils.java

示例3: getTotalStorageSpace

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * Gets the information about the total storage space,
 * 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 getTotalStorageSpace(StorageType storageType) {
  ensureInitialized();

  maybeUpdateStats();

  StatFs statFS = storageType == StorageType.INTERNAL ? mInternalStatFs : mExternalStatFs;
  if (statFS != null) {
    long blockSize, totalBlocks;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
      blockSize = statFS.getBlockSizeLong();
      totalBlocks = statFS.getBlockCountLong();
    } else {
      blockSize = statFS.getBlockSize();
      totalBlocks = statFS.getBlockCount();
    }
    return blockSize * totalBlocks;
  }
  return -1;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:StatFsHelper.java

示例4: 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

示例5: getSDCardSize

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获取SD卡全部内存空间大小
 *
 * @return
 */
public static long getSDCardSize() {
    long blockCount;
    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) {
            blockCount = statFs.getBlockCountLong();//有多少块
            blockSize = statFs.getBlockSizeLong();//每块有多大
        } else {
            blockCount = statFs.getBlockCount();//有多少块
            blockSize = statFs.getBlockSize();//每块有多大
        }

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

示例6: 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:angcyo,项目名称:RLibrary,代码行数:21,代码来源:SDCardUtils.java

示例7: calculateDiskCacheSize

import android.os.StatFs; //导入方法依赖的package包/类
private static long calculateDiskCacheSize(File dir) {
    long size = MIN_DISK_CACHE_SIZE;
    try {
        StatFs statFs = new StatFs(dir.getAbsolutePath());
        long available;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            available = statFs.getBlockCountLong() * statFs.getBlockSizeLong();
        } else {
            // checked at runtime
            //noinspection deprecation
            available = statFs.getBlockCount() * statFs.getBlockSize();
        }
        // Target 2% of the total space.
        size = available / 50;
    } catch (IllegalArgumentException ignored) {
    }
    // Bound inside min/max size for disk cache.
    return Math.max(Math.min(size, MAX_DISK_CACHE_SIZE), MIN_DISK_CACHE_SIZE);
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:20,代码来源:ProductionHttpClientFactory.java

示例8: getUsedSpace

import android.os.StatFs; //导入方法依赖的package包/类
@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();
}
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:22,代码来源:AbstractDiskStorage.java

示例9: getFreeSpace

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获得可用存储空间
 *
 * @return 可用存储空间(单位b)
 */
public long getFreeSpace() {
    File path = Environment.getExternalStorageDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize;//区块的大小
    long totalBlocks;//区块总数
    long availableBlocks;//可用区块的数量
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        blockSize = stat.getBlockSizeLong();
        totalBlocks = stat.getBlockCountLong();
        availableBlocks = stat.getAvailableBlocksLong();
    } else {
        blockSize = stat.getBlockSize();
        totalBlocks = stat.getBlockCount();
        availableBlocks = stat.getAvailableBlocks();
    }
    Log.e(TAG, "totalSpace:" + blockSize * totalBlocks + "...availableSpace:" + blockSize * availableBlocks);
    return blockSize * availableBlocks;
}
 
开发者ID:mChenys,项目名称:AndroidFFmpegCompress,代码行数:24,代码来源:MainActivity.java

示例10: getPhoneTotalSize

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获取手机内部存储总空间
 *
 * @return
 */
public static long getPhoneTotalSize()
{

    if (!checkSdCard())
    {
        File path = Environment.getDataDirectory();
        StatFs mStatFs = new StatFs(path.getPath());
        long blockSizeLong = mStatFs.getBlockSizeLong();
        long blockCountLong = mStatFs.getBlockCountLong();
        return blockSizeLong * blockCountLong;
    } else
        return getSDcardTotalSize();
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:19,代码来源:CommonUtil.java

示例11: 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

示例12: calculateDiskCacheSize

import android.os.StatFs; //导入方法依赖的package包/类
private static long calculateDiskCacheSize(File dir) {
    long size = 5242880L;

    try {
        StatFs statFs = new StatFs(dir.getAbsolutePath());
        long blockCount = Build.VERSION.SDK_INT < 18 ? (long) statFs.getBlockCount() : statFs.getBlockCountLong();
        long blockSize = Build.VERSION.SDK_INT < 18 ? (long) statFs.getBlockSize() : statFs.getBlockSizeLong();
        long available = blockCount * blockSize;
        size = available / 50L;
    } catch (IllegalArgumentException ignored) {

    }

    return Math.max(Math.min(size, 52428800L), 5242880L);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:16,代码来源:PicassoInstance.java

示例13: getSDcardTotalSize

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获取手机SD卡总空间
 */
private static long getSDcardTotalSize() {

  if (checkSdCard()) {
    File path = Environment.getExternalStorageDirectory();
    StatFs mStatFs = new StatFs(path.getPath());
    long blockSizeLong = mStatFs.getBlockSizeLong();
    long blockCountLong = mStatFs.getBlockCountLong();

    return blockSizeLong * blockCountLong;
  } else {
    return 0;
  }
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:17,代码来源:CommonUtil.java

示例14: getPhoneTotalSize

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * 获取手机内部存储总空间
 */
public static long getPhoneTotalSize() {

  if (!checkSdCard()) {
    File path = Environment.getDataDirectory();
    StatFs mStatFs = new StatFs(path.getPath());
    long blockSizeLong = mStatFs.getBlockSizeLong();
    long blockCountLong = mStatFs.getBlockCountLong();
    return blockSizeLong * blockCountLong;
  } else {
    return getSDcardTotalSize();
  }
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:16,代码来源:CommonUtil.java

示例15: getBlockCount

import android.os.StatFs; //导入方法依赖的package包/类
/**
 * See {@link android.os.StatFs#getBlockCount()}.
 */
@SuppressWarnings("deprecation")
public static long getBlockCount(StatFs statFs) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        return statFs.getBlockCountLong();
    } else {
        return statFs.getBlockCount();
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:12,代码来源:ApiCompatibilityUtils.java


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