mardi 27 janvier 2015

[Q] I need some help with aFileChooser topic






Hey all,

I'm kinda stuck on something and was hoping someone could point me in the right direction. I have an app that is using the aFileChooser module. Basically I have the chooser come up and the user will select a file from either internal, external or OTG storage. with aFileChooser if they select a file from the internal sd card it works. If they select a file from either External USB Storage or External SD card it does not. I have noticed in the getPath method in FileUtils in aFileChooser it has this condition:


Code:


if ("primary".equalsIgnoreCase(type)) {
      Log.i ("PRIMARY", Environment.getExternalStorageDirectory() + "/" + split[1]);
      return Environment.getExternalStorageDirectory() + "/" + split[1];
}


Now when the user selects a file from the internal card this condition is satisfied here is the uri:
Uri =content://com.android.externalstorage.documents/document/primary%3Amyfile.txt

So it will return the correct path /storage/emulated/0/myfile.txt

Now when I select a file from the external card this is the Uri:
Uri = content://com.android.externalstorage.documents/document/3935-6562%3Amyfile.txt

Same for the OTG storage the uri is
Uri = content://com.android.externalstorage.documents/document/2841-32E9%3Amyfile.txt

So there are no conditions to deal with if type = 3935-6562 or 2841-32E9 But is this the same identifier across all devices or will these change depending on device? I don't want to hardcode for these and have them be different on device and then how would I get the correct path even if I did hard code the numbers?

I just want the chooser to return the correct path depending on what stoage they picked
on my device that's /storage/sdcard1 and /storage/usbdisk but I know this will be different on different devices so I don't really want to hard code anything.

Any help would be appreciated..






Aucun commentaire:

Enregistrer un commentaire