Chris Simpson Chris Simpson - 2 years ago 77
Android Question

How do I determine whether a path is a local file or not

Given just a location as a string, is there a reliable way to determine if this is a local file (such as /mnt/sdcard/test.jpg) or a remote resource (such as

Converting it to a Uri with Uri.parse doesn't seem to give me anything to indicate where the file is.

I don't really want to have to look for // in the string!

Answer Source

uri format is


local files have:


or just


so if string starts with


and this is not file:// then this is url

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download