Audio data is saved in the same way as here:
// 1. create AudioRecord instance
// 2. audioTrack.play();
// 3. in separate thread reading into buffer
// int bytesRead = audioRecord.read(buffer, 0, bufferSize);
// 4. save buffer to file
// fio.write(buffer, 0 , bytesRead);
// 4. audioTrack.stop();
What codec/format is used as saved file can’t be opened as WAV file, but can be read and played using AudioTrack class?
No codec is used. It reads raw samples. If you want to save to .wav file you should first write a .wav header to file.Look at this example