Java tutorial
//package com.java2s; /* * This software and related documentation ("CK-Telecom Software") are * protected under relevant copyright laws. The information contained herein * is confidential and proprietary to CK-Telecom. and/or its licensors. * Without the prior written permission of CK-Telecom. and/or its licensors, * any reproduction, modification, use or disclosure of CK-Telecom Software, * and information contained herein, in whole or in part, shall be strictly * prohibited. * CK-Telecom (C) 2012. All rights reserved. */ import java.io.File; import android.os.Environment; import android.os.StatFs; import android.util.Log; public class Main { private static String TAG = "HaaUtil"; private static boolean isTag = true; public static long getAvailaleSDCardSize() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); long asize = availableBlocks * blockSize; LOG("getAvailaleSDCardSize asize: " + asize); return asize; } private static void LOG(String log) { if (isTag) { Log.d(TAG, log); } } }