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

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -