I had the same problem. I did not know how to access an external SD card. I developed an application in which I had to access an external SD card to read and write some things. I tried various methods, including predefined Android libraries. These are the methods I used: -
These were misses: -
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File myFile = new File(path, "test.txt");
File root = Environment.getExternalStorageDirectory();
File dir = new File(root.getAbsolutePath()+"/Download");
File f = getExternalFilesDir(null);
File file = new File(f,"test.txt");
"/storage/sdcard0" "/storage/emulated/0". , Android . , 16 , SD-, SD-, Android .
, : -
String extFilePath = "/storage/sdcard1/Download";
File myFile = new File(extFilePath, "test.txt");
. , , Android, .
, , : -
String sdpath,sd1path,usbdiskpath,sd0path;
if(new File("/storage/extSdCard/").exists())
{sdpath="/storage/extSdCard/";
Log.i("Sd Cardext Path", sdpath);}
if(new File("/storage/sdcard1/").exists())
{sd1path="/storage/sdcard1/";
Log.i("Sd Card1 Path",sd1path);}
if(new File("/storage/usbcard1/").exists())
{usbdiskpath="/storage/usbcard1/";
Log.i("USB Path",usbdiskpath);}
if(new File("/storage/sdcard0/").exists())
{sd0path="/storage/sdcard0/";
Log.i("Sd Card0 Path",sd0path);}
, SD-. , .