how to programmatically read and display the size of sd-card and internal memory.
Internal Memory
- total space.
- used space.
- free space.
External Memory
- total space.
- used space.
- free space.
any related suggestions are apreciatted
StatFs class
您可以在此处使用,提供内部和外部目录的路径并计算总空间、可用空间和可用空间。
StatFs memStatus = new StatFs(Environment.getExternalStorageDirectory().getPath());
有关更多详细信息,请参阅文档。
检查这个内存状态 类它有两种方法来获取内部和外部可用存储
试试这个代码:
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;
}