获取有关内部存储空间 [英] Get free space on internal memory

查看:123
本文介绍了获取有关内部存储空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能得到一个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?

推荐答案

<一个href="http://stackoverflow.com/questions/3170691/how-to-get-current-memory-usage-in-android">this后可能会合身你的问题。

this post might fit well to your question.

同时检查<一href="http://stackoverflow.com/questions/4350580/android-how-do-you-get-internal-total-available-memory">this螺纹。有这么多的信息在这里的SO。

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

用Google搜索了一下,这里是解决方案(在<一个发现href="http://android.git.kernel.org/?p=platform/packages/apps/Settings.git;a=blob;f=src/com/android/settings/deviceinfo/Memory.java#l335">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);

这篇关于获取有关内部存储空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆