开发者

How to calculate remaining space in local storage?

How do I find remaining/total space on the local storage?

Can I use StatFs for this (as in - How to Check available space 开发者_如何转开发on android device ? on SD card?)


Turns out you can. Ran this code which seems to return the appropriate number of bytes remaining in my internal storage. Unsure about the reliability of Environment.getDataDirectory()

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜