Help fetching data from the web

Put your problem here if it does not fit any of the other categories.

Help fetching data from the web

Postby brakim » Tue Feb 08, 2011 9:13 pm


I just want to say that i'am supernew to both android and java, i have erlier coded in php so i know the basic logic in codeing.

I'am just for fun now trying to make a app that is fetching data from a website, actually a local newpaper where i live.

I basically have two problem to begin with, the first one is that it only loads data to fill the screen and nothing more, and how i proceed to chose what data to pick, i mean if a can somehow choose to only get all the <h3> tags in a list.

Here is my code
Code: Select all
package com.kimbrannlund.lesson2;

import org.apache.http.util.ByteArrayBuffer;
import android.os.Bundle;
import android.widget.TextView;

public class Lesson2Main extends Activity {
        public void onCreate(Bundle icicle) {

                /* We will show the data we read in a TextView. */
                TextView tv = new TextView(this);
                /* Will be filled and displayed later. */
                String norranData = null;
                try {
                        /* Define the URL we want to load data from. */
                        URL norranURL = new URL(
                        /* Open a connection to that URL. */
                        URLConnection ucon = norranURL.openConnection();

                        /* Define InputStreams to read from the URLConnection. */
                        InputStream is = ucon.getInputStream();
                        BufferedInputStream bis = new BufferedInputStream(is);
                        /* Read bytes to the Buffer until there is nothing more to read(-1). */
                        ByteArrayBuffer baf = new ByteArrayBuffer(50000);
                        int current = 0;
                        while((current = != -1){

                        /* Convert the Bytes read to a String. */
                        norranData = new String(baf.toByteArray());
                } catch (Exception e) {
                        /* On any Error we want to display it. */
                      norranData = e.getMessage();
                /* Show the String on the GUI. */

Would be super thansful also if someone knew a good tutorial for this kind of app deveolopment.
Once Poster
Once Poster
Posts: 1
Joined: Tue Feb 08, 2011 8:39 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 46 guests