Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
             File file = new File(path);

if(file.exists()) {

                    file.deleteOnExit();
                    Toast.makeText(this, "File deleted.", Toast.LENGTH_SHORT).show();
                    finish();   
  
}else 
{
                    Toast.makeText(this, "File not exists", Toast.LENGTH_SHORT).show();
                
}


What I have tried:

I am trying to delete to file but it is not deleting. The program end after exceuting finish() function showing toast "File deleted". The debugger shows the file path also but file is not deleting. It is still there. Please help.
Posted
Updated 19-Aug-20 7:28am

1 solution

Re: deleteOnExit()

Quote:
deletes the file or directory defined by the abstract path name when the virtual machine terminates.
 
Share this answer
 

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