Why is USB Storage being detected only in some android devices and not all?

Updated on February 11, 2020 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on February 11, 2020

I am working on a sample project in unity android where application creates a text in an OTG pen drive connected to the android phone, the problem is my code works fine in some devices but it doesn’t work in some devices. I am unable to figure out the main cause even through the logcat extreme as it doesn’t throw any error at all that specifies code error.

 

I tried adding text logs to print text in between the code to see which texts are not printed, which would further tell me that after which line code stopped working but all the texts are printed.

 

This is my code that detects the USB and returns true if a text file is present in USB:

https://stackoverflow.com/questions/60168633/why-is-usb-storage-being-detected-only-in-some-android-devices-and-not-all

 

This code works on my android phone and returns true after detecting the file present in Pendrive.

 

Can anyone tell me what could be the issue and point me in the right direction, I will greatly appreciate your support on this.

 

This locateFile() function is called on Update().

  • Liked by
Reply