Java.IO.File.DeleteOnExit Method
Schedules this file to be automatically deleted when the VM terminates normally.

Syntax

[Android.Runtime.Register("deleteOnExit", "()V", "GetDeleteOnExitHandler")]
public virtual void DeleteOnExit ()

Remarks

Schedules this file to be automatically deleted when the VM terminates normally.

Note that on Android, the application lifecycle does not include VM termination, so calling this method will not ensure that files are deleted. Instead, you should use the most appropriate out of:

  • Use a finally clause to manually invoke File.Delete.
  • Maintain your own set of files to delete, and process it at an appropriate point in your application's lifecycle.
  • Use the Unix trick of deleting the file as soon as all readers and writers have opened it. No new readers/writers will be able to access the file, but all existing ones will still have access until the last one closes the file.

[Android Documentation]

Requirements

Namespace: Java.IO
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1