Jainendra
Jainendra

Reputation: 25143

How efficient is reading a big xml file from sdcard?

I've a big XML file(6000 lines, 1.4MB) stored in the /mnt/sdcard folder. I want to read one node from the XML file to fetch the version from the file in my Android application.

Since the file is big and stored in sdcard, so will the reading of XML slow down the performance?

Upvotes: 0

Views: 505

Answers (2)

Dheeraj Vepakomma
Dheeraj Vepakomma

Reputation: 28697

If you need to read only one node, why don't you use XPath?

It may or may not provide performance speedup compared to parsing using SAX or DOM (you need to benchmark it for your case yourself), but it might simplify your code.

Upvotes: 1

Jan Schejbal
Jan Schejbal

Reputation: 4033

Yes, reading and parsing 1.4 MB of XML will take some time (from my experience, I'd estimate between 0.1 and 2 seconds). How much depends on how you do it, and if it's acceptable depends on what you consider acceptable. I'd suggest to just benchmark it yourself.

Also, use a parser like SAX that can stop reading once you have the data. This way, if the version is usually at the beginning, you don't need to read and parse the entire file. If you know that the version is always the first line, performance will probably be very good.

Upvotes: 1

Related Questions