Android examples for java.lang:long
get Size in Description
import android.content.Context; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static String getSizeDesc(long size) { String suffix = "B"; if (size >= 1024) { suffix = "K"; size = size >> 10;/*from w w w . ja va 2 s.co m*/ if (size >= 1024) { suffix = "M"; //size /= 1024; size = size >> 10; if (size >= 1024) { suffix = "G"; size = size >> 10; //size /= 1024; } } } return size + suffix; } }