title: android clear log programmatically
body: <p>I want to get the whole log (Log.d(...)), after pressing a button to analyse some parts of our app (count something...). I'm able to do this by the following code: </p>
  
  <pre><code>HashMap&lt;String, Integer&gt; hashMapToSaveStuff = new HashMap&lt;String, Integer&gt;();
  int count= 0;
  String toCount= "";
  try {
          Process process = Runtime.getRuntime().exec("logcat -d");
          BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
          String line;
          while ((line = bufferedReader.readLine()) != null) {
              if (line.contains("MYSTRING")) {
                  toCount = line.substring(line.indexOf(":") + 1);
                  if (hashMapToSaveStuff.containsKey(toCount)) {
                      count = hashMapToSaveStuff.get(toCount);
                      count++;
                  } else {
                      count= 1;
                  }
                  hashMapToSaveStuff.put(toCount, count);
              }
          }
      } catch (Exception e) {
  
      }
  </code></pre>
  
  <p>After that I'll send the result to our server and save it on database. Because of that I want to clear all the logs, I've already send. Trying to do this with the following code didn't work:</p>
  
  <pre><code>try {
          Process process = Runtime.getRuntime().exec("logcat -c");
          BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()), 1024);
          String line = bufferedReader.readLine();
      } catch (Exception e) {
  
      }
  </code></pre>
  
  <p>How can I clear the log?</p>