Since Honeycomb (3.x), Google has prevented apps to run networking operations on the main thread, since it would cause the app to freeze while it's waiting for the network operation to finish.

There aren't many easy solutions to understand, and many use tons of code and usually extend the class AsyncTask, which is needless. If you only need to fetch text resources from the Internet, this code below will do.

Basically put your existing code inside the try/catch block and hope it'll work :D

Thread thread = new Thread(new Runnable(){
    @Override
    public void run() {
        try {
            // PUT CODE HERE!
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
});

thread.start();