Getting "the specific child already has a parent."
<p>I have tried all stackoverflow forums but couldn't get the solution</p>

<p>Error log:</p>

<pre><code>06-08 10:02:24.116 18960-18960/com.example.itachiuchiha.crimeintent E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.itachiuchiha.crimeintent, PID: 18960
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.itachiuchiha.crimeintent/com.example.itachiuchiha.crimeintent.CrimeListActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2357)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2419)
  at android.app.ActivityThread.access$900(ActivityThread.java:154)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:135)
  at android.app.ActivityThread.main(ActivityThread.java:5293)
  at java.lang.reflect.Method.invoke(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  at android.view.ViewGroup.addViewInner(ViewGroup.java:3937)
  at android.view.ViewGroup.addView(ViewGroup.java:3787)
  at android.view.ViewGroup.addView(ViewGroup.java:3728)
  at android.view.ViewGroup.addView(ViewGroup.java:3701)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
  at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339)
  at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:601)
  at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1236)
  at android.app.Activity.performStart(Activity.java:6006)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2320)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2419) 
  at android.app.ActivityThread.access$900(ActivityThread.java:154) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
  at android.os.Handler.dispatchMessage(Handler.java:102) 
  at android.os.Looper.loop(Looper.java:135) 
  at android.app.ActivityThread.main(ActivityThread.java:5293) 
  at java.lang.reflect.Method.invoke(Native Method) 
  at java.lang.reflect.Method.invoke(Method.java:372) 
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) 
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)  06-08 10:02:25.528 18960-18960/com.example.itachiuchiha.crimeintent I/Process: Sending signal. PID: 18960 SIG: 9
</code></pre>

<p>CrimeListActivity class:</p>

<pre><code>    package com.example.itachiuchiha.crimeintent;

   import android.support.v4.app.Fragment;

    public class CrimeListActivity extends SingleFragmentActivity {
        @Override
        protected Fragment createFragment() {
            return new CrimeListFragment();
        }
    }
</code></pre>

<p>CrimeListFragment class:</p>

<pre><code>    package com.example.itachiuchiha.crimeintent;

    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.support.v7.widget.LinearLayoutManager;
    import android.support.v7.widget.RecyclerView;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    //import android.widget.CheckBox;
    import android.widget.TextView;
    import android.widget.Toast;

    import java.util.List;


    public class CrimeListFragment extends Fragment {
        public RecyclerView recyclerView;
        public CrimeAdapter crimeAdapter;
        @Override
        public View. onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
            View view=inflater.inflate(R.layout.fragment_crime_list,container);
                       recyclerView=(RecyclerView)view.findViewById(R.id.crime_recycler_view);
                  recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
             updateUI();
             return view;
         }
         private void updateUI(){
             CrimeLab crimeLab;
              crimeLab =      CrimeLab.get(getActivity());
             List&lt;Crime&gt;      crimes=crimeLab.getCrimeList();
             crimeAdapter=new      CrimeAdapter(crimes);
             recyclerView.setAdapter(crimeAdapter);
         }
         private class CrimeHolder extends     RecyclerView.ViewHolder implements.   View.OnClickListener{
             public TextView titleText;
    //        public TextView dateText;
     //        public CheckBox solvedCheck;
            public Crime crime;
             public CrimeHolder(View itemView){
                 super(itemView);
                    itemView.setOnClickListener(this);
                titleText=(TextView)itemView;//.findViewById(R.id.list_item_crime_title_text_view);
//                     dateText=(TextView)itemView.findViewById(R.id.list_item_crime_date_text_view);
     //            solvedCheck=(CheckBox) itemView.findViewById(R.id.list_item_crime_solved_check_box);

        }
             public void bindCrime(Crime mcrime){
                  crime=mcrime;
                 titleText.setText(crime.getCrimeTitle());
//                dateText.setText(crime.getDate().toString());
//            solvedCheck.setChecked(crime.isSolved());
        }

        @Override
        public void onClick(View vo) {
            Toast.makeText(getActivity(),crime.getCrimeTitle()+"clicked",Toast.LENGTH_SHORT).show();
        }
    }
    private class CrimeAdapter extends RecyclerView.Adapter&lt;CrimeHolder&gt;{
        private List&lt;Crime&gt; crimes;
        public CrimeAdapter(List&lt;Crime&gt; crimess){
            crimes=crimess;
        }
        @Override
        public CrimeHolder onCreateViewHolder(ViewGroup parent,int viewType){
            LayoutInflater layoutInflater=LayoutInflater.from(getActivity());
            View vh=layoutInflater.inflate(android.R.layout.simple_list_item_1,parent,false);
            return new CrimeHolder(vh);
        }

        @Override
        public void onBindViewHolder(CrimeHolder holder, int position) {
            Crime crime=crimes.get(position);
            holder.bindCrime(crime);
        }

        @Override
        public int getItemCount() {
            return crimes.size();
        }
    }
}
</code></pre>

<p>SingleFragmentActivity class:</p>

<pre><code>package com.example.itachiuchiha.crimeintent;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;


public abstract class SingleFragmentActivity extends FragmentActivity{
    protected abstract Fragment createFragment();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment);
        FragmentManager fm=getSupportFragmentManager();
        Fragment fragment=fm.findFragmentById(R.id.fragmet_container);
        if(fragment==null){
            fragment=createFragment();
            fm.beginTransaction().add(R.id.fragmet_container,fragment).commit();
        }

    }
}
</code></pre>

<p>Crime class:</p>

<pre><code>package com.example.itachiuchiha.crimeintent;

import java.util.Date;
import java.util.UUID;

public class Crime {
    public UUID crimeID;
    public String crimeTitle;
    public Date date;
    public boolean isSolved;
    public Crime(){
        crimeID=UUID.randomUUID();
        this.date=new Date();
    }

    public boolean isSolved() {
        return isSolved;
    }

    public void setSolved(boolean solved) {
        isSolved = solved;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }



    public UUID getCrimeID() {
        return crimeID;
    }


    public String getCrimeTitle() {
        return crimeTitle;
    }

    public void setCrimeTitle(String crimeTitle) {
        this.crimeTitle = crimeTitle;
    }
}
</code></pre>

<p>CrimeLab class:</p>

<pre><code>  package com.example.itachiuchiha.crimeintent;


    import android.content.Context;

    import java.util.ArrayList;
    import java.util.List;
    import java.util.UUID;


    public class CrimeLab {
        public static CrimeLab crimeLab;
        public List&lt;Crime&gt; crimeList;
        public static CrimeLab get(Context context){
            if(crimeLab==null){
                crimeLab=new CrimeLab(context);
            }
            return crimeLab;
        }
        private CrimeLab(Context context){
            crimeList=new ArrayList&lt;&gt;();
            for(int i=0;i&lt;100;i++){
                Crime crime=new Crime();
                crime.setCrimeTitle("Crime #"+i);
                crime.setSolved(i%2==0);
                crimeList.add(crime);
            }
        }
        public List&lt;Crime&gt; getCrimeList(){
            return crimeList;
        }
        public Crime getCrimebyUUID(UUID id){
            for (Crime crime:crimeList){
                if(crime.getCrimeID().equals(id)){
                    return crime;
                }
            }
            return null;
        }
    }
</code></pre>

<p>fragment_crime_list.XML:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"&gt;
&lt;android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:id="@+id/crime_recycler_view"&gt;

&lt;/android.support.v7.widget.RecyclerView&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>activity_fragment.XML:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragmet_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/&gt;
</code></pre>

<p>Also it will be great if you can explain why this error is coming and how to sort it for future.</p>