获取有关内部存储空间存储空间

2023-09-12 23:36:56 作者:限时拥抱

是否有可能得到一个Android设备(不是SD卡),通过Android SDK上的可用内存量?

Is it possible to get the amount of free memory on an Android device (not on the SD CARD) via the Android SDK?

如果是这样,如何​​?

If so, how?

推荐答案

this后可能会合身你的问题。

this post might fit well to your question.

同时检查this螺纹。有这么多的信息在这里的SO。

also check this thread. there is so much info here on SO.

用Google搜索了一下,这里是解决方案(在android混帐)

googled a bit and here is the solution (found at android git)

File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return Formatter.formatFileSize(this, availableBlocks * blockSize);