0

I have read a lot of questions related to the topic and finally was able to write this code

        StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
        long blockSize = statFs.getBlockSizeLong();
        long totalSizeInternal = statFs.getBlockCountLong()*blockSize;
        long freeSizeInternal = statFs.getFreeBlocksLong()*blockSize;
        statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
        blockSize = statFs.getBlockSizeLong();
        long totalSizeExternal = statFs.getBlockCountLong()*blockSize;
        long freeSizeExternal = statFs.getFreeBlocksLong() * blockSize;


 Log.d("printingDetails", totalSizeExternal + "");
        Log.d("printingDetails", freeSizeExternal + "");

        Log.d("printingDetails", totalSizeInternal + "");
        Log.d("printingDetails", freeSizeInternal + "");

        Log.d("printingDetails", Environment.isExternalStorageRemovable() + "");

and was able to get this output for my redmi 3s phone freeSizeExternal : 2034581504 totalSizeExternal : 10486845440 freeSizeInternal : 308924416 totalSizeInternal : 3095707648

and my redmi 3s have an internal storage of 16GB only no external sd card is inserted, with a free space of over 2.1GB,and when i checked over micromax phone with an SD CARD of 32GB and internal mermory of 2GB, i got the following results like external storage is showing around 29GB and internal storage is around 700MB which it is showing, can anyone explain me what is internal and external size in the both cases and why are they so different from the original size, and also provide me the correct code which displays the correct size of internal as well as external memory of phone.

Deepak Sharma
  • 458
  • 9
  • 21
  • Did you checked this http://stackoverflow.com/a/16835201/5515371 – Mujammil Ahamed Jan 12 '17 at 11:50
  • 3
    Possible duplicate of [How to get an External storage sd card size (With Mounted SD card)?](http://stackoverflow.com/questions/16834964/how-to-get-an-external-storage-sd-card-size-with-mounted-sd-card) – W4R10CK Jan 12 '17 at 11:54
  • The way you try it looks ok. But you should use the path to the sd card of course. You are not using the correct path. – greenapps Jan 12 '17 at 13:42

0 Answers0