Search in sources :

Example 76 with StatFs

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

the class AppPhoneMgr method getSDFreeSize.

/**
     * 获取sd卡剩余空间的大小
     */
@SuppressWarnings("deprecation")
public long getSDFreeSize() {
    // 取得SD卡文件路径
    File path = Environment.getExternalStorageDirectory();
    StatFs sf = new StatFs(path.getPath());
    // 获取单个数据块的大小(Byte)
    long blockSize = sf.getBlockSize();
    // 空闲的数据块的数量
    long freeBlocks = sf.getAvailableBlocks();
    // 单位MB
    return (freeBlocks * blockSize) / 1024 / 1024;
}
Also used : StatFs(android.os.StatFs) File(java.io.File)

Example 77 with StatFs

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

the class AppPhoneMgr method getSDAllSize.

/**
     * 获取sd卡空间的总大小
     */
@SuppressWarnings("deprecation")
public long getSDAllSize() {
    // 取得SD卡文件路径
    File path = Environment.getExternalStorageDirectory();
    StatFs sf = new StatFs(path.getPath());
    // 获取单个数据块的大小(Byte)
    long blockSize = sf.getBlockSize();
    // 获取所有数据块数
    long allBlocks = sf.getBlockCount();
    // 单位MB
    return (allBlocks * blockSize) / 1024 / 1024;
}
Also used : StatFs(android.os.StatFs) File(java.io.File)

Example 78 with StatFs

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

the class FileUtils method gainSDAllSize.

/**
     * 获取SD卡总容量(单位Byte)
     *
     * @return
     */
@SuppressWarnings("deprecation")
public static long gainSDAllSize() {
    if (isMountedSDCard()) {
        // 取得SD卡文件路径
        File path = Environment.getExternalStorageDirectory();
        StatFs sf = new StatFs(path.getPath());
        // 获取单个数据块的大小(Byte)
        long blockSize = sf.getBlockSize();
        // 获取所有数据块数
        long allBlocks = sf.getBlockCount();
        // 返回SD卡大小(Byte)
        return allBlocks * blockSize;
    } else {
        return 0;
    }
}
Also used : StatFs(android.os.StatFs) File(java.io.File)

Example 79 with StatFs

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

the class FileUtils method gainSDFreeSize.

/**
     * 获取SD卡剩余容量(单位Byte)
     *
     * @return
     */
@SuppressWarnings("deprecation")
public static long gainSDFreeSize() {
    if (isMountedSDCard()) {
        // 取得SD卡文件路径
        File path = Environment.getExternalStorageDirectory();
        StatFs sf = new StatFs(path.getPath());
        // 获取单个数据块的大小(Byte)
        long blockSize = sf.getBlockSize();
        // 空闲的数据块的数量
        long freeBlocks = sf.getAvailableBlocks();
        // 单位Byte
        return freeBlocks * blockSize;
    } else {
        return 0;
    }
}
Also used : StatFs(android.os.StatFs) File(java.io.File)

Example 80 with StatFs

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

the class FileUtils method gainSDFreeSize.

/**
     * 获取SD卡剩余容量(单位Byte)
     *
     * @return
     */
@SuppressWarnings("deprecation")
public static long gainSDFreeSize() {
    if (isMountedSDCard()) {
        // 取得SD卡文件路径
        File path = Environment.getExternalStorageDirectory();
        StatFs sf = new StatFs(path.getPath());
        // 获取单个数据块的大小(Byte)
        long blockSize = sf.getBlockSize();
        // 空闲的数据块的数量
        long freeBlocks = sf.getAvailableBlocks();
        // 单位Byte
        return freeBlocks * blockSize;
    } else {
        return 0;
    }
}
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