如何以编程方式读取和显示的SD卡和内存的大小。
任何相关的建议是preciatted
解决方案试试这个code:
公共静态长remainingLocalStorage()
{
体statfs STAT =新体statfs(Environment.getDataDirectory()getPath());
stat.restat(Environment.getDataDirectory()getPath());
长方bytesAvailable =(长)stat.getBlockSize()*(长)stat.getAvailableBlocks();
返回方bytesAvailable;
}
how to programmatically read and display the size of sd-card and internal memory.
any related suggestions are apreciatted
解决方案Try this code:
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;
}