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
Post a Comment