Java tutorial
//package com.java2s; import android.graphics.Color; import android.os.Environment; import android.os.StatFs; public class Main { /** * To determine color of total mem in "new" dialog * * @param c * Size of cache * @param d * Size of data * @param s * Size of system * @return color of mem */ public static int getMemColor(int c, int d, int s) { int SD_FREE_SIZE = sdFreeSize(); int SD_WARN_SIZE = (int) (SD_FREE_SIZE * 0.9); int TOTAL_SIZE = getTotalSize(c, d, s); if (TOTAL_SIZE > SD_FREE_SIZE) return Color.RED; else if (TOTAL_SIZE > SD_WARN_SIZE) return Color.parseColor("#FFA500"); else return Color.parseColor("#4B8A08"); } /** * @return Free size in SDcard */ private static int sdFreeSize() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); long bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks(); int sdFreeMegs = (int) (bytesAvailable / (1024 * 1024)); return sdFreeMegs; } public static int getTotalSize(int c, int d, int s) { return c + d + s; } }