public static final String path="/sdcard/mokeelog"; public static String saveLog() throws IOException { String filePath=path; Runtime runtime=Runtime.getRuntime(); File file=new File(filePath); if(file.exists()) { file.delete(); } file.createNewFile(); RandomAccessFile raf=new RandomAccessFile(file, "rw"); raf.seek(raf.length()); raf.writeBytes("Device:"+android.os.Build.DEVICE); raf.writeBytes("\nVersion:"+CommonUtils.getInstalledVersion()); raf.writeBytes("\n***********************************************************\n"); raf.close(); runtime.exec("logcat -d -f "+filePath).destroy(); return filePath; } public static String getInstalledVersion() { return SystemProperties.get("ro.mk.version"); }