开发者

How to detect that file is located on SD card?

开发者 https://www.devze.com 2023-04-07 23:33 出处:网络
Is there any durable way to detect that is file located somewhere on external (detachable/dismountable) storage?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号