Android newest mobile phone internal storage size, SD card storage size Method
We used to obtain this information in the past.
// Before Android API18: fs. getAvailableBlocks () * fs. getBlockSize ()
Currently:
/** get the system available memory **/
@ SuppressLint (" NewApi ")
Private String getMemFree () {
StatFs fs = new StatFs (Environment. GetDataDirectory () getPath ());
Return the Formatter. FormatFileSize (this, (fs) getAvailableBytes ()));
}
/** get SD free memory **/
@ SuppressLint (" NewApi ")
Private String getSdFree () {
If (Environment. GetExternalStorageState (.) the equals (Environment. MEDIA_MOUNTED)) {
StatFs fs = new StatFs (Environment. External.getexternalstoragedirectory () getPath ());
// before Android API18: fs.getavailableblocks ()* fs.getblocksize ()
Return the Formatter. FormatFileSize (this, (fs) getAvailableBytes ()));
}
Return "unloaded ";
}
Finally solved the problem.