I'm using the afilechooser module to select a file from the user's device. The device has both internal storage and external storage. when I select a file from internal storage the path is returned correctly the uri looks like this:
Uri =content://com.android.externalstorage.documents/document/primary%3Amyfile.txt
However, the afilechooser fails when I select a file from the external sd card and the URI looks like this:
Uri = content://com.android.externalstorage.documents/document/3935-6562%3Amyfile.txt
So I was looking at the code in the afilechooser getPath method and it has this condition:
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
Now I can see that it's not getting the path because instead of containing primary it contains "3935-6562" Now I can just write another condition to test for this but I am wondering. On this device it's "3935-6562" But on a different device would it still be the same numbers? If they are different depending on device how can I make it so it will work? Also If the "3935-6562" is something that is the same across all devices how would I get the path to it since Environment.getExternalStorageDirectory() seems to be returning the internal sd path, not the external
Thanks in advance. I'm still learning this stuff so please be as simple as possible.