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

  • Home
  • SEARCH
  • 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 6692573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:52:58+00:00 2026-05-26T05:52:58+00:00

Please see the following code.In following code I want to download some data from

  • 0

Please see the following code.In following code I want to download some data from server when button is clicked.

  public void fetch1(){

                event=this;

                // TODO Auto-generated method stub
                try {

                    Runnable runnable = new Runnable() {
                        @Override
                        public void run() {
                                handler.post(new Runnable() {
                                    @Override
                                    public void run() {
                                        try{

          //dialog.show();


          BufferedReader in = null;





          String url=URLManager.orderUrl+DataFactory.userData.sid+"&dnumber="+DataFactory.userData.dnumber+"&from_date="+fromDateStr+"&to_date="+toDateStr; ;

         // String login = "morris";
          //String pass = "mor$ris";

          DefaultHttpClient client = new DefaultHttpClient();
          HttpGet request = new HttpGet();


          client.getCredentialsProvider().setCredentials(new AuthScope("newdev.objectified.com", 80), new UsernamePasswordCredentials(URLManager.user, URLManager.pass));

          request.setURI(new URI(url));
          HttpResponse response = client.execute(request);

                 in = new BufferedReader
                 (new InputStreamReader(response.getEntity().getContent()));
                 StringBuffer sb = new StringBuffer("");
                 String line = "";
                 String NL = System.getProperty("line.separator");
                 while ((line = in.readLine()) != null) {
                     sb.append(line + NL);
                 }
                 in.close();
                 String page = sb.toString();
              //  Toast.makeText(event,url+"--::::--"+ page, Toast.LENGTH_LONG).show();


                  OrdersHandler handler=new OrdersHandler();
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
                XMLReader xr = sp.getXMLReader();
                xr.setContentHandler(handler);
                InputSource is = new InputSource();
                  is.setCharacterStream(new StringReader(page));           
                  xr.parse(is);  
                  Vector v=handler.getData();
                  DataFactory.ordersVector=v;


                 dataVector=DataFactory.ordersVector;

                 ordersId=new String[dataVector.size()];
                for(int a=0;a<dataVector.size();a++){
                    OrdersData o=(OrdersData)dataVector.elementAt(a);
                    ordersId[a]=o.order_id;



                }// end of the for


                //event.setListAdapter(new IconicAdapter());

            //  adapter.clear();
                // Create an ArrayAdapter, that will actually make the Strings above
                // appear in the ListView






                  /*
                 for(int a=0;a<v.size();a++){
                    OrdersData o=(OrdersData)v.elementAt(a);
                    names=names+o.order_id+"\n";


                 }// end of the for loop

                //String data=d.sid+"\n"+d.dtitle+"\n"+d.dcountry+"\n"+d.dcity;
                  Toast.makeText(event, names, Toast.LENGTH_LONG).show();
                   */


                                        }catch(Exception e){


                                        }
                                        }
                                });
                            }

                    };
                    new Thread(runnable).start();



                    //executeHttpGet();

                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                     Toast.makeText(this, e+"", Toast.LENGTH_SHORT).show();
                }
                adapter.notifyDataSetChanged();

                adapter.clear();
                adapter=new IconicAdapter();
                this.setListAdapter(adapter);

            }// end of the fetch method

I want to refresh the ListActivity when data is downloaded using above method. but unfortunately app crashed .Please help I am new to android development

  • 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-05-26T05:52:59+00:00Added an answer on May 26, 2026 at 5:52 am
    adapter.notifyDataSetChanged();
    adapter.clear();
    adapter=new IconicAdapter();
    this.setListAdapter(adapter);
    

    If you haven’t previously set the adapter, you’re running notifyDataSetChanged() and clear() on a null pointer. If it was already created, you create a new adapter and setListAdapter() anwyay: calling notifyDataSetChanged() would be pointless (old adapter is no longer displayed in the list, the new one is), and clear() is only of use if you need to do some cleaning up.

    I think you’re trying to display a list of Strings as contained in ordersId[]? But you don’t pass it into the IconicAdapter. Is IconicAdapter an inner class?

    Have a look at http://developer.android.com/reference/android/os/AsyncTask.html – preferred over Thread.

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

Sidebar

Related Questions

Please see following code I want to know how can I de-alloc cell .
Please help me with the following code. All I want to do is see
Please see the following t-sql code DECLARE @iError INT EXEC('select * from sysobj') SELECT
Please see the following code: List list = Collections.synchronizedList(new ArrayList()); // ... synchronized (list)
How do we update a textbox on ticking checkboxes? Please see the following code,
Please see following methods. public static ProductsCollection GetDummyData(int? customerId, int? supplierId) { try {
Please see following examples first, and which one is better? Could you compare some
Please see this fiddle I want the scrolling div stop following when left div
Please see the pic. I am attaching DBs using following code. Dim conn As
i want my java code to send and receive response from ntp server. however,

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.