What is the diskspace free and used in android? -


a code/simple function return available , used diskspace in main android device.

is making df command , parsing best way? other methods can used?

many in advance

i managed fix make nice class.

// phone storage public static long phone_storage_free(){     file path = environment.getdatadirectory();     statfs stat = new statfs(path.getpath());     long free_memory = stat.getavailableblocks() * stat.getblocksize(); //return value in bytes      return free_memory; }  public static long phone_storage_used(){     file path = environment.getdatadirectory();     statfs stat = new statfs(path.getpath());     long free_memory = (stat.getblockcount() - stat.getavailableblocks()) * stat.getblocksize(); //return value in bytes      return free_memory; }  public static long phone_storage_total(){     file path = environment.getdatadirectory();     statfs stat = new statfs(path.getpath());     long free_memory = stat.getblockcount() * stat.getblocksize(); //return value in bytes      return free_memory; }     // sd card public static long sd_card_free(){      file path = environment.getexternalstoragedirectory();     statfs stat = new statfs(path.getpath());     long free_memory = stat.getavailableblocks() * stat.getblocksize(); //return value in bytes      return free_memory; } public static long sd_card_used(){      file path = environment.getexternalstoragedirectory();     statfs stat = new statfs(path.getpath());     long free_memory = (stat.getblockcount() - stat.getavailableblocks()) * stat.getblocksize(); //return value in bytes      return free_memory; } public static long sd_card_total(){      file path = environment.getexternalstoragedirectory();     statfs stat = new statfs(path.getpath());     long free_memory = stat.getblockcount() * stat.getblocksize(); //return value in bytes      return free_memory; } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -