Android 最新获取手机内置存储大小,SD卡存储空间大小方法
在以前我们都是这样获取的
//Android API18之前:fs.getAvailableBlocks()*fs.getBlockSize()
目前:
/** 得到系统可用内存 **/ @SuppressLint("NewApi") private String getMemFree(){ StatFs fs = new StatFs(Environment.getDataDirectory().getPath()); return Formatter.formatFileSize(this, (fs.getAvailableBytes())); } /** 得到SD可用内存 **/ @SuppressLint("NewApi") private String getSdFree(){ if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ StatFs fs = new StatFs(Environment.getExternalStorageDirectory().getPath()); //Android API18之前:fs.getAvailableBlocks()*fs.getBlockSize() return Formatter.formatFileSize(this, (fs.getAvailableBytes())); } return "未装载"; }
终于解决问题了,嘎嘎
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了