package com.kdanmobile.kdan_others_library_for_android.model;

/**
 * Created by Shan on 2017/4/12.
 */

public class StorageHelper {

    public static String covertByteUnit(long storageBytes){
        float spaceValue = storageBytes / 1024f / 1024f;
        String spaceUnit = "MB";

        if (spaceValue > 1024 * 1024) {
            spaceValue /= (1024f * 1024f);
            spaceUnit = "TB";
        } else if (spaceValue > 1024) {
            spaceValue /= 1024f;
            spaceUnit = "GB";
        }
        return String.format("%.1f", spaceValue) + spaceUnit;
    }

}
