2

how to programmatically read and display the size of sd-card and internal memory.

Internal Memory

  1. total space.
  2. used space.
  3. free space.

External Memory

  1. total space.
  2. used space.
  3. free space.

any related suggestions are apreciatted

4

3 回答 3

2
StatFs class 

您可以在此处使用,提供内部和外部目录的路径并计算总空间、可用空间和可用空间。

StatFs memStatus = new StatFs(Environment.getExternalStorageDirectory().getPath());

有关更多详细信息,请参阅文档

于 2013-03-20T10:37:37.623 回答
2

检查这个内存状态 类它有两种方法来获取内部和外部可用存储

于 2013-03-20T10:37:48.320 回答
2

试试这个代码:

public static long remainingLocalStorage()
{
StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
stat.restat(Environment.getDataDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getAvailableBlocks();
return bytesAvailable;
}
于 2013-03-20T10:37:48.400 回答