Back to project page Common-Library.
The source code is released under:
Apache License
If you think the Android project Common-Library listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.morgan.library.utils; /* w ww . j a va 2 s . c om*/ import java.io.File; import android.os.Environment; import android.os.StatFs; /** * ????SD??????????? * * @author Morgan.Ji * */ public class SDCardUtils { public static String getSDCardPath() { return Environment.getExternalStorageDirectory().getAbsolutePath(); } public static long getSDCardAvailableBytes() { if (isSDCardBusy()) return 0; final File path = Environment.getExternalStorageDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize = stat.getBlockSizeLong(); final long availableBlocks = stat.getAvailableBlocksLong(); return blockSize * (availableBlocks - 4); } public static boolean isSDCardBusy() { return !Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED); } }