Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.os.Build; public class Main { public static String convertFileSize(Bitmap bitmap) { long kb = 1024; float f = (float) getBitmapsize(bitmap) / kb; return String.format(f > 100 ? "%.0f" : "%.1f", f); } public static long getBitmapsize(Bitmap bitmap) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); } }