does anybody know how to find android apps memory usage using C++, because I can not get correct result using Java. I know two way how to find total Internal memory. First is:
    //Total Memory
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long totalBlocks = stat.getBlockCount();
    return formatSize(totalBlocks * blockSize); 
    public static String formatSize(long size) {
    String suffix = null;
    Long l = new Long(size);
    double sizeD = l.doubleValue();
    if (sizeD >= 1024) {
        suffix = "KB";
        sizeD /= 1024;
        if (sizeD >= 1024) {
            suffix = "MB";
            sizeD /= 1024;
            if (sizeD > 1024){
                sizeD /= 1024;
                suffix = "GB";
            }
        }
    }
    //size = (long)sizeD;
    //return  roundDouble(sizeD, 10) + suffix;
   StringBuilder resultBuffer = new StringBuilder(Long.toString(size));
    int commaOffset = resultBuffer.length() - 3;
    while (commaOffset > 0) {
        resultBuffer.insert(commaOffset, ',');
        commaOffset -= 3;
    }
    if (suffix != null) resultBuffer.append(suffix);
    return resultBuffer.toString();
}
Second is:
public long InternalTotalMemory(){
    StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
    long blockCount = statFs.getBlockCountLong();
    long blockSize = statFs.getBlockSizeLong();
    long total = blockCount * blockSize;
    return total;
}
    public static String BytesLongToString(long size){
    double KB = 1 * 1024;
    double MB = KB * 1024;
    double GB = MB * 1024;
    double TB = GB * 1024;
    String memorySize = "";
    if (size < KB){
       memorySize = floatForm(size) + " byte";
    } else if (size >= KB && size < MB){
        memorySize = floatForm((double)size / KB) + " KB";
    }  else if (size >= MB && size < GB){
        memorySize = floatForm((double)size / MB) + " MB";
    } else if (size >= GB && size < TB){
        memorySize = floatForm((double)size / GB) + " GB";
    }
    return memorySize;
}
public static String floatForm (double d)
{
    return new DecimalFormat("#.###").format(d);
}
I don't understand why two functions result is different or one of the format is wrong?
 
     
    