I have made a program which populates a listview with videos stored on the device and plays them. It have also tried to implement the functionality of deleting the file using file.delete function. However, after using notifydatasetchange() function, the file is still shown in the listview. Moreover, I just noticed that the video file was deleted from the DCIM folder; however, it is showing up in the Gallery of the device but when you click it, it can't be played.. Here is the part of code where I am showing a dialog box to the user, when the user clicks Yes , then the delete function is performed.
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
file.delete();
adapter.notifyDataSetChanged();
//list.setAdapter(adapter);
break;
case DialogInterface.BUTTON_NEGATIVE:
image2.setImageResource(R.drawable.play);
flag.setText("play");
//No button clicked
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("This Item will be Deleted\nAre you sure?").setPositiveButton("Yes", dialogClickListener)
.setNegativeButton("No", dialogClickListener).show();
}// else closes
I don't understand why it is happening. Any useful suggestions please...