Android: is it more efficient to use a text file or XML file to store static data

I have some reference data in a text file (~ 5 MB) that I want to use with the android application for applications.

The file has the format:

1|a|This is line 1a
1|b|This is line 1b
2|a|This is line 2a
2|b|This is line 2b
2|c|This is line 2c

What I want to know is the most efficient way (less memory, faster, size, etc.) to use this file in my application.

a.) Should I save the file as a raw resource and open and read the entire file whenever I need a specific line.

b.) Should I convert the file to XML and use XPath to query the file when I need to find the value

<!--sample XML -->
<data>
  <line number="1">
     <entry name="a">This is line 1 a</entry>
  </line>
</data>

c.) Should I just copy and paste the whole file as a static array of strings into the application and use it.

... any other suggestions are welcome.

[EDIT] , . " 1a".

+3
4

XML , CSV . XML , . XML, , 2-3 , , .

, "" , , , , .

+3

, . , , , , " ".

? - ? - ? SQL, - ? ​​ Google?

, , .

... .

? , " " "" : ? ? ? ? - ?

, , , :

  • ?
  • : ? ? deltas/diffs? - ?
  • ASCII? UTF-8? - ?

..

-, , " SQLite", .

+3

, Android XML , , XML. , , , , SQLlite ( ). .

, imo, , .

+1

If you define efficiency as (less memory, speed, size, etc.), a flat or limited file will load and save faster.

However, people use XML because they are willing to trade at this speed for greater flexibility and ease of use of XML.

0
source

Source: https://habr.com/ru/post/1714083/


All Articles