Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd go a modified #5:</p> <p><strong>strings.xml</strong>:</p> <pre><code>&lt;string-array name="some_data"&gt; &lt;item&gt;string|0.56|100&lt;/item&gt; &lt;/string-array&gt; </code></pre> <p><strong>Parser.java</strong>:</p> <pre><code>String[] arr = getResources().getStringArray(R.array.some_data); for (String str : arr) { string[] columns = str.split("|"); // to Java objects or parallel arrays } </code></pre> <p>Microbenchmark:</p> <pre><code>&lt;string-array name="data"&gt; &lt;item&gt;some0|10|1.0&lt;/item&gt; ... &lt;item&gt;some99|199|1.99&lt;/item&gt; &lt;/string-array&gt; @Override public boolean onPrepareOptionsMenu(Menu menu) { long start = System.currentTimeMillis(); String[] arr = getResources().getStringArray(R.array.data); ArrayList&lt;Triple&gt; triples = new ArrayList&lt;Triple&gt;(); for (String s : arr) { String[] parts = s.split("\\|"); Triple tr = new Triple(); tr.str = parts[0]; tr.i = Integer.valueOf(parts[1]); tr.f = Float.valueOf(parts[2]); triples.add(tr); } System.out.println(System.currentTimeMillis() - start); return true; } static class Triple { public String str; public int i; public float f; } 05-02 21:17:50.418: INFO/System.out(609): 125 05-02 21:17:51.128: INFO/System.out(609): 124 05-02 21:17:52.368: INFO/System.out(609): 124 05-02 21:17:53.158: INFO/System.out(609): 127 05-02 21:17:53.858: INFO/System.out(609): 123 05-02 21:17:54.688: INFO/System.out(609): 124 05-02 21:17:55.778: DEBUG/dalvikvm(609): GC freed 14380 objects / 525008 bytes in 136ms </code></pre> <p>On a <strong>1.6 ADP1</strong>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload