android - File.deleteOnExit - Unix trick from comments -
here's source comment method:
note on android, application lifecycle not include vm termination, calling method not ensure files deleted. instead, should use appropriate out of:
* use {@code finally} clause manually invoke {@link #delete}. * maintain own set of files delete, , process @ appropriate point in application's lifecycle. * use unix trick of deleting file readers , writers have opened it. no new readers/writers able access file, existing ones still have access until last 1 closes file.
can explain me "unix trick" mentioned in , how use it?
this answer has explanation: https://stackoverflow.com/a/5219960/200508. basically, means "deleting" file on unix system doesn't erase disk; instead, deletes reference file directory it's in. file isn't erased until processes using terminate. thus, can open temporary file , delete it, , whenever program terminates automatically erased.
Comments
Post a Comment