Bluetooth file transfer Android

I was able to solve this problem by sending small chunks of data out to the bluetooth outstream. It turned out that 8 * 1024 was a good buffer size, which helped in sending out data seamlessly over the stream as well as preventing corruption of data at the receiving end.

BufferedInputStream bis = new BufferedInputStream(fis, 8 * 1024);


byte[] buffer = new byte[8192];
int len
while ((len = bis.read(buffer)) != -1) {
    outStream.write(buffer, 0, len);
}

Leave a Comment