2

I have an Nook Color (Android 2.1) device and the app which is going to read some huge files (PDFs) from sdcard. I'm going to use FileInputStream for file reading (and it works fine both on emulator and on Android 2.2+ devices). Unfortunately it works painfuly slow (about 25 sec for 125Mb file) while executing the following code:

FileInputStream fileInputStream = new FileInputStream(filename);
fileInputStream.skip(offset);
BitmapFactory.Options options = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeStream(fileInputStream, null, options);
fileInputStream.close();
return bitmap;

The file is placed somewhere on sd card. The offset could points to any point at the file (even to the beginning) -- the problem is still in place.

What could be a reason of this performance problem?

Nas Banov
  • 28,347
  • 6
  • 48
  • 67
Vladimir
  • 9,913
  • 4
  • 26
  • 37

1 Answers1

3

That equates to a read speed of 5mb/s, which is about on par with the speed of MicroSD cards in most Android devices I've used.

Higher end SD cards may get higher performance, but there's nothing in code you can do to speed this up.

James Davies
  • 9,602
  • 5
  • 38
  • 42
  • I will gladly believe you, but under android 2.2+ (and I'm not completely unsure about 2.1) devices the reading tooks less than 1 second for the latest pages of the 128Mb PDF (the page is located at the end of the file). – Vladimir Feb 14 '11 at 16:02
  • Moreover as android is based on linux, something tells me that seeking through a large file even in the FAT fs used on sd cards does not require reading of all the file prefix. And also the reading of the page (500kb) even in the beginning of the file tooks > 25 sec. And this time does not depends on where the page is located within the file. – Vladimir Feb 14 '11 at 16:06
  • If you're skipping to the end of the file and only reading a small amount, then that's a different scenario. In that case you'd be getting a much lower actual read speed. Are you saying that the code works fine on Android 2.2 on a regular device (i.e. HTC Desire) but runs incredibly slowly on the Nook? – James Davies Feb 14 '11 at 22:51
  • Yes, exactly. Moreover it runs well on HTC Hero which is android 2.1. – Vladimir Feb 15 '11 at 01:14
  • I would suspect it might actually be a bug in the Nooks firmware then? My first guess would be that the seek implementation is buggy? What filesystem does it use? – James Davies Feb 15 '11 at 02:14
  • Actually after a big of googling, it appears a lot of people are having issues with Slow IO access to the SD Card on the Nook. – James Davies Feb 15 '11 at 02:16