8

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.

sdgfsdh
  • 24,047
  • 15
  • 89
  • 182
Tushar
  • 75
  • 1
  • 4

3 Answers3

6

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

public static Uri fromFile (File file)

vbence
  • 19,252
  • 8
  • 61
  • 111
5

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.

Pragnani
  • 19,755
  • 6
  • 46
  • 74
  • please give a simple example , – Tushar Apr 16 '13 at 08:38
  • what is the benefit of making them as immutable . – Tushar Apr 16 '13 at 08:47
  • 2
    java.net.URI is not mutable. From JavaDocs: "This class provides constructors for creating URI instances from their components or by parsing their string forms, methods for accessing the various components of an instance, and methods for normalizing, resolving, and relativizing URI instances. Instances of this class are immutable." – Jeff Oct 15 '14 at 16:55
0

URIs identify and URLs locate; however, locations are also identifications, so every URL is also a URI, but there are URIs which are not URLs.

URL - http://example.com/some/page.html

URI - /some/page.html

Nirav Ranpara
  • 15,268
  • 4
  • 40
  • 57