i need to list only the files present on a sdcard.
With the following code:
File sdcard=new File(Environment.getExternalStorageDirectory().getAbsolutePath());
if(sdcard.isDirectory()){
String files[]= sdcard.list();
for(int i=0;i<files.length;i++){
File f=new File(files[i]);
if(!f.isDirectory())
Log.d("FILES",files[i]);
}
}
I see also in the log the subdirectories. What am i doing wrong?
Try this:
The key difference is
sdcard.files()vssdcard.listFiles().