1

i try to use this code, from How to find the amount of free storage (disk space) left on Android?

    File pathOS = Environment.getRootDirectory();//Os Storage
    StatFs statOS = new StatFs(pathOS.getAbsolutePath());
    long   total_OS_memory=0;long free_OS_memory=0;
total_OS_memory= (statOS.getBlockCountLong()*statOS.getBlockSizeLong());

but size of Operting system not same with hardware on mobile.

On my phone value is 3.4 G, but when i use my code result is 1.17.

And this is compare between my real phone with my code result.

Name            |Phone|MyCode
Total Storage   |8    |5.81
System          |3.4  |1.17 
Internal Storage|4.64 |4.64 

How to get operating sistem size in android?

Community
  • 1
  • 1
Akbar
  • 53
  • 1
  • 8
  • Why are you talking about operating system size in your subject and post? Has nothing to do with free storage. Please edit. – greenapps May 07 '17 at 09:54
  • as per the Docs, `Environment.getRootDirectory()` **Return root of the "system" partition** so that's one partition, if you need the whole storage (external or internal) you have to get that path, not `/system` only. – Yazan May 07 '17 at 09:57
  • can you explain why u say that. And can you explain why my result code not same with real hardware on my phone?.@greenapps . – Akbar May 07 '17 at 10:03
  • actually I have got the value to get external storage and internal storage. Couse on my phone total storage is 8G. with System 3.4G and internal storage 4.6G. But on my code result is internal storage 4.6G and System 1.17.@Yazan . – Akbar May 07 '17 at 10:08

0 Answers0