Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing a recyclebin app like dumpster. When i am going to delete any file from any file manager (Astro file manager, ES file explorer) , i am getting the file path of the deleted file using fileobserver. But fileobserver is returning after completion of the operation (operation like delete, modify etc..). Is it possible to get the file path before deleting the file ? or to override the delete() ?
Posted

1 solution

I don't think it is possible to get the file path before deleting it.Consider the logic behind,you want to delete a file,so FileObserver don't let you notify until you delete it and also you don't get that path before deleting.

But i think it could be done implementing some simple things.I don't familiar with FileObserver,so i don't talk about that.I assume,you have the list of files that you want to delete or it may be a list works like File Manager.
So when you click on specific file item of that listview you can get the path of that file from code behind by:
Java
File file = new File("fileName.txt");
String filePath = file.getAbsolutePath();

You can then prompt a confirmation dialog asking user he want to delete that file or not?If user choose delete then you can do it by:
Java
File file = new File(selectedFilePath);
boolean deleted = file.delete();

But look, before deleting you have the file path of it, isn't it?
 
Share this answer
 
v4
Comments
hk.v 21-Aug-13 3:51am    
It will work for our own file explore. But user can delete the file from diff explorers (like es file explore, astro FM). At that time how to get the path before deletion?
ridoy 21-Aug-13 3:56am    
Then you need to check for similar methods of Astro FM.You can't do something like that if they don't implement something that would retrieve a path before deleting a file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900