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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:43:20+00:00 2026-05-21T06:43:20+00:00

Hi I have an application which after login, loads a main activity which contains

  • 0

Hi I have an application which after login, loads a main activity which contains a tabhost with 3 tabs containing listviews. Each tab is populated via sqlite + custom adapter. The database is initially populated via xml data (sync’d asynchronously to the sqlite database).

My problem: I want to allow allow manual syncing of the sqlite database with XML data, which then updates the current tab listview. I have the asynchronous thread working fine to do the background update of the database. What i can’t figure out is how to force a refresh of the current tab’s listview. The problem is i don’t know how to access a sub activity within the tabhost from the parent activity.

I’m fairly sure notifyDataSetChanged() is what i need but i can’t figure out how to access the tab’s activity > adapter to do this. How do i access a sub activities adapter in order to call notifyDataSetChanged()? The parent (containing) activity has the button which will be used to refresh the tabhost’s listview.

An alternative: i could try is broadcasting an intent from my background thread’s onPostExecute() callback. ie, when it finishes updating the database with xml data i have my tab receive the broadcast and trigger it to refresh via notifyDataSetChanged()… but this is probably NOT how broadcast/receive intents are designed is that right?? ie, communicating between a activity and contained tab’s listview activity?

This is my 2nd post on stack overflow I hope I’ve been clear in my explanation. Thanks for any help or advice you can provide

EDIT (16-Jan-2012):
Been a long time since I worked on this issue. I originally used a solution of broadcasting an intent and consuming it in the child activity. BUT I’ve since taken the advice from many others (and you should too)! and instead stopped using Activities inside tabs. I’m now using views within the tabs. This works MUCH better and cleaner.

Apart from the code getting too cumbersome, I was also getting weird “Database not closed” type errors when going between Activities also when rotating the devide from portrait/landscape. Views within tabs instead of activities fixed many issues and I’m sure its better on resource usage.

  • 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-21T06:43:21+00:00Added an answer on May 21, 2026 at 6:43 am

    I just finished implementing “a” solution. I basically went with the broadcast intent alternative i mentioned above.

    Incase anyone else wants to do it this way, in the onPostExecute() method of my AsyncTask task (which does the background syncing of my XML with database). I raise a Intent Broadcast with :

        @Override
        protected void onPostExecute(Integer result) {
            Intent i = new Intent("com.myapp.app.DATA_REFRESH");
            sendBroadcast(i);
    
        }       
    

    Then within the tabhost > tab activity i receive that broadcasted intent with :

    public class updaterBroadcastReceiver extends BroadcastReceiver {       
            @Override
            public void onReceive(Context context, Intent intent) {
                fillData(); // rebuild my listview with new database data
            }
    }
    

    Register / setup the above intent receiver with :

    @Override
    public void onResume(){         
             IntentFilter filter = new IntentFilter("com.myapp.app.DATA_REFRESH");
             updaterBroadcastReceiver r = new updaterBroadcastReceiver();
             registerReceiver(r,filter);
    
             super.onResume();
    }   
    

    FillData() is used to update the listview with new data from the database.

    Well this seems to work for me if anyone has a suggestion on a better way to do this please let me know. I’m quite new to android.

    Cheers,
    Rob

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

Sidebar

Related Questions

M developing an application which starts with a login page. After loggin the user
I have an Android application which needs username and password to login. I need
I have a fielded FB application which uses the JS login button workflow (fb:login-button).
in my activity I have login page (L), which leads to hierarchy of activites
I have an Android application which has a login screen. Upon the click of
I currently have a form based login in my application which is developed on
I have application which needs to use a dll (also written by me) which
I have an application which really should be installed, but does work fine when
I have an application which extracts data from an XML file using XPath. If
We have an application which needs to use Direct3D. Specifically, it needs at least

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.