title: Destroy webview in Android
body: <h2>Fail To Destroy WebView</h2>
  
  <p>Firstly, a lot of example i had been tried for destroy the webview in Android. </p>
  
  <p>For example:
  <a href="https://stackoverflow.com/questions/3130654/memory-leak-in-webview">Memory Leak in Android</a></p>
  
  <p>Although i was destroying webview in the onDestroy() and declared a webview programmatically, but the memory leak problem also will be occurred in my Android device.</p>
  
  <p>Below is my coding..</p>
  
  <pre><code>public class MainActivity extends Activity {
  private FrameLayout mWebContainer;
  private WebView mWebView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.your_layout);
  
      mWebContainer = (FrameLayout) findViewById(R.id.web_container);
      mWebView = new WebView(getApplicationContext());
      mWebContainer.addView(mWebView);
  }
  
  @Override
  protected void onDestroy() {
      super.onDestroy();
  
      mWebContainer.removeAllViews();
      mWebView.clearHistory();
      mWebView.clearCache(true);
      mWebView.clearView();
      mWebView.destroy();
      mWebView = null;        
  }
  </code></pre>
  
  <p>Someone help me please.. thank you..</p>