title: listview adapter not updating after removing an item
body: <p>Hello am trying to delete an item from my listview am able to delete item from my db but my adapter is not getting updated I have attached the code below` </p>
  
  <pre><code>public class SavedPolygonFragment extends android.support.v4.app.Fragment implements RefreshListener {
  private static String LOG_TAG = SavedPolygonFragment.class.getName();
  
  private String message = "No message";
  private ListView          shapeList;
  private TextView          textView;
  private Button            startMainBtn;
  private SavedShapeAdapter savedShapeAdapter;
  private long              shapeId;
  private float             scaleFactor;
  private List&lt;Shape&gt; savedShapes = new ArrayList&lt;&gt;();
  private StartDrawingListener startListener;
  private DeleteShapesDialog   deleteDialog;
  
  public SavedPolygonFragment() {
  
  }
  
  @Override
  public void onAttach(Activity activity) {
      super.onAttach(activity);
      startListener = (StartDrawingListener) activity;
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setHasOptionsMenu(true);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View view = inflater.inflate(R.layout.fragment_one, container, false);
  
      savedShapes = getArguments().getParcelableArrayList("shapes");
      AssetLog.verbose(LOG_TAG, "savedshapes.size " + savedShapes.size());
      shapeList = (ListView) view.findViewById(R.id.shapeList);
      textView = (TextView) view.findViewById(R.id.polygonTitle);
      startMainBtn = (Button) view.findViewById(R.id.gotoMain);
  
      startMainBtn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              startListener.startMainReceived();
          }
      });
  
      if (!savedShapes.isEmpty() &amp;&amp; !savedShapes.equals(null) &amp;&amp; savedShapes.size() != 0) {
          textView.setText("Polygons");
          shapeList.setVisibility(View.VISIBLE);
          startMainBtn.setVisibility(View.GONE);
  
  
          if (savedShapeAdapter != null) {
              savedShapeAdapter.notifyDataSetChanged();
          } else {
  
              savedShapeAdapter = new SavedShapeAdapter(savedShapes, getActivity());
              shapeList.setAdapter(savedShapeAdapter);
  
              shapeList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                      MainActivity_.intent(getActivity())
                              .savedProjectId(ProjectShapesActivity.projId)
                              .scaleFactor(ProjectShapesActivity.scaleFactor)
                              .shapeId(((Shape) view.getTag()).getShapeId())
                              .lineId(-1)
                              .pointId(-1)
                              .start();
                  }
              });
  
  
          }
      }
      else{
          shapeList.setVisibility(View.GONE);
          startMainBtn.setVisibility(View.VISIBLE);
  
          textView.setText("Sorry no shapes are saved");
      }
  
      return view;
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      registerForContextMenu(shapeList);
  }
  
  @Override
  public void onRefreshPressed() {
  }
  
  @Override
  public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
      super.onCreateContextMenu(menu, view, menuInfo);
      AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
      shapeId = info.id;
      menu.add(Menu.NONE, R.id.deleteShapes, Menu.NONE, "Delete");
      menu.add(Menu.NONE, R.id.editShapes, Menu.NONE, "Edit");
  
  }
  
  @Override
  public boolean onContextItemSelected(MenuItem item) {
      switch (item.getItemId()){
          case R.id.refresh:
              return false;
  
          case R.id.deleteShapes:
              if(deleteDialog == null){
                  Bundle bundle = new Bundle();
                  bundle.putString("SHAPE", "SHAPE");
                  bundle.putLong("shapeId", shapeId);
                  deleteDialog = new DeleteShapesDialog();
                  deleteDialog.setArguments(bundle);
                  deleteDialog.show(getActivity().getFragmentManager().beginTransaction(), "showDeleteDialog");
              }
              return true;
          case  R.id.editShapes:
              return true;
  
      }
      return super.onContextItemSelected(item);
  }
  
  
   public void onDataChanged(long shapeid) {
  
      Shape shape;
      for (int i = 0; i &lt;savedShapes.size() ; i++) {
          shape = savedShapes.get(i);
          if(shape.getShapeId() == shapeid){
              savedShapes.remove(i);
              shapeList.removeViewAt(i);
              shapeList.invalidate();
              savedShapeAdapter.notifyDataSetChanged();
              break;
          }
      }
  }
  </code></pre>
  
  <p>}
  `</p>
  
  <p>Now when user selects yes from <strong><em>deleteDialog</em></strong> i wrote a callback to my activity and in the corresponding methods this is what I do</p>
  
  <pre><code>SavedPolygonFragment polygonFragment = new SavedPolygonFragment();
   polygonFragment.onDataChanged(shapeId);
  </code></pre>
  
  <p>Can somebody show me whats wrong</p>
  
  <p>/////EDIT 1</p>
  
  <pre><code> public void onDataChanged(long shapeid) {
  
       savedShapeAdapter.removeItemById(shapeid);
  
  }
  </code></pre>
  
  <p>and my adapter </p>
  
  <pre><code>public void removeItemById(long itemId){
      for(int i =0; i&lt; shapeList.size() ; i++){
          if(shapeList.get(i).getShapeId() == itemId){
              shapeList.remove(i);
          }
      }
      notifyDataSetChanged();
  }
  </code></pre>