/*Files will be clicked here*/
@Override
protected void onListItemClick(ListView l,View v, final int position, long id){
filePosition=new File(path1.get(position));
System.out.println("File position:"+filePosition);
if(filePosition.isDirectory()){
if(filePosition.canRead())
getDirectories(path1.get(position));
else
{
new AlertDialog.Builder(VideoSDcard.this)
.setIcon(R.drawable.folder)
.setTitle("["+filePosition.getName()+"]folder can't be read!")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
}
}
else {
AlertDialog.Builder alert=new AlertDialog.Builder(this);
alert.setIcon(R.drawable.folder);
alert.setTitle("Do you want to Delete this File from SD card ?"+" [ "+filePosition.getName()+" ] ");
//.setTitle("["+filePosition.getName()+"]")
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
/*Deleting a File*/
deleteFile(); // here deleting a file
}
private void deleteFile() {
boolean deleted= filePosition.delete();
}
});
I am browsing the files and directories from SD card. So Iam displaying it by using listview. When I don't need a file on sd card so I could be able to delete a file.
My problem is, after I deleting a file it has deleted completely on SD card but it is visible on listview. I meant in emulator. After deleting a file from the list , it should be disappear.
For an example:- I am having song.mp4 file on sd card. Once I deleted this file "song.mp4" then it should not be displayed again in a listview.
How should I do this?