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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T17:01:45+00:00 2026-05-14T17:01:45+00:00

I have an Activity with a list that is bound to a ListAdapter reading

  • 0

I have an Activity with a list that is bound to a ListAdapter reading data into a ArrayList from a database. All is well when the data is first loaded. While the Activity is open and the list is being displayed it is possible and likely that the data in the database will be updated by a service but the list does not reflect the changes because the ArrayList does not know about the changes. If the Activity is no longer in the foreground as would be the case if the user goes to the home screen and then is brought back to the foreground I would like for the Activity to not display what it did prior but rather reload the data using the ListAdapter the view is bound to. I think something needs to call finish() but I am not sure what. This is what I have in the Activity.

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setUpViews();
app = (MyApplication) getApplication();
adapter = new MyListAdapter(this, app.getMyEvents());
setListAdapter(adapter);
}
@Override
protected void onResume() {
super.onResume();
adapter.forceReload();
}
  • 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-14T17:01:46+00:00Added an answer on May 14, 2026 at 5:01 pm

    I have an Activity with a list that is
    bound to a ListAdapter reading data
    into a ArrayList from a database.

    Why not use a CursorAdapter instead of reading everything into an ArrayAdapter?

    While the Activity is open and the
    list is being displayed it is possible
    and likely that the data in the
    database will be updated by a service
    but the list does not reflect the
    changes because the ArrayList does not
    know about the changes.

    If you used a CursorAdapter, you could just call requery() on the Cursor, and your list would update with the latest contents of the database. You could do that in onStart(), for example, and it would be triggered whenever the user comes back to the activity — from the home screen, from an incoming phone call they took, etc.

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

Sidebar

Related Questions

I have a custom list view that is getting data from server and changing
I have three activities: Activity A - Displays a list of data from a
I have a list activity that implements Runnable so that my data fetch is
I have a activity that displays a number of elements from a list that
I have make on demo that list all contact from contact Uri in that
I have an AsyncTask, that fills a custom List with parsed data from Internet.
I have an activity that extends ListView. I populate my list with the results
I have a list that is populated by a listadapter that specifies a layout
I have an activity that shows customer information. All the controls are drawn dynamically
I have an activity that calls the new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); setListAdapter(notes);

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.