title: Removing Preference data when Application killed
body: <p>In my application i am storing some SharedPreference data. </p>
  
  <p>I have to clear that all stored data when application killed.</p>
  
  <p>So, I have done it in my activity's <code>onDestroy()</code> as below : </p>
  
  <pre><code>@Override
  protected void onDestroy() {
  
      if(isBackPressed==0){
          if(Prefrences.checkPref(MyActivity.this,MAIN_PREF)){
              Prefrences.removePref(MyActivity.this,MAIN_PREF);
              Prefrences.removePref(MyActivity.this,PREF_1);
              Prefrences.removePref(MyActivity.this,PREF_2);
              Constant.displayLogE("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;","### Prefrence removed ");
          }
          Constant.displayLogE("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;","### Destroy activity ");
      }
      finish();
      super.onDestroy();
  }
  </code></pre>
  
  <p>Here, I have taken <code>isBackPressed</code> because, When onBackPressed called it calles finish() automatically and onDestroy() method calls. So, I have initialized <code>isBackPressed</code> to 1 inside <code>onBackPressed()</code> method.</p>
  
  <p>It doesn't matter, I just have to remove my prefrence data when app going to be killed. But, the issue is when I killing app, <code>onDestroy()</code> methos not calling.</p>
  
  <p>Thanks.</p>