How do I record audio to file?(Android)

I used the following method to write butter to a file, but the file is corrupt. How can I solve it?
sound ->readData(&irData[1], irdatalength-sizeof (short), &irDataRead);
Fwrite (& irData [1], irDataLength, sizeof (short), FPW);

Do you need to set system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER)?
But if you set up the FMOD_OUTPUTTYPE_WAVWRITER, you will not be able to run.

How does the FMOD_OUTPUTTYPE_OPENSL mode output sound to a file?

To access the data from a recorded sound, you are best off using Sound::lock & Sound::unlock.
https://fmod.com/resources/documentation-api?page=content/generated/FMOD_Sound_Lock.html#/

The data from FMOD should not corrupt the file, it would be more likely to do with the writing of the file. eg. Make sure the file is being closed after writing to it.

Is there a simple learning example?

At the moment we don’t have any examples using lock/unlock, although we are planning on adding some.

It just needs to be used in place of system->readData().
ReadData will attempt to decode the data, store it in memory and internally call system->lock() to get the data buffer. If you are trying to access the recorded data, before it is written to file, it does not need to be decoded.

Thank you for your help. Now I still don’t understand the specific process. Could you please write the main steps?