java - Fetch total Memory of Android Device -


i trying fetch total memory of android device. returns me 24gb. however, total internal memory of device 32gb.

i tried using ...

public long getinternalfreespace()    {     //get free bytes...     long bytesavailable = stat.getblocksizelong() * stat.getavailableblockslong();     return bytesavailable; } 

use this:

public static long getavailableinternalmemorysize() {     file path = environment.getdatadirectory();     statfs stat = new statfs(path.getpath());     long blocksize = stat.getblocksize();     long availableblocks = stat.getavailableblocks();     long size = availableblocks * blocksize;     long availableblocksinkb = size /= 1024;     long availableblocksinmb = availableblocksinkb /= 1024;     return availableblocksinmb; } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -