Example usage for android.os StatFs getBlockCount

List of usage examples for android.os StatFs getBlockCount

Introduction

In this page you can find the example usage for android.os StatFs getBlockCount.

Prototype

@Deprecated
public int getBlockCount() 

Source Link

Usage

From source file:com.atwal.wakeup.battery.util.Utilities.java

public static long getTotalExternalMemorySize() {
    if (externalMemoryAvailable()) {
        File path = Environment.getExternalStorageDirectory();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long totalBlocks = stat.getBlockCount();
        return totalBlocks * blockSize;
    } else {/*from  w  w  w.  j  a  v a2 s. c o m*/
        return 0;
    }
}

From source file:com.doomy.padlock.InfoFragment.java

/**
  * Gets total internal memory size./*from w w  w.ja v a 2 s. co m*/
  *
  * @return The total size of internal storage.
  */
public String getTotalInternalMemorySize() {
    File mPath = Environment.getDataDirectory();
    StatFs mStat = new StatFs(mPath.getPath());
    long mBlockSize = mStat.getBlockSize();
    long mTotalBlocks = mStat.getBlockCount();
    return Formatter.formatFileSize(getActivity(), mTotalBlocks * mBlockSize);
}

From source file:com.fallahpoor.infocenter.fragments.StorageFragment.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private String getInternalTotal() {

    long size;/*from  ww  w  . j  a  v  a2  s .com*/
    StatFs internalStatFs = new StatFs(Environment.getDataDirectory().getAbsolutePath());

    if (mIsApiAtLeast18) {
        size = internalStatFs.getTotalBytes();
    } else {
        size = (long) internalStatFs.getBlockCount() * (long) internalStatFs.getBlockSize();
    }

    return Utils.getFormattedSize(size);

}

From source file:rus.cpuinfo.AndroidDepedentModel.DevInfo.java

@NonNull
@SuppressLint("NewApi")
private String getInternalStorage() {

    StatFs statFs = new StatFs(Environment.getDataDirectory().getAbsolutePath());

    final long blockCount = VersionUtil.IS_JELLY_BEAN_MR2()
            ? statFs.getBlockCountLong() * statFs.getBlockSizeLong()
            : statFs.getBlockCount() * statFs.getBlockSize();

    // return String.format(Locale.getDefault(),"%s",blockCount);
    return formatFileSize(getContext(), blockCount);

}

From source file:com.wso2.mobile.mdm.api.DeviceInfo.java

/**
*Returns the total internal memory size/*from   ww  w.ja v a 2 s .co  m*/
*/
public double getTotalInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    double blockSize = stat.getBlockSize();
    double totalBlocks = stat.getBlockCount();
    return formatSizeGB(totalBlocks * blockSize);
}

From source file:eu.mhutti1.utils.storage.StorageDevice.java

public Long getTotalBytes() {
    StatFs statFs = new StatFs((mFile.getPath()));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return statFs.getBlockSizeLong() * statFs.getBlockCountLong();
    } else {//from   ww  w  .jav a  2s  .c om
        return (long) statFs.getBlockSize() * (long) statFs.getBlockCount();
    }
}

From source file:com.wso2.mobile.mdm.api.DeviceInfo.java

/**
*Returns the total external memory size//from   w  w w . j ava2s  . c  o m
*/
public double getTotalExternalMemorySize() {
    if (externalMemoryAvailable()) {
        File path = Environment.getExternalStorageDirectory();
        StatFs stat = new StatFs(path.getPath());
        double blockSize = stat.getBlockSize();
        double totalBlocks = stat.getBlockCount();
        return formatSizeGB(totalBlocks * blockSize);
    } else {
        return ERROR;
    }
}

From source file:com.example.demo_highlights.slidingmenu.fragment.LeftFragment.java

public void getDataSize() {
    textView2.setText("?");
    progressBar2.setProgress(0);/*from   w w  w  .j av a 2  s .co  m*/
    //
    File path = Environment.getDataDirectory();
    //sdcard
    StatFs statfs = new StatFs(path.getPath());
    //blockSIZE
    long blocSize = statfs.getBlockSize();
    //BLOCK
    long totalBlocks = statfs.getBlockCount();
    //Block
    long availaBlock = statfs.getAvailableBlocks();

    String[] total = filesize(totalBlocks * blocSize);
    String[] availale = filesize(availaBlock * blocSize);
    // 
    int maxValue = Integer.parseInt(availale[0].replaceAll(",", "")) * progressBar2.getMax()
            / Integer.parseInt(total[0].replaceAll(",", ""));
    progressBar2.setProgress(100 - maxValue);
    //          String Text="?"+total[0].replaceAll(",", "")+total[1]+"\n"
    //          +"?:"+availale[0].replaceAll(",", "")+availale[1]; 
    String Text = ":"
            + (Integer.parseInt(total[0].replaceAll(",", ""))
                    - Integer.parseInt(availale[0].replaceAll(",", "")))
            + availale[1]/*availale[0].replaceAll(",", "")+availale[1]*/ + " / " + total[0].replaceAll(",", "")
            + total[1];
    textView2.setText(Text);

}

From source file:com.example.demo_highlights.slidingmenu.fragment.LeftFragment.java

public void getSDSize() {
    textView1.setText("");
    progressBar1.setProgress(0);/*from w w  w. ja  va2  s  .  co m*/
    //
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        File path = Environment.getExternalStorageDirectory();
        //sdcard
        StatFs statfs = new StatFs(path.getPath());
        //blockSIZE
        long blocSize = statfs.getBlockSize();
        //BLOCK
        long totalBlocks = statfs.getBlockCount();
        //Block
        long availaBlock = statfs.getAvailableBlocks();

        String[] total = filesize(totalBlocks * blocSize);
        String[] availale = filesize(availaBlock * blocSize);
        // 
        int maxValue = Integer.parseInt(availale[0].replaceAll(",", "")) * progressBar1.getMax()
                / Integer.parseInt(total[0].replaceAll(",", ""));
        progressBar1.setProgress(100 - maxValue);
        String Text = "SD:"
                + (Integer.parseInt(total[0].replaceAll(",", ""))
                        - Integer.parseInt(availale[0].replaceAll(",", "")))
                + availale[1]/*availale[0].replaceAll(",", "")+availale[1]*/ + " / "
                + total[0].replaceAll(",", "") + total[1];
        textView1.setText(Text);

    } else if (Environment.getExternalStorageState().equals(Environment.MEDIA_REMOVED)) {
        //          Toast.makeText(getActivity(), "sdCard", 1000).show();
        textView1.setText("SD??");
    }
}

From source file:com.fallahpoor.infocenter.fragments.StorageFragment.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private String getExternalTotal() {

    long size;//from  w  ww  .ja  v a 2 s .  c o m
    StatFs extStorageStatFs;
    String extStoragePath = getExternalStoragePath();

    if (extStoragePath == null || !(new File(extStoragePath).exists())) {
        return getString(R.string.sto_sub_item_ext_storage_not_available);
    }

    extStorageStatFs = new StatFs(new File(extStoragePath).getAbsolutePath());

    if (mIsApiAtLeast18) {
        size = extStorageStatFs.getTotalBytes();
    } else {
        size = (long) extStorageStatFs.getBlockCount() * (long) extStorageStatFs.getBlockSize();
    }

    return Utils.getFormattedSize(size);

}