一瘦材、獲取手機(jī)的存儲信息(注意是存儲容量,非運(yùn)行內(nèi)存信息仿畸。)
//獲取存儲信息
private String getRAMInfo() {
File directory = Environment.getExternalStorageDirectory();
long totalSpace = directory.getTotalSpace();
long usableSpace = directory.getUsableSpace();
String total = Formatter.formatFileSize(this, totalSpace);
String useAble = Formatter.formatFileSize(this, usableSpace);
return "可用 " + useAble +"/總共 " + total;
}
二食棕、獲取手機(jī)電量信息
//獲取電量信息
private int getElectricity() {
try {
BatteryManager batterymanager = (BatteryManager) getSystemService(BATTERY_SERVICE);
int intProperty = batterymanager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
return intProperty;
}catch (Exception e) {
e.printStackTrace();
return 0;
}
}