FilePickerLibrary icon indicating copy to clipboard operation
FilePickerLibrary copied to clipboard

Navigation to the external SD card

Open u2gilles opened this issue 10 years ago • 9 comments

Is it possible to navigate to the external SD card. I can't select it. Thanks in advance and kind regards.

u2gilles avatar Feb 12 '15 05:02 u2gilles

Ill look into this. Does it work when you try the demo app?

DeveloperPaul123 avatar Feb 13 '15 04:02 DeveloperPaul123

Same with the demo. I looked into the code and the problem is that you are using Environment.getExternalStorageDirectory(), which return the top directory of the internal memory of the device, On my samsung S4, this is : /storage/emulated/0/. But the top directory of the SD card is /storage/extSdCard. Of course you can't hardcode these names as different manufacturers use different names. Good luck.

u2gilles avatar Feb 13 '15 09:02 u2gilles

It seems like I just need to make the parent directory just /storage, then the user can navigate wherever they want to. What I think I'm going to do is allow users to pass a start directory themselves and that way you can make it whatever you'd like.

DeveloperPaul123 avatar Feb 14 '15 01:02 DeveloperPaul123

I cloned locally your lib. When I tried this method, there were plenty of drives like usb1, usb2 etc... and when you click on it the app crashes. I read in forums that /storage/extSdCard not be the same on all decices. If you hardcode the sd drive, I recommend that you test the existence of "/storage/extSdCard" folder.

In my case, I had the top sd card directory availabe in my app so I just pass it to the cloned lib in the intend. The way I got it in my app (an ActionBarActivity) is not so nice but pretty safe I think. Basically I took 4 times the parent of the sd app root folder (/storage/extSdCard/Android/data/myapp/files) to get the sd drive root folder (/storage/extSdCard). But it is only a personal app (not for the store). I was lazy to look up in the official API.

isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

File[] files = android.support.v4.content.ContextCompat.getExternalFilesDirs(this, null); appFolderDevice = files[0].toString(); if (isSDPresent){ appFolderSD = files[1].toString(); File appFolderSDFile = new File(appFolderSD); appFolderSDFile = appFolderSDFile.getParentFile().getParentFile().getParentFile().getParentFile(); rootFolderSD = appFolderSDFile.getAbsolutePath(); }

u2gilles avatar Feb 14 '15 03:02 u2gilles

Did the code above work?

DeveloperPaul123 avatar Mar 05 '15 04:03 DeveloperPaul123

yes but i tested it only on my samsung s4. It should also work on all android devices as they all should have the same file system structure (application folder at the fourth level). I cross fingers.

u2gilles avatar Mar 05 '15 05:03 u2gilles

Ok Ill let you know what happens

DeveloperPaul123 avatar Mar 06 '15 03:03 DeveloperPaul123

First,thank you for your work. External Sd card doesnt work here at Marshmellow. Any Help?

Madaditya avatar Jun 01 '16 17:06 Madaditya

@Madaditya this is still a work in progress. I haven't had the opportunity to add this feature yet but it's on the list of todos.

DeveloperPaul123 avatar Jun 01 '16 23:06 DeveloperPaul123