获取手机的内存详细信息
//total
StatFs statF = new StatFs(Environment.getDataDirectory().getAbsolutePath());
float total = ((float)statF.getBlockCount() * statF.getBlockSize()) / 1073741824;
TextView tt = (TextView) ax.findViewById(R.id.total1);
tt.setText(String.valueOf(total)+"GB");
//free
StatFs statFs = new StatFs(Environment.getDataDirectory().getAbsolutePath());
float free = ((float)statFs.getAvailableBlocks() * statFs.getBlockSize()) / 1073741824;
TextView t = (TextView) ax.findViewById(R.id.free1);
t.setText(String.valueOf(free)+"GB");
//use
float use = total - free ;
TextView ttt = (TextView) ax.findViewById(R.id.use1);
ttt.setText(String.valueOf(use)+"GB");
我正在使用此代码,但我得到 11.350227GB 的输出