title: Android - Listview .remove() function is not working as expected
body: <p>I have a listview that is able to delete a specific image via onLongClick, but it isn't working so far. When testing, the dialog appears If i want to delete or not, i press Yes/Ok and the toast appears saying Item deleted, however the item is still there.</p>
  
  <p><strong>UPDATED</strong> ( I got the remove and delete function working thanks to user1140237)</p>
  
  <p><strong>UPDATED MAIN ACTIVITY</strong></p>
  
  <pre><code>private String[] FilePathStrings;
  private String[] FileNameStrings;
  private File[] listFile;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_yearbook);
      File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),"/CapturyGallery");
  
      // Check for SD Card
      if (!Environment.getExternalStorageState().equals(
              Environment.MEDIA_MOUNTED)) {
          Toast.makeText(this, "Error! No SDCARD Found!", Toast.LENGTH_LONG)
                  .show();
      } else {
          // Locate the image folder in your SD Card
          file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),"/CapturyGallery");
          // Create a new folder if no folder named CapturyGallery exist
          file.mkdirs();
      }
  
  
      if (file.isDirectory())
      {
          listFile = file.listFiles();
          // Create a String array for FilePathStrings
          FilePathStrings = new String[listFile.length];
          // Create a String array for FileNameStrings
          FileNameStrings = new String[listFile.length];
  
          for (int i = 0; i &lt; listFile.length; i++)
          {
              //Get the path image file
              FilePathStrings[i] = listFile[i].getAbsolutePath();
              // Get the name image file
              FileNameStrings[i] = listFile[i].getName();
          }
      }
      Arrays.sort(listFile);
  
       final ListAdapter listAdapter = new CustomAdapter(Yearbook.this, FilePathStrings, FileNameStrings);
       ListView lv = (ListView) findViewById(R.id.ListingView);
       lv.setAdapter(listAdapter);
  
       final ArrayList&lt;String&gt; list = new ArrayList(Arrays.asList(FilePathStrings));
  
  
  
  
  
      lv.setOnItemClickListener(this);
      lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View view, final int position, long id) {
              //Deletes item
              AlertDialog.Builder adb=new AlertDialog.Builder(Yearbook.this);
              adb.setTitle("Delete?");
              adb.setMessage("Are you sure you want to delete " + FileNameStrings[position]);
              final int positionToRemove = position;
              adb.setNegativeButton("Cancel", null);
              adb.setPositiveButton("Ok", new AlertDialog.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                      File file = new File(list.get(positionToRemove));
                      if (file.delete()) {
                          list.remove(position);
                          ((CustomAdapter) listAdapter).updateMyData(FilePathStrings, FileNameStrings);
                          Toast.makeText(getApplicationContext(), FileNameStrings[position] + " deleted", Toast.LENGTH_LONG).show();
                      }
  
  
                  }
              });
              adb.show();
              return true;
          }
  
      });
  
  
  }
  </code></pre>
  
  <p><strong>CUSTOMADAPTER</strong></p>
  
  <pre><code>public class CustomAdapter extends BaseAdapter {
  
  private Activity activity;
  private String[] filepath;
  private String[] filename;
  
  
  private static LayoutInflater inflater = null;
  
  public CustomAdapter(Activity a, String[] fpath, String[] fname) {
      activity = a;
      filepath = fpath;
      filename = fname;
      inflater = (LayoutInflater) activity
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
  
  }
  public void updateMyData(String[] fpath, String[] fname) {
      filepath = fpath;
      filename = fname;
      notifyDataSetChanged();
  }
  
  
  @Override
  public int getCount() {
      return filepath.length;
  
  }
  
  public Object getItem(int position) {
      return position;
  }
  
  public long getItemId(int position) {
      return position;
  }
  
  class MyViewHolder {
      ImageView myImage;
      TextView timestamp;
      TextView myName;
      TextView myHeader;
      MyViewHolder(View v) {
          myImage = (ImageView) v.findViewById(R.id.PicView);
          timestamp = (TextView) v.findViewById(R.id.timestamp);
          myName = (TextView) v.findViewById(R.id.myName);
          myHeader = (TextView) v.findViewById(R.id.textSeparator);
  
      }
  }
  
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View vi = convertView;
      MyViewHolder holder = null;
      if (vi == null) {
          vi = inflater.inflate(R.layout.custom_row, null);
          holder = new MyViewHolder(vi);
          vi.setTag(holder);
      } else {
          holder = (MyViewHolder) vi.getTag();
      }
  
      Bitmap bmp = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(filepath[position]),100,100);
  
  
      holder.myImage.setImageBitmap(bmp);
      //PicImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
      holder.myImage.setPadding(8, 8, 8, 8);
  
      //Set Title
      holder.myName.setText(filename[position]);
  
      ExifInterface intf = null;
      try {
          intf = new ExifInterface(filepath[position]);
      } catch(IOException e) {
          e.printStackTrace();
      }
  
      if(intf != null) {
          String dateString = intf.getAttribute(ExifInterface.TAG_DATETIME);
          holder.timestamp.setText("Date Taken: " + dateString.toString());
      }
  
  
      return vi;
  }
  </code></pre>
  
  <p>And so my last problem is, whenever i remove something from my listview it crashed. However, the file was indeed removed. Im not sure what is the error because i tested it on my mobile phone</p>