title: SharedPreferences overwrite other value?
body: <p>I am new in android.here i make simple contacts list app. when user click on contact items, contact add in favorite list. but problem is that when user click on first contact item to add favorite,then user click second contact,but first item was remove automatically. Shared Preferences overwrite other value,i want to add item in list so what i do to add contacts in favorite List.</p>
  
  <p>First Fragment:</p>
  
  <pre><code>imageViewfavourite.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
                  SharedPreferences.Editor editor = preferences.edit();
  
                  editor.putString("name1", Pname);
                  editor.putString("number1", Pnumber);
                  editor.putString("image1", temp);
                  editor.putInt("pos", position);
  
                  Log.e("a", "name1" + Pname);
                  Log.e("a", "number1" + Pnumber);
                  Log.e("a", "image1" + temp);
  
                  editor.commit();
  
              }
          });
  </code></pre>
  
  <p>Second Fragment:</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
  View view = inflater.inflate(R.layout.fragment_fragment_fv, container, false);
  recyclerView = (RecyclerView) view.findViewById(R.id.favourite_list);
  selectUsers = new ArrayList&lt;DataContact&gt;();
  
  SharedPreferences preferences = getActivity().getPreferences(0);
  String Pname = preferences.getString("name1", "");
  String Pnumber = preferences.getString("number1", "");
  String Pimage = preferences.getString("image1", "");
  
  byte[] encodeByte = Base64.decode(Pimage, Base64.DEFAULT);
  bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
  
  Log.v("name1", Pname);
  Log.v("number1", Pnumber);
  Log.v("image1", Pimage);
  
  DataContact selectUser = new DataContact();
  selectUser.setName(Pname);
  selectUser.setPhone(Pnumber);
  selectUser.setThumb(bitmap);
  selectUsers.add(selectUser);
  
  adapter = new AdapterFv(getActivity(), "");
  LinearLayoutManager llm = new LinearLayoutManager(getActivity());
  llm.setOrientation(LinearLayoutManager.VERTICAL);
  recyclerView.setLayoutManager(llm);
  adapter.setData(selectUsers);
  recyclerView.setAdapter(adapter);
  
  return view;
  }
  </code></pre>