The difference is that Android.Net.Uri
is Google's own implementation of RFC 2396.
Android.Net.Uri
is immutable, hence it is thread-safe. Their implementation is also, according to the comments in the source, more forgiving. So while Java.Net.Uri
would throw an Exception
you attempt to use a garbage Uri, the Android implementation would just return you a Uri with that garbage.
As far as I can tell, Android.Net.Uri
will only throw NullPointerException and seemingly no other exceptions. While the Java.Net.Uri
implementation will throw other exceptions such as URISyntaxException
and IllegalArgumentException
Otherwise they seem very similar.
The Uri you get file:/sdcard/MyFolder/MyFile.txt
is valid, and when throwing it through java.net.URI
I get following:
java> String uri = "file:/sdcard/MyFolder/MyFile.txt";
java> import java.net.*
java> URI urr = new URI(uri);
java.net.URI urr = file:/sdcard/MyFolder/MyFile.txt
java> urr.getScheme();
java.lang.String res2 = "file"
java> urr.getPath();
java.lang.String res3 = "/sdcard/MyFolder/MyFile.txt"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…