java - How to delete a file stored in my device using OnItemLongClickListener? -
i have listview display files inside folder. method delete file using onitemlongclicklistener?
thank you.
inside onitemlongclicklistener()
method call method. here path.get(position) arraylist used. should change giving file location according requirement.
public void dodeletefile(listview l, view v, int position, long id){ file filetodelete = new file(path.get(position)); if(!filetodelete.isdirectory()){ try{ if(filetodelete.delete()){ system.out.println("file deleted successfull !"); }else{ system.out.println("file delete operation failed"); } }catch(exception ex){ system.out.println("exception :"+ex.getmessage()); } }else{ system.out.println("it not file"); }
Comments
Post a Comment