本文整理匯總了Java中android.os.StatFs.getAvailableBytes方法的典型用法代碼示例。如果您正苦於以下問題:Java StatFs.getAvailableBytes方法的具體用法?Java StatFs.getAvailableBytes怎麽用?Java StatFs.getAvailableBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.StatFs
的用法示例。
在下文中一共展示了StatFs.getAvailableBytes方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSDCardInfo
import android.os.StatFs; //導入方法依賴的package包/類
/**
* 獲取SD卡信息
*
* @return SDCardInfo
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getSDCardInfo() {
if (!isSDCardEnable()) return null;
SDCardInfo sd = new SDCardInfo();
sd.isExist = true;
StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
sd.totalBlocks = sf.getBlockCountLong();
sd.blockByteSize = sf.getBlockSizeLong();
sd.availableBlocks = sf.getAvailableBlocksLong();
sd.availableBytes = sf.getAvailableBytes();
sd.freeBlocks = sf.getFreeBlocksLong();
sd.freeBytes = sf.getFreeBytes();
sd.totalBytes = sf.getTotalBytes();
return sd.toString();
}
示例2: getSDCardInfo
import android.os.StatFs; //導入方法依賴的package包/類
/**
* 獲取SD卡信息
*
* @return SDCardInfo
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getSDCardInfo() {
SDCardInfo sd = new SDCardInfo();
if (!isSDCardEnable()) return "sdcard unable!";
sd.isExist = true;
StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
sd.totalBlocks = sf.getBlockCountLong();
sd.blockByteSize = sf.getBlockSizeLong();
sd.availableBlocks = sf.getAvailableBlocksLong();
sd.availableBytes = sf.getAvailableBytes();
sd.freeBlocks = sf.getFreeBlocksLong();
sd.freeBytes = sf.getFreeBytes();
sd.totalBytes = sf.getTotalBytes();
return sd.toString();
}
示例3: getFreeSpaceBytes
import android.os.StatFs; //導入方法依賴的package包/類
/**
* 獲取空閑的空間大小
* @param path 文件路徑
* @return 空間大小
*/
public static long getFreeSpaceBytes(final String path) {
long freeSpaceBytes;
final StatFs statFs = new StatFs(path);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
freeSpaceBytes = statFs.getAvailableBytes();
} else {
//noinspection deprecation
freeSpaceBytes = statFs.getAvailableBlocks() * (long) statFs.getBlockSize();
}
return freeSpaceBytes;
}
示例4: getFreeSpaceBytes
import android.os.StatFs; //導入方法依賴的package包/類
/**
* 獲取空閑的空間大小
* @return 空間大小
*/
public static long getFreeSpaceBytes() {
long freeSpaceBytes;
final StatFs statFs = new StatFs(getSDPath());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
freeSpaceBytes = statFs.getAvailableBytes();
} else {
//noinspection deprecation
freeSpaceBytes = statFs.getAvailableBlocks() * (long) statFs.getBlockSize();
}
return freeSpaceBytes;
}
示例5: getFreeSpaceBytes
import android.os.StatFs; //導入方法依賴的package包/類
public static long getFreeSpaceBytes(final String path) {
long freeSpaceBytes;
final StatFs statFs = new StatFs(path);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
freeSpaceBytes = statFs.getAvailableBytes();
} else {
//noinspection deprecation
freeSpaceBytes = statFs.getAvailableBlocks() * (long) statFs.getBlockSize();
}
return freeSpaceBytes;
}
示例6: getSDCardInfo
import android.os.StatFs; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getSDCardInfo() {
if (!isSDCardEnable()) return null;
SDCardInfo sd = new SDCardInfo();
sd.isExist = true;
StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
sd.totalBlocks = sf.getBlockCountLong();
sd.blockByteSize = sf.getBlockSizeLong();
sd.availableBlocks = sf.getAvailableBlocksLong();
sd.availableBytes = sf.getAvailableBytes();
sd.freeBlocks = sf.getFreeBlocksLong();
sd.freeBytes = sf.getFreeBytes();
sd.totalBytes = sf.getTotalBytes();
return sd.toString();
}
示例7: getFreeSpaceBytes
import android.os.StatFs; //導入方法依賴的package包/類
public static long getFreeSpaceBytes(final String path) {
// NEED CHECK PERMISSION?
long freeSpaceBytes;
final StatFs statFs = new StatFs(path);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
freeSpaceBytes = statFs.getAvailableBytes();
} else {
//noinspection deprecation
freeSpaceBytes = statFs.getAvailableBlocks() * (long) statFs.getBlockSize();
}
return freeSpaceBytes;
}
示例8: getSDCardInfo
import android.os.StatFs; //導入方法依賴的package包/類
/**
* Get SD card info detail.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static SDCardInfo getSDCardInfo() {
SDCardInfo sd = new SDCardInfo();
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
sd.isExist = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
File sdcardDir = Environment.getExternalStorageDirectory();
StatFs sf = new StatFs(sdcardDir.getPath());
sd.totalBlocks = sf.getBlockCountLong();
sd.blockByteSize = sf.getBlockSizeLong();
sd.availableBlocks = sf.getAvailableBlocksLong();
sd.availableBytes = sf.getAvailableBytes();
sd.freeBlocks = sf.getFreeBlocksLong();
sd.freeBytes = sf.getFreeBytes();
sd.totalBytes = sf.getTotalBytes();
}
}
if (Log.isPrint) {
Log.i(TAG, sd.toString());
}
return sd;
}
示例9: getSDCardInfo
import android.os.StatFs; //導入方法依賴的package包/類
/**
* Get SD card info detail.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static SDCardInfo getSDCardInfo() {
SDCardInfo sd = new SDCardInfo();
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
sd.isExist = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
File sdcardDir = Environment.getExternalStorageDirectory();
StatFs sf = new StatFs(sdcardDir.getPath());
sd.totalBlocks = sf.getBlockCountLong();
sd.blockByteSize = sf.getBlockSizeLong();
sd.availableBlocks = sf.getAvailableBlocksLong();
sd.availableBytes = sf.getAvailableBytes();
sd.freeBlocks = sf.getFreeBlocksLong();
sd.freeBytes = sf.getFreeBytes();
sd.totalBytes = sf.getTotalBytes();
}
}
Log.i(TAG, sd.toString());
return sd;
}
示例10: getSizeUpdatedApi
import android.os.StatFs; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static long getSizeUpdatedApi(StatFs statFs) {
return statFs.getAvailableBytes() / (1024 * 1024);
}