Android 2.1文件读取速度慢
我有一个 Nook Color (Android 2.1) 设备和应用程序,它将从 sdcard 读取一些大文件 (PDF)。 我将使用 FileInputStream 进行文件读取(它在模拟器和 Android 2.2+ 设备上都可以正常工作)。 不幸的是,在执行以下代码时,它的运行速度非常慢(125Mb 文件大约需要 25 秒):
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;
该文件放置在 sd 卡上的某个位置。偏移量可能指向文件中的任何点(甚至到开头)——问题仍然存在。
造成此性能问题的原因可能是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这相当于 5mb/s 的读取速度,与我使用过的大多数 Android 设备中 MicroSD 卡的速度相当。
更高端的 SD 卡可能会获得更高的性能,但您无法在代码中执行任何操作来加快速度。
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.