0

I have this code,

  public static boolean deleteDirectory(File path) {
        // TODO Auto-generated method stub
        if( path.exists() ) {
            File[] files = path.listFiles();
            for(int i=0; i<files.length; i++) {
                if(files[i].isDirectory()) {
                    deleteDirectory(files[i]);
                }
                else {
                    files[i].delete();
                }
            }
        }
        return(path.delete());
    }

I want to call this method and delete SDcards' contents, what path should i use ?

slayton
  • 20,123
  • 10
  • 60
  • 89
emna
  • 47
  • 1
  • 4
  • 8
  • you want to delete all the files or just your own files in sdcard? – nandeesh Aug 16 '12 at 13:40
  • possible duplicate of [Find an external SD card location](http://stackoverflow.com/questions/5694933/find-an-external-sd-card-location) – slayton Aug 16 '12 at 13:41
  • @H2CO3 : it doesn't except that as type File, i must add something as type File – emna Aug 16 '12 at 13:45

1 Answers1

3

use

Environment.getExternalStorageDirectory() to get the external storage directory

Check the documentation before you use it.

nandeesh
  • 24,740
  • 6
  • 69
  • 79