How to send an audio file from Android phone to computer?


I'm working on an Android app that makes phone call recording on a mobile device.

I just need to send a copy of the audio file to the computer via TCP / IP. I already have a function that sends text to the computer. But how to send an audio file?

In the computer I already have a server made in Delphi that communicates with the cell phone and vice versa. I also know how to do it, in Delphi, to receive the file on the computer. I just do not know how to make the code to send from the mobile.

Does anyone have an idea?

asked by anonymous 20.09.2016 / 04:00

1 answer


Asynchronously ....

    Socket socket  = null;
    BufferedInputStream bufferedInputStream = null;

    try {
        socket = new Socket("", 8901);
        bufferedInputStream = new BufferedInputStream(socket.getInputStream());
        int counter = 0;
        String path = "/mnt/sdcard/ad.wav";
        FileOutputStream fileOutputStream = new FileOutputStream(new File(path));
        byte jj[] = new byte[1024];
        while ((counter =, 0, 1024)) != -1) {
            fileOutputStream.write(jj, 0, counter);
    } catch (Exception e) {


I just organized the code suggested in the comments by checkmate .

14.12.2016 / 18:47