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