Search in sources :

Example 66 with StatFs

use of android.os.StatFs in project android_frameworks_base by AOSPA.

the class PackageManagerTests method checkInt.

private boolean checkInt(long pkgLen) {
    StatFs intStats = new StatFs(Environment.getDataDirectory().getPath());
    long intSize = (long) intStats.getBlockCount() * (long) intStats.getBlockSize();
    long iSize = (long) intStats.getAvailableBlocks() * (long) intStats.getBlockSize();
    // TODO check for thresholds here?
    return pkgLen <= iSize;
}
Also used : StatFs(android.os.StatFs)

Example 67 with StatFs

use of android.os.StatFs in project ABPlayer by winkstu.

the class CropImage method calculatePicturesRemaining.

public static int calculatePicturesRemaining() {
    try {
        /*if (!ImageManager.hasStorage()) {
			    return NO_STORAGE_ERROR;
			} else {*/
        String storageDirectory = Environment.getExternalStorageDirectory().toString();
        StatFs stat = new StatFs(storageDirectory);
        float remaining = ((float) stat.getAvailableBlocks() * (float) stat.getBlockSize()) / 400000F;
        return (int) remaining;
    //}
    } catch (Exception ex) {
        // blank since we really don't know.
        return CANNOT_STAT_ERROR;
    }
}
Also used : StatFs(android.os.StatFs) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 68 with StatFs

use of android.os.StatFs in project ABPlayer by winkstu.

the class FileUtils method showFileAvailable.

/** 显示SD卡剩余空间 */
public static String showFileAvailable() {
    String result = "";
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
        long blockSize = sf.getBlockSize();
        long blockCount = sf.getBlockCount();
        long availCount = sf.getAvailableBlocks();
        return showFileSize(availCount * blockSize) + " / " + showFileSize(blockSize * blockCount);
    }
    return result;
}
Also used : StatFs(android.os.StatFs)

Example 69 with StatFs

use of android.os.StatFs in project teaTime by ancfdy.

the class AppFileMgr method getSdCardEnableSize.

/**
	 * 获取SDCard卡的剩余容量(单位byte)
	 * @return long  返回大小
	 */
@SuppressWarnings("deprecation")
public static long getSdCardEnableSize() {
    //首先判断SdCard是否存在
    if (getSdCardIsEnable()) {
        StatFs stat = new StatFs(getSdCardAbsolutePath());
        //获取空闲的数据块的数量  
        long availableBlocks = (long) stat.getAvailableBlocks() - 4;
        //获取单个数据块的大小(byte)  
        long freeBlocks = stat.getAvailableBlocks();
        return freeBlocks * availableBlocks;
    }
    return 0;
}
Also used : StatFs(android.os.StatFs)

Example 70 with StatFs

use of android.os.StatFs in project teaTime by ancfdy.

the class AppFileMgr method getSdCardSize.

/**
	 * 获取SD卡剩余空间的大小(SD卡剩余空间的大小(单位:byte))
	 * @return long   
	 */
@SuppressWarnings("deprecation")
public static long getSdCardSize() {
    String str = Environment.getExternalStorageDirectory().getPath();
    StatFs localStatFs = new StatFs(str);
    long blockSize = localStatFs.getBlockSize();
    return localStatFs.getAvailableBlocks() * blockSize;
}
Also used : StatFs(android.os.StatFs)

Aggregations

StatFs (android.os.StatFs)196 File (java.io.File)120 IOException (java.io.IOException)30 FileOutputStream (java.io.FileOutputStream)17 TargetApi (android.annotation.TargetApi)15 LargeTest (android.test.suitebuilder.annotation.LargeTest)12 FileNotFoundException (java.io.FileNotFoundException)11 ContentResolver (android.content.ContentResolver)10 DropBoxManager (android.os.DropBoxManager)10 TextView (android.widget.TextView)10 DropBoxManagerService (com.android.server.DropBoxManagerService)10 Test (org.junit.Test)7 PendingIntent (android.app.PendingIntent)6 Intent (android.content.Intent)6 IntentFilter (android.content.IntentFilter)6 Context (android.content.Context)5 Suppress (android.test.suitebuilder.annotation.Suppress)5 Button (android.widget.Button)5 SuppressLint (android.annotation.SuppressLint)3 SDCardInfo (com.yzy.supercleanmaster.model.SDCardInfo)3