[android-developers] Re: how to list files on SD card

2010-09-16 Thread cindy
thank you all for the help. I got it.

Cindy

On Sep 16, 5:59 am, TreKing  wrote:
> On Thu, Sep 16, 2010 at 1:56 AM, cindy  wrote:
> > ANy example to use the api? I am confused.
>
> FilenameFilter has a single method "accept(File dir, String filename)" which
> returns true if the given parameters are what you're looking for.
>
> So you implement a class that extends FilenameFilter and override the accept
> method to return true if the given parameters are what you're looking for.
> So in your case you could check "filename" for starting with "voice" and
> ending in ".amr".
>
> Then you use the File.list() method with an instance of your newly defined
> class to get all the files that match your criteria. Then it's a simple
> matter of iterating the list and calling File.delete().
>
> Hope that helps.
>
> And do test thoroughly so you don't end up deleting all of the user's SD
> card contents =P
>
> -
> TreKing  - Chicago
> transit tracking app for Android-powered devices

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


Re: [android-developers] Re: how to list files on SD card

2010-09-16 Thread TreKing
On Thu, Sep 16, 2010 at 1:56 AM, cindy  wrote:

> ANy example to use the api? I am confused.


FilenameFilter has a single method "accept(File dir, String filename)" which
returns true if the given parameters are what you're looking for.

So you implement a class that extends FilenameFilter and override the accept
method to return true if the given parameters are what you're looking for.
So in your case you could check "filename" for starting with "voice" and
ending in ".amr".

Then you use the File.list() method with an instance of your newly defined
class to get all the files that match your criteria. Then it's a simple
matter of iterating the list and calling File.delete().

Hope that helps.

And do test thoroughly so you don't end up deleting all of the user's SD
card contents =P

-
TreKing  - Chicago
transit tracking app for Android-powered devices

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

Re: [android-developers] Re: how to list files on SD card

2010-09-16 Thread Kostya Vasilyev

 16.09.2010 12:09, karteek пишет:

You can use File apis as follows
   File f=new File("/sdcard");
if(f.isDirectory()){
 String files[]=  f.list();
 for(int i=0;iExcept that hard-coding "/sdcard" is bad - it's "/mnt/sdcard" in Froyo. 
Use Environment.getExternalStorageDirectory instead.


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

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


[android-developers] Re: how to list files on SD card

2010-09-16 Thread karteek
You can use File apis as follows
  File f=new File("/sdcard");
   if(f.isDirectory()){
 String files[]=  f.list();
 for(int i=0;i wrote:
> ANy example to use the api? I am confused.
>
> On Sep 15, 11:26 pm, Vinay S  wrote:
>
> > Pl. look 
> > athttp://developer.android.com/reference/java/io/FilenameFilter.html
>
> > On Sep 16, 8:40 am, cindy  wrote:
>
> > > Hi all,
>
> > >  My application needs to do some clean up. I need to list the files
> > > such as  " ls voice*.amr", and then delete those files. How could I do
> > > it in Android?
>
> > > Thanks !
>
> > > Cindy
>
>

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


[android-developers] Re: how to list files on SD card

2010-09-15 Thread cindy
ANy example to use the api? I am confused.

On Sep 15, 11:26 pm, Vinay S  wrote:
> Pl. look athttp://developer.android.com/reference/java/io/FilenameFilter.html
>
> On Sep 16, 8:40 am, cindy  wrote:
>
> > Hi all,
>
> >  My application needs to do some clean up. I need to list the files
> > such as  " ls voice*.amr", and then delete those files. How could I do
> > it in Android?
>
> > Thanks !
>
> > Cindy

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


[android-developers] Re: how to list files on SD card

2010-09-15 Thread Vinay S
Pl. look at http://developer.android.com/reference/java/io/FilenameFilter.html

On Sep 16, 8:40 am, cindy  wrote:
> Hi all,
>
>  My application needs to do some clean up. I need to list the files
> such as  " ls voice*.amr", and then delete those files. How could I do
> it in Android?
>
> Thanks !
>
> Cindy

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