How to pause recording and play or overwrite the audio being recorded

Apr 13 at 6:44 AM

I am recording an audio which I want to pause the recording and rewind and play then pause again and start recording to overwrite some of already recorded audio, how is that possible?
The audio is either in use or corrupted
Can anyone provide a sample code snippet ?