优化大师
程序员文章站
2022-05-21 09:14:30
...
剩下的几个未完成的给几个提示,其实就是文件读写操作,handler,还有TimeTask结合去处理,然后绘图,更新ui
/sys/class/net
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
/proc/stat
/proc/self/net/dev
/proc/meminfo 这几个文件一看名字你们就懂,不过这几个文件在ddms中你看不到哟,不能导出来.
再贴几个方法
public long getAvailMemory() { ActivityManager am = (ActivityManager)mContext.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); am.getMemoryInfo(mi); return mi.availMem; }
public long[] getRomMemroy() { long[] romInfo = new long[2]; //Total rom memory romInfo[0] = getTotalInternalMemorySize(); //Available rom memory File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); romInfo[1] = blockSize * availableBlocks; getVersion(); return romInfo; } public long getTotalInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; }
public long[] getSDCardMemory() { long[] sdCardInfo=new long[2]; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { File sdcardDir = Environment.getExternalStorageDirectory(); StatFs sf = new StatFs(sdcardDir.getPath()); long bSize = sf.getBlockSize(); long bCount = sf.getBlockCount(); long availBlocks = sf.getAvailableBlocks(); sdCardInfo[0] = bSize * bCount;//总大小 sdCardInfo[1] = bSize * availBlocks;//可用大小 } return sdCardInfo; }
public void getTotalMemory() { String str1 = "/proc/meminfo"; String str2=""; try { FileReader fr = new FileReader(str1); BufferedReader localBufferedReader = new BufferedReader(fr, 8192); while ((str2 = localBufferedReader.readLine()) != null) { Log.i(TAG, "---" + str2); } } catch (IOException e) { } }
工程在附件里面
上一篇: 删除所有存储过程