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 9078569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:39:25+00:00 2026-06-16T19:39:25+00:00

Im a little bit confused about this adapter element (NotifyDataSetChanged) cause when I use

  • 0

Im a little bit confused about this adapter element (NotifyDataSetChanged) cause when I use it, my listview doesnt update.

My work scenario:
First ive created a void so that whenever I Update something on listview’s item I could just call again my void.

private void bindOrderListSorted(String sort){
    orderList = new ArrayList<Order>();
    mySQLiteAdapter = new SQLiteAdapter(context);
    mySQLiteAdapter.openToRead();
    String selectQuery = "MY QUERY...";
    Cursor cursor =mySQLiteAdapter.read(selectQuery); 
    while(cursor.moveToNext())
    {
        Order order = new Order();
        order.orderdDesc = cursor.getString(0);
        order.orderitemCode = cursor.getString(1);
        order.orderitemID = cursor.getString(2);
        order.orderPrice = cursor.getString(3);
        order.qtyOrdered = cursor.getString(4);
        order.stocksQty = cursor.getString(5);
        orderList.add(order);
    }
    cursor.close();
    mySQLiteAdapter.close();
    orderAdapter =new OrderListAdapter(this, orderList,context, sort);      
    listViewSearchPanel.setAdapter(orderAdapter);

}

The main problem about this is that whenever I update something on my database and call that “bindOrderListSorted” my listview updates but as expected it will rebind again that the position of the listview goes to zero again.

Thats my logic before but then as I found out, what if I have a long list of items? It will not be suitable and user friendly because the user must scroll down again to find the item(s) he/she wishes to update

so ive learned about NotifyDataSetChanged and created a void again for that

private void NotifyDataChangedOrderListSorted(String sort){
    orderList = new ArrayList<Order>();
    mySQLiteAdapter = new SQLiteAdapter(context);
    mySQLiteAdapter.openToRead();
    String selectQuery = "MY QUERY... SAME AS BEFORE";
    Cursor cursor =mySQLiteAdapter.read(selectQuery); 
    while(cursor.moveToNext())
    {
        Order order = new Order();
        order.orderdDesc = cursor.getString(0);
        order.orderitemCode = cursor.getString(1);
        order.orderitemID = cursor.getString(2);
        order.orderPrice = cursor.getString(3);
        order.qtyOrdered = cursor.getString(4);
        order.stocksQty = cursor.getString(5);
        orderList.add(order);
    }

    cursor.close();
    mySQLiteAdapter.close();
    orderAdapter =new OrderListAdapter(this, orderList,context, sort);  
    orderAdapter.notifyDataSetChanged();

}

And call that “NotifyDataChangedOrderListSorted” whenever I updated something.

My main problem is my listview isnt updating. I am quite sure that my orderList has the updated value cause using debugger and breakpoints the data I am expecting is as expected. Why is that?

Please feel free to recommend suggestion or comments. If you want to see my base adapter please say it so..

THANKS IN ADVANCE

  • 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-16T19:39:27+00:00Added an answer on June 16, 2026 at 7:39 pm

    You are creating a new List and ArrayAdapter so notifyDataSetChanged() has no effect and orderAdapter no longer references the adapter in your ListView. You have two choices:

    1. Call setAdapter() in your NotifyDataChangedOrderListSorted() method:

      ...
      orderAdapter =new OrderListAdapter(this, orderList,context, sort);  
      listViewSearchPanel.setAdapter(orderAdapter);
      

      But this identical to bindOrderListSorted()

    2. Reuse orderList and orderAdapter:

      private void NotifyDataChangedOrderListSorted(String sort){
          orderList.clear(); // Change this
          mySQLiteAdapter = new SQLiteAdapter(context);
          mySQLiteAdapter.openToRead();
      
          ...
          cursor.close();
          mySQLiteAdapter.close();
          orderAdapter.notifyDataSetChanged(); // Change this
      
      }
      

    But really you should use a CursorAdapter since they are faster and smaller… but it’s up to you.

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

Sidebar

Related Questions

I am little bit confused about this statement that I read in a book
I'm a little bit confused about how to approach this. I had never used
I am a little bit confused about the use of Thread.yield() method in Java,
I'm a little bit confused by this scenario: I have a class that implements
I'm a little bit confused about this expression: char *s = abc; Does the
I am a little bit confused about 2 things. Firstly when I create an
I am little bit confused about following problem & their solutions: i have 2
Started learning Wicket after ASP.NET MVC and feel a little bit confused about managing
I´m a little bit confused by reading all the posts and tutorials about starting
I'm using SQLite as my database, and I'm a little bit confused about how

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.