Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

Carl Taggett
Carl Taggett
10,260 Points

Android Question BlogReader Getting Data from the Web: Trying Code and Catching Exceptions

Declare a constant String variable named URL and set it to "teamtreehouse.com". Declare it as a static constant like we did in the video?

static final String URL = (teamtreehouse.com); ????

5 Answers

Paul Stevens
Paul Stevens
4,125 Points

Hello,

I think instead of brackets you need speech marks around the value:

static final String URL = "teamtreehouse.com";

Paul :)

Paul Stevens
Paul Stevens
4,125 Points

Hello,

You need to set the variable as public as well. Also the line should go above the @override.

package com.example;

import android.os.Bundle;
import android.view.View;
import java.net.MalformedURLException;
import android.util.Log;

public class MainListActivity extends ListActivity {

    //Declare a constant String variable named URL and set it to "teamtreehouse.com".
    public static final String URL = "teamtreehouse.com";  

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_list);


        // Add Task 2 code here
    }
}

Hope this helps, Paul :)

Carl Taggett
Carl Taggett
10,260 Points

package com.example;

import android.os.Bundle; import android.view.View; import java.net.MalformedURLException; import android.util.Log;

public class MainListActivity extends ListActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_list);

static final String URL = "teamtreehouse.com";

    // Add Task 2 code here
}

}

this the code i have however not working not sure what i'm missing

Carl Taggett
Carl Taggett
10,260 Points

got it! thanks for the help ;)