Question

I have a class called GraphView that extends View and I do some calculations in side this class
The object of this class represents a custom Graph that I display on the screen. This is created in the MainActivity file

I need to save the value of an array inside the extended View class so I want to create a RandomAccessFile object inside the class, I will probably initialize this object inside the constructor of GraphView, but where do I specify the close() function?

The graph will stay on screen as long as the program runs so I am not sure where the close() function should be, as there does not seem to be a destructor in Java.

Was it helpful?

Solution

It's better to open and close a file straight away after you're done with reading/writing. Don't keep it open as you cannot tightly control what happens to your view (e.g. other processes can come in front, OS can decide to kill your process, etc).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top