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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:04:12+00:00 2026-05-27T16:04:12+00:00

I am trying to create a refesh function for my main page. I have

  • 0

I am trying to create a refesh function for my main page. I have searched many site but i can’t seem to find a (for me) acccesseble exaple. I am loading information from a sQLLite database. When i use my add activity and i return to the MainScreen activity the item i have added do not appear. How could i refresh this data the moment de activity is resumed.

Any help is welcome, thx in advance.

      public ListView whiskeylist;
      String[] DataArryWhiskey;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Start db view of whiskey
    DBConfig info = new DBConfig(this);

    info.open();
        DataArryWhiskey = info.getDataInArray();
    info.close();


    whiskeylist = (ListView) findViewById(R.id.listofWhiskey);
    whiskeylist.setOnItemClickListener(this);
    whiskeylist.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, DataArryWhiskey));


}// end onCreate

On The advice of Adil i change the code to

      public ListView whiskeylist;
String[] DataArryWhiskey;
ListAdapter Adapter;


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    // Start db view of whiskey 
    DBConfig info = new DBConfig(this); 

    info.open(); 
         DataArryWhiskey = info.getDataInArray(); 
    info.close(); 


    whiskeylist = (ListView) findViewById(R.id.listofWhiskey); 
    Adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, DataArryWhiskey); 
    whiskeylist.setAdapter(Adapter); 

    // End db view of whiskey


}// end onCreate

@Override
public void onResume() 
{ 
    super.onResume(); 
    DBConfig info = new DBConfig(this); 

    info.open(); 
        DataArryWhiskey = info.getDataInArray(); 
    info.close(); 
    Adapter.notifyDataSetChanged();  // refresh adapter     
} 

however i get a error on notifyDataSetChanged “the method notifyDataSetChanged is undefined for the type ListAdapter” <- fixed it by changing the ListAdapter to ArrayAdapter but the app still crashes.

  • 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-27T16:04:12+00:00Added an answer on May 27, 2026 at 4:04 pm

    //made changes in your oncreate method, see below

    DBConfig info;
     @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    // Start db view of whiskey
    info = new DBConfig(this);
    whiskeylist = (ListView) findViewById(R.id.listofWhiskey);
    whiskeylist.setOnItemClickListener(this);
     }// end onCreate
    

    another method give below, call this method from on ActivityResult(), but before doing that ensure that
    the field you added with another activity also saved into database.
    call show Data() from onActivityResult method or from onResume()

    private void showData()
    {
      info.open();
        DataArryWhiskey = info.getDataInArray();
    info.close();
     whiskeylist.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, DataArryWhiskey));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a user interface, but when I refresh the page,
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Trying to create a user account in a test. But getting a Object reference
I'm trying to create a PHP based game where you have to do all
I am trying to create a function that handles the 'keyup' event for several
I must have some permissions wrong, but I can't figure out how. The following
I have been trying to basically create a div for each row of the
I am trying create a WCF service that leverages the WPF MediaPlayer on the
I am trying create a delegate representation of constructor by emitting a Dynamic Method,
Ok so I am trying create a login script, here I am using PHP5

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.