Reputation: 5259
Lets suppose I am on screen2 on my application, and my application retrieves data from a database. I want to have a refresh button on it. So I am writing this code:
b3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(Screen2.this,Screen2.class);
startActivity(i);
}
});
where b3 is the button.My question is kind of theoritically: Is there any better way? Does this make my application heavy or causes any other problems to OS if I do for example several time refresh.
Would it be better to do the refresh for example at specific times? If yes, how I will write this code?
Thanks.
Upvotes: 0
Views: 138
Reputation: 3723
You should not restart the activity each time you want updated information: just update your views when the update button is clicked.
Upvotes: 0
Reputation: 199
you could use adapter.notifyDataSetChanged(). much more efficient http://developer.android.com/reference/android/widget/ArrayAdapter.html#notifyDataSetChanged()
Edit: (thats only valid if you are using an ArrayAdapter)
Upvotes: 2