0

Is there any durable way to detect that is file located somewhere on external (detachable/dismountable) storage?

For sure there's a way to parse file path and extract file:///sdcard string, but as we know on some devices this path can be different, e.g. file:///mount/sdcard or file:///sdcard, not saying that some modern devices support USB host mode, so file easily can be placed on usb stick attached to device.

Any ideas?

Barmaley
  • 16,638
  • 18
  • 73
  • 146
  • What exactly you want existense of a known file? – ingsaurabh Sep 28 '11 at 07:00
  • @ingsaurabh depending on either file located in dismountable media or not, I plan to intercept media detaching broadcast and warn user about possible unavailability of particular file – Barmaley Sep 28 '11 at 07:07

1 Answers1

1

Get a location of external storage via Environment.getExternalStorageDirectory() and then compare it to the path of your file. Make sure you have the absolute path to your file.

Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • http://stackoverflow.com/questions/6156649/is-there-a-documented-way-in-android-2-x-to-inspect-multiple-sd-cards-for-conte/6156812#6156812 – Peter Knego Sep 28 '11 at 07:13