0

i do not understand why only by emulator, i can't read files that i have into my SD card directory (send it by DDMS). This is how i create a directory:

public static boolean makeDirectory(Context context){
    boolean make= true;
    String sp = Utility.getDirectory();

    File dirp = new File(Environment.getExternalStorageDirectory(), sp);        

    if (!dirp.exists()) {
        if (!dirp.mkdirs()) {
            return false;
        }
    }
    return make;
}   

public static String getDirectory(){
        return Environment.getExternalStorageDirectory()+"/EchoDrive/";
}

this is how i read my directory:

File directory = new File(Utility.getDirectory()); 
File[] files = directory.listFiles();

why from Android emulator array files is always null? thanks!

fabio
  • 271
  • 5
  • 18

1 Answers1

0

Refresh the SD card. Try this code :

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));

Aditya Gupta
  • 508
  • 3
  • 18