Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation to the external SD card #3

Open
u2gilles opened this issue Feb 12, 2015 · 9 comments
Open

Navigation to the external SD card #3

u2gilles opened this issue Feb 12, 2015 · 9 comments
Assignees
Milestone

Comments

@u2gilles
Copy link

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

@u2gilles u2gilles changed the title Is it possible to .... ? Navigation to the external SD card Feb 12, 2015
@DeveloperPaul123
Copy link
Owner

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

@u2gilles
Copy link
Author

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.

@DeveloperPaul123
Copy link
Owner

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.

@u2gilles
Copy link
Author

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();
}

@DeveloperPaul123
Copy link
Owner

Did the code above work?

@u2gilles
Copy link
Author

u2gilles commented Mar 5, 2015

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.

@DeveloperPaul123
Copy link
Owner

Ok Ill let you know what happens

@DeveloperPaul123 DeveloperPaul123 self-assigned this Jul 28, 2015
@DeveloperPaul123 DeveloperPaul123 added this to the Version 1.5 milestone Jul 28, 2015
@DeveloperPaul123 DeveloperPaul123 modified the milestones: Version 2.1.1, Version 2.1 Dec 6, 2015
@Madaditya
Copy link

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

@DeveloperPaul123
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants