简体   繁体   English

android内部内存使用情况

[英]android internal memory usage

I am new in Android and I want to find free memory in internal storage. 我是Android的新手,我想在内部存储中找到可用的内存。 I use two function to find free memory but they show me two different values in long format. 我使用两个函数来查找可用内存,但是它们以长格式显示了两个不同的值。 I don't know why? 不知道为什么 Here is my code: 这是我的代码:

1) Result of getTIM() function is 558628864 1)getTIM()函数的结果是558628864

public String getTIM(){
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long totalBlocks = stat.getBlockCount();
    String str = Long.toString(blockSize * totalBlocks);
    return str;
} 

2) Result of ITMStr() function is 914120704 2)ITMStr()函数的结果为914120704

public String ITMStr(){
    StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
    long blockCount = statFs.getBlockCountLong();
    long blockSize = statFs.getBlockSizeLong();
    long total = blockCount * blockSize;
    String str = Long.toString(total);
    return str;
}

Which value is right? 哪个值正确?

According to reference : 根据参考

public static File getDataDirectory () 公共静态文件getDataDirectory()

Added in API level 1 Return the user data directory. API级别1中已添加返回用户数据目录。

_ _

public static File getRootDirectory () 公共静态文件getRootDirectory()

Added in API level 1 Return root of the "system" partition holding the core Android OS. 在API级别1中添加。返回包含核心Android OS的“系统”分区的根目录。 Always present and mounted read-only. 始终存在且以只读方式安装。

So sizes are different as you are getting sizes for different stuff. 因此,尺寸会有所不同,因为您要获得不同物料的尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM