Sorry, maybe I spoke too soon.
It worked once. But now it keeps creating a file of zero length. I have tried deleting the file and even the directory but it recreates the file with zero length again.
Sub SaveWavFile
Dim raf As RandomAccessFile
Msgbox("Saving to sd card","")
raf.Initialize(File.DirDefaultExternal, "packet.wav", False)' open the file which will end up in I:\Android\data\test.test.test\files (test.test.test is my program)
raf.WriteBytes(audiofile,0,30000, 0) ' write bytes. Is 32768 the max size as this is an integer variable
raf.close
End Sub
I'm not sure what that last parameter in writebytes is supposed to be. It is called "position" but I can't find a description.
And it is a bit of a mystery why it has gone from saving a 30k file to saving one with zero length.
Addit: Yikes, this is going to be hard to debug. Sometimes it saves a 30k file, and sometimes a 0k file. I added this at the end
Msgbox("Finish saving","")
just in case I was pulling the sd card out too early. I have a suspicion though that the msg box comes up before the sd card has finished writing.
Ah, yes I think that is it. I waited a while, and then hit the sd icon on the Android and selected "safely remove card" and then it saved the data.