title: How to keep new data in recycleView.setAdapter
body: <p>In TabHost, I have 2 tabs (2 fragments). In tab1, inside onCreateView, I have <code>recycleView.setAdapter</code>. When I click, it loads new data then if switch from tab1 to tab2 then return to tab1, <code>recycleView.setAdapter</code> reloads the old data. <br> How can I keep new data in <code>recycleView</code> when switching from tab2 to tab1?<br></p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
  
      // Inflate the layout for this fragment
      View view = inflater.inflate(R.layout.fragment_position, container, false);
  
      recyclerViewPosition = view.findViewById(R.id.recyclview);
      LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
      recyclerViewPosition.setLayoutManager(linearLayoutManager);
      recyclerViewPosition.setHasFixedSize(true);
      recyclerViewPosition.setAdapter(positionAdapter);
  
      // searchView
      searchView = view.findViewById(R.id.sview);
      searchView.setOnQueryTextListener(new OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
              return false;
          }
  
          @Override
          public boolean onQueryTextChange(String newText) {
              final List&lt;DataPosition&gt; filteredModelList = filter(mPositionList, newText);
              positionAdapter.setFilter(filteredModelList);
              return true;
          }
      });
  
      Call&lt;Position&gt; call = mApiService.getPositionList(strTokent);
      call.enqueue(new Callback&lt;Position&gt;() {
          @Override
          public void onResponse(Call&lt;Position&gt; call, Response&lt;Position&gt; response) {
              if (response.isSuccessful()) {
  
                  itemArrayList = response.body().getData().getItems();
  
                  mPositionList.clear();
                  dataPosition.clear();
  
                  /* put id and name to hashMap*/
                  for (int i = 0; i &lt; itemArrayList.size(); i++) {
                      hashMap.put(itemArrayList.get(i).getName(), itemArrayList.get(i).getId());
                  }
  
                  for (int j = 0; j &lt; itemArrayList.size(); j++) {
                      dataPosition.add(itemArrayList.get(j).getName());
                  }
  
                  for (String strPosition : dataPosition) {
  
                      mPositionList.add(new DataPosition(strPosition));
                  }
              }
          }
  
          @Override
          public void onFailure(Call&lt;Position&gt; call, Throwable t) {
  
          }
      });
  
      return view;
  } 
  </code></pre>