storage - What does getAvailableBlocks() on Android actually return? -


i'm writing app gets how disk space left on android device , use following code:

public int phone_storage_free() {     statfs statfs = new statfs(environment.getrootdirectory().getabsolutepath());     int free  = (statfs.getavailableblocks() * statfs.getblocksize()) / 1048576;     return free; } 

it returns 35mb, tiny amount, assume it's amount of disk space free app itself. wrote code download file bigger 35mb, saved file path.getpath()+"/test.avi" , succeeded. ran above code again , got same value of 35mb.

so question is, how can amount of internal disk space on android device available app can download , accurate , can use.

thanks!

i found solution. use code:

public long phone_storage_free() {             long val=0;     file path = environment.getdatadirectory();     statfs stat = new statfs(path.getpath());     long blocksize = stat.getblocksize();     long availableblocks = stat.getavailableblocks();     val=availableblocks * blocksize;     return val; } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -