I have 2 activities SingActivity and ExoPlayerActivity. In SingActivity, user records a song and the song is saved in internal storage. As soon as the song is saved, I am opening ExoPlayerActivity to play the song. The ExoPlayerActivity has a save button.
If user presses save button, then I am doing nothing as song is already saved after recording. If user does not press save button and exists from ExoPlayerActivity, I am deleting the file which was saved. Suppose user is in ExoPlayerActivity and user puts the app in background and swipes the app from background, then too I want to delete the file as saved is not pressed.
So my question is where to put the delete code? I can't put in onDestroy or in finish() as they are not called every time and may cause problem in case of resource constraint scenario.