My Android application will use big and very big files (i.e. between the size of 10MB and 2GB).
I've always been wondering about what hardware is used by smartphones for stable storage, and whether the software (file reading/seeking) considerations are similar here as for PC hard disks. I tried to find information about hardware and have some sort of picture about it (internal storage, SD card), but none of the sources I checked are comprehensive and/or specific enough. My (interrelated) questions are:
InputStream
reading and seeking (skipBytes), is there a difference (e.g. on Android) between using the internal storage and the SD card (I intentionally didn't write "external storage", because it's not necessarily the SD card on every device)? Is the SD card slower?BufferedInputStream.read()
(e.g. in a DataInputStream
) to read them (and using skipBytes()
for seeking wherever necessary). Therefore, in the underlying file system, this may require "going through" the entire 2GB file. (E.g. Android uses the linux functions to seek in the file when needed.) However, is seeking as efficient as in a PC hard disk? What about the SD card vs. internal storage in terms of seek efficiency?I know benchmarking for my concrete application is a must, but I would welcome a theoretical clarification in the matter as well.
IMPORTANT: when I ask that "... is seeking as efficient as in a PC hard disk?", I don't (only) mean the absolute values but also the mechanism of it. That is, if it works based on the same logical principles (= skipping large parts whenever possible), or there are some drawbacks (e.g. such "skipping-based" seeking is not possible on an SD card, and thus skipping is much more -- i.e. non-proportionally -- useless on a smartphone hardware than on a PC hard disk).
Trying to answer your questions
There's only one difference, that's if your files are into the app package (within app), because you need to open it using a different method, however if it's inside app package and into package/file/ than you can use the same File file bla.. .
Smartphones internal memory is faster than HDD, though ifyou store it in a external SDCard, this will change due that SDCards have maximum speed for read and write.
Yes there is differences... if reading from internal or SDCard (not the external SD card), other else we shouldn't have devices with 1 or 2GB and 16Gb for storage. Everything that it's within that main memory will run faster.
Seeking is always a slow task, you can once got all date that you need close the stream, even if you didn't have reached the end of the file. What you can do to get faster is go reloading a cache everytime that your app has readed some amount of KBs or MBs... than you can lunch a asyncTask to go loading it, and once the main thread has finished will look for more data if exist. This should speed up a lot, because you will be searching just in memory.
You will need a app for that or write your own, that shouldn't be too difficult, you can use handler, and load as much as you can in an array or list, and count the bytes, and repeat it on other memory types (internal SD card and external SDCard).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With