gpt4 book ai didi

android - 通过编码得到数据分区的大小

转载 作者:太空宇宙 更新时间:2023-11-03 13:32:53 29 4
gpt4 key购买 nike

我有测试代码使用:

  $ adb -s emulator-5554 shell

# df
df
/dev: 47084K total, 0K used, 47084K available (block size 4096)
/sqlite_stmt_journals: 4096K total, 0K used, 4096K available (block size 4096)
/system: 73600K total, 73600K used, 0K available (block size 4096)
/data: 65536K total, 18464K used, 47072K available (block size 4096)
/cache: 65536K total, 1156K used, 64380K available (block size 4096)

你看到数据总共有 65536k 等等,我的问题是如何通过编码获得大小?如果我需要 root 权限,你能给我一些建议吗?

最佳答案

try {
Runtime rt = Runtime.getRuntime();
Process pcs = rt.exec("df /data");
BufferedReader br = new BufferedReader(new InputStreamReader(pcs
.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
Log.e("line","line="+line);
}
br.close();
pcs.waitFor();

    File path = Environment.getDataDirectory();
android.os.StatFs stat = new android.os.StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks()*blockSize;

关于android - 通过编码得到数据分区的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10909054/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com