Here it’s:
public String size(int size){
String hrSize = "";
double m = size/1024.0;
DecimalFormat dec = new DecimalFormat("0.00");
if (m > 1) {
hrSize = dec.format(m).concat(" MB");
} else {
hrSize = dec.format(size).concat(" KB");
}
return hrSize;
}
SOURCE: Converting KB to MB, GB, TB dynamically
1
solved How to get file size in KB and MB in android [duplicate]