1

I am building an app to read results from color measurement devices, and for this purpose I need to know how to store an array of results to a local file on an android smartphone/tablet and read it back from that file so that it's once again an array I can work with.

The results will be result objects, because I also need to tell when the measurement was taken, and what measurement mode was used (such as B/W-measurement or measurement of a light source).

I know how to get strings in and out, but as far as I know, transforming that to an array is impossible without bodgy and inelegant code.

So where do I even get started here?

Should I use plain .txt?

Or should I try to use .xml or .json files?

1 Answer 1

1

You should use standard formats for your storing. The json format is a good one for structured data because many tools support displaying or even parsing it.

For instance, you may store it like this

[   
   [
      "result1",
      "23:00",
      "B/W"
   ],
   [
      "result2",
      "18:14",
      "Color"
   ]
]

You can see, if you store it to e.g. test.json and drag'n'drop it on the Firefox browser, it recognizes the format and supports cool displaying. So using standard formats for structured data is a good idea, programming libraries and even programming languages like Python support it with special classes or functionality. It's also easy for you to code the data dump or the parser by yourself.

Also XML is a good format. Actually, .json is more modern while .xml was there first. What to choose depends on in which programming world you are. Some more support this, some more that. For your purposes, it doesn't matter which one you use. I've seen .json much in the Android world but probably because it is just more modern.

But remember, the format is just the framework, which data content you put into it is up to you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.