Calculate Image Size in MB in Android

public int calculateImageSize(String filepath) {
    File file = new File(filepath);

    double bytes = file.length();
    double kilobytes = (bytes / 1024);
    double megabytes = (kilobytes / 1024);

    return  (int)megabytes;
}

and Done...

Comments