国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android編程實現(xiàn)獲得內(nèi)存剩余大小與總大小的方法

2020-04-11 11:14:13
字體:
來源:轉載
供稿:網(wǎng)友

本文實例講述了Android編程實現(xiàn)獲得內(nèi)存剩余大小與總大小的方法。分享給大家供大家參考,具體如下:

public class memInfo { // 獲得可用的內(nèi)存 public static long getmem_UNUSED(Context mContext) {  long MEM_UNUSED;  // 得到ActivityManager  ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);  // 創(chuàng)建ActivityManager.MemoryInfo對象   ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();  am.getMemoryInfo(mi);  // 取得剩余的內(nèi)存空間   MEM_UNUSED = mi.availMem / 1024;  return MEM_UNUSED; } // 獲得總內(nèi)存 public static long getmem_TOLAL() {  long mTotal;  // /proc/meminfo讀出的內(nèi)核信息進行解釋  String path = "/proc/meminfo";  String content = null;  BufferedReader br = null;  try {   br = new BufferedReader(new FileReader(path), 8);   String line;   if ((line = br.readLine()) != null) {    content = line;   }  } catch (FileNotFoundException e) {   e.printStackTrace();  } catch (IOException e) {   e.printStackTrace();  } finally {   if (br != null) {    try {     br.close();    } catch (IOException e) {     e.printStackTrace();    }   }  }  // beginIndex  int begin = content.indexOf(':');  // endIndex  int end = content.indexOf('k');  // 截取字符串信息  content = content.substring(begin + 1, end).trim();  mTotal = Integer.parseInt(content);  return mTotal; }}

希望本文所述對大家Android程序設計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 怀柔区| 宁明县| 临洮县| 郯城县| 梁山县| 微山县| 芒康县| 九寨沟县| 邻水| 淄博市| 和田县| 东兴市| 广昌县| 登封市| 曲靖市| 改则县| 新密市| 罗城| 合阳县| 高雄市| 礼泉县| 达尔| 彭州市| 井研县| 靖江市| 和政县| 扎囊县| 牡丹江市| 会昌县| 齐齐哈尔市| 连城县| 湛江市| 宜兴市| 岱山县| 汝南县| 巢湖市| 和顺县| 平邑县| 任丘市| 乐业县| 庆云县|