Collect all Log.d from class and save it into SDCard

后端 未结 4 592
别跟我提以往
别跟我提以往 2021-01-20 05:46

Hey is it possible in Android to collect all Log.d from one class and keep on appending it and save it into SDCard ?

For example :

Class Android {

          


        
4条回答
  •  鱼传尺愫
    2021-01-20 06:00

    If you want to add logs with tag name and

    logcat -s 
    

    Is not working for you then you can do this trick

    //... Brtle 's code..(accepted one )
        file.createNewFile();
           FileWriter writer = new FileWriter(file);
             while((line = in.readLine()) != null){
                 if(line.contains("TAG_NAME")){ // Trick :-)
                    writer.write(line + "\n");
                   }
                 }
    

提交回复
热议问题