How to detect that file is located on SD card?
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 开发者_StackOverflow社区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?
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.
精彩评论