Example usage for android.os StatFs getAvailableBlocks

List of usage examples for android.os StatFs getAvailableBlocks

Introduction

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

Prototype

@Deprecated
public int getAvailableBlocks() 

Source Link

Usage

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

public static long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    return stat.getAvailableBlocks() * blockSize;
}

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

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

From source file:org.navitproject.navit.NavitDownloadSelectMapActivity.java

private long getFreeSpace() {
    StatFs fsInfo = new StatFs(Navit.map_filename_path);
    return (long) fsInfo.getAvailableBlocks() * fsInfo.getBlockSize();
}

From source file:fr.eoit.activity.EOITActivity.java

/**
 * Called when the activity is first created.
 *//* w  w w  .j  ava  2  s . co m*/
@Override
public void onCreate(Bundle savedInstanceState) {

    loadParametersOnCreate = false;

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    disableConnectionReuseIfNecessary();
    enableHttpResponseCache();

    bar = (ProgressBar) findViewById(R.id.progressBar);
    bar.setIndeterminate(true);
    infoTextView = (TextView) findViewById(R.id.textView);

    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();

    if (blockSize * availableBlocks > EOITConst.APPLICATION_SIZE) {
        new LoadItemsAsyncTask().execute(this);
    } else {
        new AlertDialog.Builder(this).setCancelable(false).setTitle(R.string.database_no_space)
                .setMessage(getResources().getString(R.string.database_no_space_message,
                        EOITConst.APPLICATION_SIZE / (1024 * 1024)))
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setNegativeButton(R.string.database_locked_close_button_message,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int whichButton) {
                                finish();
                            }
                        })
                .create().show();
    }
}

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

/**
  * Gets available internal memory size.
  *//from www .  j a  v  a2s  .c  o m
  * @return The size of internal storage available.
  */
public String getAvailableInternalMemorySize() {
    File mPath = Environment.getDataDirectory();
    StatFs mStat = new StatFs(mPath.getPath());
    long mBlockSize = mStat.getBlockSize();
    long mAvailableBlocks = mStat.getAvailableBlocks();
    return Formatter.formatFileSize(getActivity(), mAvailableBlocks * mBlockSize);
}

From source file:cordova.plugins.Diagnostic_External_Storage.java

/**
 * Given a path return the number of free bytes in the filesystem containing the path.
 *
 * @param path to the file system//from w w  w.  j ava 2 s.  c  o m
 * @return free space in bytes
 */
protected long getFreeSpaceInBytes(String path) {
    try {
        StatFs stat = new StatFs(path);
        long blockSize = stat.getBlockSize();
        long availableBlocks = stat.getAvailableBlocks();
        return availableBlocks * blockSize;
    } catch (IllegalArgumentException e) {
        // The path was invalid. Just return 0 free bytes.
        return 0;
    }
}

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

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

    long size;/* w  w w . ja v  a2s  .  c  om*/
    StatFs internalStatFs = new StatFs(Environment.getDataDirectory().getAbsolutePath());

    if (mIsApiAtLeast18) {
        size = internalStatFs.getAvailableBytes();
    } else {
        size = (long) internalStatFs.getAvailableBlocks() * (long) internalStatFs.getBlockSize();
    }

    return Utils.getFormattedSize(size);

}

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

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

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

    final long availBlocks = VersionUtil.IS_JELLY_BEAN_MR2()
            ? statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong()
            : statFs.getAvailableBlocks() * statFs.getBlockSize();

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

}

From source file:com.esminis.server.mariadb.server.MariaDbServerLauncher.java

private long getFreeSpace(File file) {
    StatFs stat = new StatFs(file.getPath());
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return stat.getAvailableBlocksLong() * stat.getBlockSizeLong();
    }/*w  w  w  .  ja va2s .  c  om*/
    return (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
}

From source file:com.open.file.manager.CutCopyService.java

/**
 * Checks weither there's enough space to perform the operation
 * @param current//from   w w w .  j  a v a 2 s .c  o  m
 * @return
 */
private boolean notEnoughSpace(FileCopyNode current) {
    StatFs targetfs = new StatFs(current.dstFile.getParent());
    return current.size > (long) targetfs.getAvailableBlocks() * (long) targetfs.getBlockSize();
}