Skip to content Skip to sidebar Skip to footer

Android App Data Storage Keeps Increasing

I am developing an android app that basically loads up a list of news articles and opens them up in a webview upon user click. What I'm wondering about is when I look at my app de

Solution 1:

I know that is over 2 years, but it could be useful for someone else. I discovered that the problem resides in the WebView and not in the SharedPreferences I had the same problem and solved by overriding the onPause() method in this way:

private WebView wv;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    wv = new WebView(this);
    setContentView(wv);
    wv.loadUrl("http://www.stackoverflow.com");
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    wv.clearCache(true);
}

The clearCache method takes a boolean argument that lets you specify whether you want to include disk files that the WebView stores. If you enable it your data usage will significantly decrease. Hope it helps!


Post a Comment for "Android App Data Storage Keeps Increasing"