public class DemoActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); //每一个区块的大小 long totalBlocks = stat.getBlockCount(); //所有区块 long availableBlocks = stat.getAvailableBlocks(); // 所有可用区块 String totalsize = Formatter.formatFileSize(this, totalBlocks * blockSize); String availablesize = Formatter.formatFileSize(this, availableBlocks * blockSize); TextView tv = new TextView(this); tv.setText("sd卡大小"+totalsize+"\n"+"可用空间"+availablesize); setContentView(tv); } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。