I need to allocate files of (large) given size on Android devices.
Doing as following takes no time on most devices.
RandomAccessFile fileStream = new RandomAccessFile("test.txt", "rw");
fileStream.seek(FILE_SIZE - 1);
fileStream.write(0);
Unfortunately on two devices which use fat32 for their storages the operation seems quite slow (90-100secs. for a 2GB files).
I also tried using java.nio but I'm getting the same results.
FileOutputStream fos = new FileOutputStream(f);
FileChannel fc = fos.getChannel();
fc.position(FILE_SIZE - 1);
fc.write(ByteBuffer.wrap(new byte[]{0}));
fos.close();
Any idea how to speed up this operation on those two devices?