简体   繁体   中英

Android Device Total Internal Storage

I'm trying to find out the total storage space a device has. I've tried:

StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); 
statFs.getTotalBytes();
statFs.getBlockCountLong() * statFs.getBlockSizeLong();

and both methods return the same number, which is ~2GB , when I know that my device has 16GB total storage space (accessible and inaccessible).

How can I get the real storage size? Not only available or free space, every last scrap of a byte a device has.

What you probably need is this:

StatFs statFs = new StatFs(Environment.getDataDirectory().getPath()); 

because getRootDirectory(); gets you the "system" partition holding the core Android OS.

Then, the other method will get you the total storage space...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM