I am working on an android application to read data from USB. The usb can be connected to android with serial port and my app can find it.
Now, I want to read data files and folder from USB. I have read many articles. I found that they use this code :
Environment.getExternalStorageDirectory();
However in my case, I got that the path is /storage/emulated/0. When I try to read all the files which are contained in the path, I got the following statements:
/storage/emulated/0/Android
/storage/emulated/0/Music
/storage/emulated/0/Podcasts
/storage/emulated/0/Ringtones
and etc.
but the path of my usb is not found. So, I'm not sure is it the correct way to read files from USB?
Here is my code :
File f = Environment.getExternalStorageDirectory();
File[] files = f.listFiles();
String fol = "";
for (File inFile : files) {
if (inFile.isDirectory()) {
fol += inFile.toString()+"\n";
}
}
TextView tv = (TextView) findViewById(R.id.demoTitle);
tv.setText(fol);