android开发——获取手机SD卡的容量
今天写了一个小巧但是实用的应用,获取手机sdcard 的容量,主要是通过总容量=分区数量*分区总数这个公式得到的。直接贴上代码。
sdnumberView = (TextView) this.findViewById(R.id.sdnumber); //获取sd卡目录 File path = Environment.getExternalStorageDirectory(); //把sd卡目录传进去 StatFs statFs = new StatFs(path.getPath()); long count = statFs.getBlockCount(); long size = statFs.getBlockSize(); String text = count*size+""; sdnumberView.setText(text);
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。