Search in sources :

Example 71 with StatFs

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

the class SdCardUtil method getAvailableSize.

/**
     * Get available size of SD card.
     */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static long getAvailableSize(String path) {
    try {
        File base = new File(path);
        StatFs stat = new StatFs(base.getPath());
        return stat.getBlockSizeLong() * stat.getAvailableBlocksLong();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}
Also used : StatFs(android.os.StatFs) TargetApi(android.annotation.TargetApi)

Example 72 with StatFs

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

the class AppFileMgr method getSdCardAllSize.

/**
	 * 获取SDCard总存储容量大小(单位byte) 
	 * @return long  返回大小
	 */
@SuppressWarnings("deprecation")
public long getSdCardAllSize() {
    if (getSdCardIsEnable()) {
        File path = Environment.getExternalStorageDirectory();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long totalBlocks = stat.getBlockCount();
        return totalBlocks * blockSize;
    }
    return 0;
}
Also used : StatFs(android.os.StatFs) File(java.io.File)

Example 73 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 74 with StatFs

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

the class AppFileMgr method getMobileEnableRAM.

/**
	 * 获取可用手机内容容量大小
	 * @return long   
	 */
@SuppressWarnings("deprecation")
public static long getMobileEnableRAM() {
    StatFs stat = new StatFs(getDataPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks() - 4;
    ;
    return availableBlocks * blockSize;
}
Also used : StatFs(android.os.StatFs)

Example 75 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