Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8870081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:38:08+00:00 2026-06-14T17:38:08+00:00

I get this exception when i scroll my ListView and fetch new data when

  • 0

I get this exception when i scroll my ListView and fetch new data when last item in the list is reached.

This is the code to get new data:

public static String PostData(String url, String sa[][]) {

    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    int n = sa.length;
    for (int i = 0; i < n; i++) {
        nameValuePairs.add(new BasicNameValuePair(sa[i][0], sa[i][1]));
    }
    HttpPost httppost;
    try {
        httppost = new HttpPost(url);
    } catch (Exception e) {
    }
    try {
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    } catch (UnsupportedEncodingException e) {
    }
    HttpResponse response = null;
    try {
        response = client.execute(httppost);
    }catch (Exception e) {
    }
    HttpEntity entity = response.getEntity();
    try {
        is = entity.getContent();
    } catch (Exception e) {
    }
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8);
        sb = new StringBuilder();
        sb.append(reader.readLine());
        String line = "0";
        while ((line = reader.readLine()) != null) {
            sb.append("\n" + line);
        }
        result = sb.toString();
    } catch (Exception e) {
        //I get Exception here saying: Attempted read on closed stream
    }finally{
        try {
            reader.close();
        } catch (Exception e) {
        }
    }
}

the client i used is:

private static DefaultHttpClient client = getThreadSafeClient();

of

public static DefaultHttpClient getThreadSafeClient() {

    DefaultHttpClient client = new DefaultHttpClient();
    ClientConnectionManager mgr = client.getConnectionManager();
    HttpParams params = client.getParams();
    client = new DefaultHttpClient(new ThreadSafeClientConnManager(params,
            mgr.getSchemeRegistry()), params);
    return client;
}

The method PostData gets new 10 items when ever we scroll to the bottom of the ListView.

The problem is, this works fine, for first 3-4 scrolls, and later i get the Exception and the new 10 items added are from the previous data(duplication).

Some times i even get this Exception:

Socket closed

in place of

Attempted read on closed stream

but i haven’t used any Sockets, to try fixing it.

Edit:

Actually i have Log in every catch block, which prints the Exception. But i didn’t add all those Logs in the question. The ones which i get in the LogCat are listed above.

I keep getting these lines in the Logcats info:

11-21 15:49:57.735: I/System.out(1034): close [socket][/0.0.0.0:36508]
11-21 15:49:57.735: I/System.out(1034): close [socket][/0.0.0.0:36508]
11-21 15:50:02.978: I/System.out(1034): [socket][3] connection /76.74.166.78:80(0)
11-21 15:50:03.010: I/System.out(1034): /76.74.166.78:80(0)
11-21 15:50:03.330: I/System.out(1034): Socket[addr=/0.0.0.0,port=0,localport=33818]
11-21 15:50:03.331: I/System.out(1034): [socket][/192.168.1.6:33818]
11-21 15:50:03.341: I/System.out(1034): setSoSndTimeout:0
11-21 15:50:03.342: I/System.out(1034): setSendBufferSize:8096
11-21 15:50:04.164: I/System.out(1034): close [socket][/0.0.0.0:33818]
11-21 15:50:04.165: I/System.out(1034): close [socket][/0.0.0.0:33818]

Please help. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:38:10+00:00Added an answer on June 14, 2026 at 5:38 pm

    When you ignore every possible exception, this kind of error is inevitable. A try/catch block in the middle of a method with more code after it is automatically suspect. Try catching, logging, and handling exceptions properly, by which I mean not continuing after they happen as though they hadn’t happened.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

why do i get this exception? Map myHash = null myHash = (HashMap)Collections.synchronizedMap(new HashMap());
When I try to EDIT a tennis court... I get this exception :System.Data.UpdateException; Unable
I get this exception when i try to create a new layer. So ,
I get this exception in my code: ...IllegalArgumentException...Cant use FLAG_RECEIVER_BOOT_UPGRADE here... Looking into the
I get this exception on my Windows 7 64bit in application running in VS
Several random customers get this exception every time I update my Android app. I've
why do I get this exception?please suggest any solutions.i have properly copied mail.jar and
I know i will get this exception when i try to modify or remove
I'm trying the basic jMonkey but I get this exception jun 27, 2012 9:25:08
How can I get around this exception? Dim imagepathlit As Literal = DownloadsRepeater.FindControl(imagepathlit) imagepathlit.Text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.