-1

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?

BC2
  • 892
  • 1
  • 7
  • 23
lou
  • 71
  • 7

2 Answers2

0

Thats not the fat32 format which is slowing you down. its the bus speed of your phone, SD Card Clock, Processor and so on. Just cant blame the format on that much overhead.

alknows
  • 1,972
  • 3
  • 22
  • 26
  • I'm blaming the filesystem because is one thing that the two 'slow' devices have in common and none of the other devices has. – lou Oct 01 '13 at 14:46
0

There many reasons that can be source of your problem. First, take a look at the limitations of a fat32 filesystem. Also your hardware maybe affecting the device's performances. Example (The speed of taking a 15 Megapixel photo with a quad core 1,6 Ghz processor is the same as 600 Mhz processor)