1.获取SD卡目录:File file = Environment.getExternalStorageDirectory();
2.获取SD卡路径:String path = Environment.getExternalStorageDirectory().getPath();
3.获取SD卡状态(挂在还是卸载)Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED),SD卡可用
4.获取SD开总大小:Environment.getExternalStorageDirectory().getTotalSpace()
5.获取SD卡可用大小(字节数):Environment.getExternalStorageDirectory().getFreeSpace()
6.格式化存储字节数大小用(MB表示):String fileSize = Formatter.formatFileSize(this, size);
7.访问sd卡需要添加权限:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>