I have a FragmentActivity
that shows a contacts list.
Here is my onCreate
method:
@Override
protected void onCreate(Bundle
It is always adviced to use caching to retain the data . as mentiond by Groucho u can go with storage options Check below link for details.
http://developer.android.com/guide/topics/data/data-storage.html
@Override
public void onPause ()
{
super.onPause();
//...........
}
@Override
public void onStop ()
{
super.onPause();
//............
}
Check if you can use these methods in your fragments ?
You are going to check controller therefor.
Instead of that try to check value you stored. First take one variable as Bundle. Save it in onCreate method.
Bundle bdlSaveInstant; // Declare at top before onCreate() method.
/* Initialise in onCreate() method. After
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_human_list);
bdlSaveInstant = savedInstanceState;
*/
@override
onBackPressed()
{
bdlSaveInstant.putBoolean("displayed_contacts", true);
}
@override
onDestroy()
{
bdlSaveInstant.putBoolean("displayed_contacts", true);
}
Try this will work.
In your on create method just clear your list.Because every time it will go to on create method and make list clear(which) is your previous data loading.
OR
check your list if(list.size==null) then call your API otherwise in else block (list.setAdapter).
hope it will work.
when you are done with loading of the data in displayContacts(), you can save a flag(displayed_contacts) in shared preferences. In onCreate() check the preference value, and call your displayContacts() accordingly.
Its simple. follow these steps in your Activity
Then definitely you wont get content replication.