安卓:如何获得内部总内存/可用内存?[英] Android: How do you get internal Total/Available memory?

本文是小编为大家收集整理的关于安卓:如何获得内部总内存/可用内存?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

RAM内存和内部闪存之间有差异吗? 我可以通过以下方式获取RAM记忆:

cat /proc/meminfo
但是,我不确定如何获取闪存信息.

我想我知道如何获得可用内存:

ActivityManager activityManager = (ActivityManager).getSystemService(Context.ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
memoryInfo.availMem;

这是否可提供内部闪存?

全内存全部内存如何?

遵循unix命令让我这个信息?

df

结果:

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    97744         0     97744   0% /dev
tmpfs                     4096         0      4096   0% /sqlite_stmt_journals
/dev/block/mtdblock3    174080    154372     19708  89% /system
/dev/block/mtdblock5    169728     57144    112584  34% /data
/dev/block/mtdblock4    133120     89632     43488  67% /cache
/dev/block/mtdblock4    133120     89632     43488  67% /data/dalvik-cache
/dev/block//vold/179:1
                       7970928   2358576   5612352  30% /sdcard

如果是,我必须添加所有tmpfs和/dev/block/mtdblock#以获取全内部内存?

推荐答案

df告诉您关于文件系统上的空间...即,将Flash视为"磁盘"

加上它......取决于你想知道什么.添加不同的分区有点可疑,因为它们并不完全互换.还有其他MTD分区没有文件系统或在正常操作期间未安装文件 - 它们包含像引导加载程序,无线电固件,Linux内核和压缩根文件系统等内容,以及内核和压缩文件系统恢复系统.

您可能会更好地查看内核启动消息,并查看RAM和MTD设备的方式发现的内容.

但是,还有内部内存无法访问内核,而是由无线电协处理器使用.因此,如果您实际上希望总计安装,可能最好阅读制造商规格.

否则,您应该坚持可能可以想象的内存以应用程序...

本文地址:https://www.itbaoku.cn/post/102465.html

问题描述

There's a difference between RAM memory and internal flash memory right? I can get RAM memory by:

cat /proc/meminfo

However, I am not sure how to get Flash memory information.

I think I know how to get available memory:

ActivityManager activityManager = (ActivityManager).getSystemService(Context.ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
memoryInfo.availMem;

Does this give available internal Flash memory?

How about total internal memory?

Does following unix command get me this info?

df

result:

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    97744         0     97744   0% /dev
tmpfs                     4096         0      4096   0% /sqlite_stmt_journals
/dev/block/mtdblock3    174080    154372     19708  89% /system
/dev/block/mtdblock5    169728     57144    112584  34% /data
/dev/block/mtdblock4    133120     89632     43488  67% /cache
/dev/block/mtdblock4    133120     89632     43488  67% /data/dalvik-cache
/dev/block//vold/179:1
                       7970928   2358576   5612352  30% /sdcard

if so, do I have to add all tmpfs & /dev/block/mtdblock# to get total internal memory?

推荐答案

df tells you about the space on file systems... ie, think of flash as 'disk'

As for adding it up... depends on what you want to know. Adding up distinct partitions is a bit dubious since they aren't exactly interchangeable. And there are other mtd partitions that don't have file systems or don't get mounted during normal operation - they contain things like bootloaders, radio firmware, the linux kernel and compressed root filesystem, and also the kernel and compressed file system for the recovery system.

You might do better to look through the kernel boot messages and see what it finds in the way of ram and mtd devices.

But then, there's also internal memory that is not accessible to the kernel and is instead used by the radio coprocessor. So if you actually want the total installed, it's probably best to read the manufacturers specifications.

Otherwise, you should stick to the memory that might conceivably be available to applications...