• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Button to Clear just my apps cache

suran37

Newbie
Dec 7, 2009
14
0
I have an app that loads up a lot of images and can become a hog on the memory I suppose. So I am trying to make it so the user can click a button to clear the cache of the app.

I have no idea how to do this but so far i have the button :p
Code:
public class Clear extends Activity {
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.clear);

        final Button trimCache = (Button) findViewById(R.id.trimCache);
        trimCache.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //clear the cache here
            }
        });
    }
}
How would I go about making it clear only my apps cache?
Also as a little bonus can i make it so it sends like a back command so that it returns to the main part of the app since this "Clear" page is accessed via a menu?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones