How to Get a new URL Connection

public URLConnection openConnection () was added in API level 1
Returns a new connection to the resource referred to by this URL.
Throws: IOException - if an error occurs while opening the connection.

1. Create a new URL object named myUrl.

2. Declare a URLConnection object named myURLConnection

3. In the MainActivity.java file, add the below line to the imports section. 

import java.io.IOException;

4. Add the below catch statement under the MalformedURLException catch you created when you created the URL object. You may choose to add Log also.

catch (IOException e) { 
e.printStackTrace();
//Toast.makeText(this, "URL:No I/O Exception", Toast.LENGTH_LONG).show();
}

5. Add the below line in the try/catch right after you create your URL named myUrl above(in step #1). This must be in the try/catch statement.

myURLConnection = myUrl.openConnection();

6. Compile and run!

Resources:
http://developer.android.com/reference/java/net/URL.html#openConnection()