I'm trying to get the total internal storage and available storage for the android device but the code I have only gets the available disk space. Any advice on how to get total storage space.
private fun getStorage() {
val stat = StatFs(Environment.getDataDirectory().path)
val bytesAvailable: Long = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
stat.blockSizeLong * stat.availableBlocksLong
} else {
TODO("VERSION.SDK_INT < JELLY_BEAN_MR2")
}
val gbAvailable = (bytesAvailable / (1024 * 1024) ) * 0.001
Log.d("Storage", "Available GB : ${gbAvailable.roundToInt()}")
}