How to know your index from ViewPager to remove the crime?

I figured this out. How do I delete this topic?

Stating that there is no dummy question, why don’t you share the solution instead ?

How did you solve this issue? This is my solution.

Into the CrimeLab.java I added delete crime method:

public void deleteCrime(UUID id){
    Iterator<Crime> i = mCrimes.iterator();
    while (i.hasNext()){
        Crime crime = i.next();
        if(crime.getId().equals(id)){
            i.remove();
            return;
        }
    }
}

In the CrimeFragment I overrided onOptionsItemSelected method:

   public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case R.id.menu_item_delete_crime:
                CrimeLab crimes = CrimeLab.get(getActivity());
                crimes.deleteCrime(mCrime.getId());
                getActivity().finish();
            default:
                return super.onOptionsItemSelected(item);
        }
    }

I think I may have found a slightly more elegant solution, however I’m pretty new to Java so let me know what you think.

Add this to CrimeLab:

public void deleteCrime(Crime c){
    mCrimes.remove(c);
}

Add this to CrimeFragment (I’m assuming you already added the menu for this as well):

    @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_crime, menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item){
    switch (item.getItemId()){
        case R.id.delete_crime:
            CrimeLab.get(getActivity()).deleteCrime(mCrime);
            //return to previous screen
            getActivity().finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}