title: Android java : delete selected file / folder
body: <p>How to delete the selected file / folder by using long pressed ?
  I'm developing an File Explorer app and there are listed folder and file from my storage.
  I want to have a delete function for the <code>longpressed()</code>. </p>
  
  <pre><code>public void longpressed(){
  
  this.getListView().setLongClickable(true);
  this.getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
      public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
          new AlertDialog.Builder(ViewNoteActivity.this , AlertDialog.THEME_HOLO_DARK)
          .setTitle("Delete Folder / File")
          .setMessage("Are you sure you want to delete the selected folder / file ?")
          .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which ) { 
                   boolean success = true;
  
  
                  if (success) {
                      Toast.makeText(getBaseContext(), "You have successfully delete." , Toast.LENGTH_SHORT ).show();
  
  
  
              } else {
                  Toast.makeText(getBaseContext(), "You have Failed to delete." , Toast.LENGTH_SHORT ).show();
              }
              }
  
           })
          .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) { 
                  // do nothing
              }
           })
          .setIcon(R.drawable.ic_launcher)
           .show();
          return true;
      }
  });
  
  }
  </code></pre>
  
  <p>item select coding:</p>
  
  <pre><code>@Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
  
      super.onListItemClick(l, v, position, id);
      FileInfo fileDescriptor = fileArrayListAdapter.getItem(position);
      if (fileDescriptor.isFolder() || fileDescriptor.isParent()) {
          currentFolder = new File(fileDescriptor.getPath());
          fill(currentFolder);
      } else {
  
          fileSelected = new File(fileDescriptor.getPath());
          Intent intent = new Intent();
          intent.putExtra(Constants.KEY_FILE_SELECTED,
                  fileSelected.getAbsolutePath());
          setResult(Activity.RESULT_OK, intent);
          Log.i("FILE CHOOSER", "result ok");
                }
            }
  </code></pre>