Save Data of LogCat in android

前端 未结 5 1540
盖世英雄少女心
盖世英雄少女心 2021-02-04 19:09

I want to save all the contents of log cat into specific file in Android. I used Eclipse IDE to develop the android application.

How i can achieve this ?

Thanks.

5条回答
  •  情话喂你
    2021-02-04 19:59

    Here is a way to get the Logcat contents progrmatically.

     Process process = Runtime.getRuntime().exec("logcat -d");
    
     BufferedReader bufferedReader = new BufferedReader(
         new InputStreamReader(process.getInputStream()));
    
     StringBuilder log=new StringBuilder();
     String line = "";
     while ((line = bufferedReader.readLine()) != null) {
         log.append(line);
     }
    

    Check this link for more details.

提交回复
热议问题