title: How to clear entire app data without force closing the app in android
body: <p>I want to clear the entire app data like  </p>
  
  <pre><code>Settings-&gt;Applications-&gt; ManageApplications-&gt; My_application-&gt;Clear Data.
  </code></pre>
  
  <p>I tried this code but it is force closing the app.</p>
  
  <pre><code>try {
    // clearing app data
    String packageName = getActivity().getPackageName();
    Runtime runtime = Runtime.getRuntime();
    runtime.exec("pm clear " + packageName);
  } catch (Exception e) {
    e.printStackTrace();
  }
  </code></pre>
  
  <p>Please help me to solve the issue, Thank you.</p>