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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:17:53+00:00 2026-06-02T04:17:53+00:00

I am working on an app which combines the SQL and the adapter. The

  • 0

I am working on an app which combines the SQL and the adapter. The main issue is that once I updated the database, the adapter will not reflect my update directly. Here’s the code:

public class RSSItemActivity extends ListActivity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rssitem);

        long channelid = getIntent().getExtras().getLong(RSSReaderApp.CHANNEL_KEY);
        DBAdaptor dbAdaptor = ((RSSReaderApp)getApplication()).getDBAdaptor();
        Cursor cursor = dbAdaptor.getRssItems(channelid);

        adapter = new RSSItemAdapter(this, R.layout.rssitemview, cursor);

        setListAdapter(adapter);
}

As you can see, this code get the data from the SQL at the line Cursor cursor = dbAdaptor.getRssItems(channelid);(The get RssItems is just loading data we want to present on the screen from the SQL). However, I have some bottoms in the same activity that if I press that, it will change the values in the SQL, which should affect the data it retrieve. (For example, there’s a column decide what’s these item’s color, it is originally set to white, after I press that, it should be blue.) However, once I press that, seems although the data in the SQL is changed, but the real presentation is still the same color. I had tried using adapter.swapCursor(dbAdapter.getRssItems(id)); on the bottom to update the cursor everytime I press the buttom, but it will let my original display disappear (Possibly because the original adapter loses it’s cursor,so it can display nothing), I have to reload that page to get the correct output. Is there a way that I can instantly update the output? Thanks for your reply 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-02T04:17:55+00:00Added an answer on June 2, 2026 at 4:17 am

    You will have to update the cursor in the adapter. You could call the following:

    // Closes the old cursor as well.
    adapter.changeCursor(dbAdapter.getRssItems(id)); 
    // Notify the view that the underlying data has changed.
    adapter.notifyDataSetChanged(); 
    

    Also, the difference with swapCursor() is that changeCursor, automatically closes the old cursor, while swapCursor does not.

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

Sidebar

Related Questions

I am working on an app which requires that the user be logged in
I'm working on an app which is using OLE DB and SQL Server Native
I am working on an app which will provide route for the student shuttle.
I´m working with an iPhone app which has a SQLite database set up. I
I am working on an app which will allow me to login to a
We're working on app which will deliver content to users from different countries (Europe).And
i am working on app which deals with proximity alerts. I can add proximity
I am working on an app which calls a rest web service. Sometimes the
I am working on an app which uses Commonslang.jar libraries. I was trying to
I am working on a app which requires me to store some directions for

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.