Sojurn
Sojurn

Reputation: 485

file.getTotalSpace() returning twice of the actual value

So i have a rooted android 4.0.3 device. Whenever I install something to the 'sd card' which happens to actually be internal, it creates this /mnt/secure/asec partition as well. following is the partial output of df.

    /mnt/sdcard              1G    65M     1G   4096
    /mnt/secure/asec         1G    65M     1G   4096

Now, if I try to execute the following code.

    File f = new File("/mnt/sdcard");
    long div = (1024*1024);
    long d = f.getTotalSpace()/div;
            Log.i("Capacity",String.valueOf(d));

The value it is showing me is 2Gb. What is going on here? And why is android 4.0.3 creating a secure mount point for these apks install on the 'sd card' anyway? Isn't that a JellyBean only feature?

Upvotes: 1

Views: 1267

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006924

What is going on here?

Try using StatFs instead of getTotalSpace() and see if you get better results.

And why is android 4.0.3 creating a secure mount point for these apks install on the 'sd card' anyway?

Because that has been part of install-to-SD in Android since the feature was introduced in API Level 8.

Upvotes: 1

Related Questions