Sunday, September 13, 2015

Android reload database on resume or restart.

This scenario happens when , say we have two activities A and B.
From A we go to B and update the database. Then when we comeback at A
we notice that the A is not updated.
We have to implement the OnRestart in A, so that when the BACK button is pressed our
database is reloaded.

      @Override
    public void onRestart()
    {
        super.onRestart();
        finish();
        startActivity(getIntent());
    }

  


You can also try OnResume too



     @Override
    public void onResume() {
        super.onResume();  // Always call the superclass method first
        finish();
        startActivity(getIntent());

    }

  

This is just a trick, hope it paved your way out. 

No comments:

Post a Comment