當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。