Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove audio file from SDCard by getting it's position
    text
    copied!<p>I have a custom list-view with check-boxes which get's all audio file name from SD Card folder and when i click any of this it play's audio. Everything is working fine. Now i have a image-view when i click on it, it show's 2 option with spinner </p> <p>1) Delete<br> 2) Edit</p> <p>Now i want like this, when user select any check-box from list-view and then delete from this spinner, i want to completely remove this audio from SD Card as well as from List-view. So basically i want to get position of list-view that which item is clicked by user and want to delete it...</p> <p>So please guide me how can i achieve this. Below is my code.</p> <pre><code>final Spinner spinnerDelete = new Spinner(Assignment.this); alertDialogBuilder.setView(spinnerDelete); adapterSpinner = ArrayAdapter.createFromResource( Assignment.this, R.array.delete_menu, android.R.layout.simple_spinner_item); adapterSpinner .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerDelete.setAdapter(adapterSpinner); alertDialogBuilder.setTitle("Delete Data"); alertDialogBuilder .setMessage("Click yes to Delete Record!") .setCancelable(false) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (spinnerDelete .getSelectedItemPosition() == 0) { Code.i = true; int len = mListView.getCount(); SparseBooleanArray checked = mListView .getCheckedItemPositions(); for (int i = 0; i &lt; len; i++) if (checked.get(i)) { File file = new File(MEDIAPATH); boolean deleted = file.delete(); } </code></pre> <p>where media path contains</p> <pre><code>private static final String MEDIA_PATH = new String( Environment.getExternalStorageDirectory() + "/AudioRecorder/"); </code></pre> <p>I have tried with below link but not getting solution as i want</p> <p><a href="https://stackoverflow.com/questions/1248292/how-to-delete-a-file-from-sd-card">How to delete a file from SD card?</a></p> <p><a href="https://stackoverflow.com/questions/17880187/delete-file-in-sd-card-android-with-string">Delete File in SD Card android with string</a></p> <p><a href="https://stackoverflow.com/questions/18545477/delete-file-on-sd-card-from-a-listview">Delete file on sd card from a listview</a></p> <p><a href="https://stackoverflow.com/questions/18545477/delete-file-on-sd-card-from-a-listview">Delete file on sd card from a listview</a></p> <p><a href="https://stackoverflow.com/questions/10006127/how-to-delete-a-particular-file-from-the-paticular-folder-in-sdcard-when-click-o">how to delete a particular file from the paticular folder in sdcard when click on check boxes in list view</a></p> <p><a href="https://stackoverflow.com/questions/16982647/how-can-i-make-a-file-to-disappear-once-if-it-is-deleted-in-android-sd-card">How can I make a file to disappear once if it is deleted in android SD card?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload