Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between URI and Uri class

Tags:

java

android

I am confused , how to use Uri because i am using it in android development at Intent's Action dial

Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:555-2368"));

What I want to do :

I want to create a file inside which I want to put 2 phone numbers. Then, I want to use toUri() method with this file, and want to put that Uri in the intent, then I want to see what happens with the intent.

like image 826
Tushar Avatar asked Apr 16 '13 07:04

Tushar


People also ask

What is the difference between URI and URL with example?

URI contains both URL and URN to identify the name and location or both of a resource; in contrast, URL is a subset of URI and only identifies the location of the resource. The example of URI is urn:isbn:0-476-27557-4, whereas the example of URL, is https://google.com.

What do you mean by URI?

A Uniform Resource Identifier (URI) is a character sequence that identifies a logical (abstract) or physical resource -- usually, but not always, connected to the internet. A URI distinguishes one resource from another. URIs enable internet protocols to facilitate interactions between and among these resources.

What is the difference between URI and path?

Uniform Resource Identifier (URI) is a structured format to identify where something is, be it locally or remote. As such Path is a loose term with no definition, where URI is specifically defined.

What is difference between URL URI and urn?

URI (uniform resource identifier) identifies a resource (text document, image file, etc) URL (uniform resource locator) is a subset of the URIs that include a network location. URN (uniform resource name) is a subset of URIs that include a name within a given space, but no location.


2 Answers

According to the Android API docs you can create a file Uri with:

public static Uri fromFile (File file)

like image 198
vbence Avatar answered Oct 05 '22 11:10

vbence


java.net.URI is mutable

android.net.Uri is immutable

java.net.URI

A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC 2396.

android.net.Uri . A URI reference includes a URI and a fragment, the component of the URI following a '#'. Builds and parses URI references which conform to RFC 2396.

In the interest of performance, this class performs little to no validation. Behavior is undefined for invalid input. This class is very forgiving--in the face of invalid input, it will return garbage rather than throw an exception unless otherwise specified.

like image 36
Pragnani Avatar answered Oct 05 '22 10:10

Pragnani