public class AndroidSdCardActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
readFile();
}
private void readFile() {
File file = Environment.getExternalStorageDirectory();
File[] files = file.listFiles();
readFile(files);
}
private void readFile(final File[] files){
if(files!=null && files.length>0){
for(int i=0;i<files.length;i++){
if(files[i].isDirectory()){
final int tag=i;
new Thread(new Runnable() {
@Override
public void run() {
readFile(files[tag].listFiles());
}
}).start();
}else{
Log.d("name", files[i].getName());
}
if(i==files.length-1){
}
}
}
}
}