i was not talking about the files which my app writes on the local file
system.

I was talking about the "Clear Cache" button in here "Settings --> Apps -->
Manage Apps --> "My App" --> Clear Cach"

Is this the right way?


public static void trimCache(Context context) {
        File dir = context.getCacheDir();
        if(dir!= null && dir.isDirectory()){
            File[] children = dir.listFiles();
            if (children == null) {
                // Either dir does not exist or is not a directory
            } else {
                File temp;
                for (int i = 0; i < children.length; i++) {
                    temp = children[i];
                    temp.delete();
                }
            }

        }

    }



On Mon, Aug 3, 2009 at 12:43 PM, Dianne Hackborn <[email protected]>wrote:

> Delete all of your cache files.  They are your files, you can do what you
> want with them.
>
> On Sun, Aug 2, 2009 at 11:46 PM, for android <[email protected]> wrote:
>
>> <<Settings --> Apps --> Manage Apps --> "My App" --> Clear Cache>>
>>
>>
>> How do we clear this cache progrmatically?
>>
>>
>> On Sun, Jul 26, 2009 at 3:44 AM, niko001 <
>> [email protected]> wrote:
>>
>>>
>>> Hi Mark,
>>>
>>> thanks for your answer.
>>>
>>> I mean the cache that the users can delete themselves by going to
>>> Settings --> Apps --> Manage Apps --> "My App" --> Clear Cache
>>>
>>> Thanks for your suggestion, I'll try it!
>>>
>>> Niko
>>>
>>>
>>> On Jul 25, 2:27 am, Mark Murphy <[email protected]> wrote:
>>> > niko001 wrote:
>>> > > is it possible to force thecacheof your app to clear when the user
>>> > > exits the app?
>>> >
>>> > > My app piles upcachedata (rightfully so) on each start, which is no
>>> > > longer needed once the user quits the app, so I am trying to find a
>>> > > way to forcibly clear it.
>>> >
>>> > You could try deleting the files from getCacheDir(), available on
>>> > Activity, Service, and other flavors of Context.
>>> >
>>> > On the other hand, you did not specify whichcacheyou were concerned
>>> > about...
>>> >
>>> > --
>>> > Mark Murphy (a Commons Guy)http://commonsware.com|
>>> http://twitter.com/commonsguy
>>> >
>>> > _The Busy Coder's Guide to *Advanced* Android Development_
>>> > Version 1.0 Available!
>>>
>>>
>>
>>
>>
>
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to