Static Data Structures on Embedded Devices (Android in particular)
- by Mark
I've started working on some Android applications and have a question regarding how people normally deal with situations where you have a static data set and have an application where that data is needed in memory as one of the standard java collections or as an array.
In my current specific issue i have a spreadsheet with some pre-calculated data. It consists of ~100 rows and 3 columns. 1 Column is a string, 1 column is a float, 1 column is an integer. I need access to this data as an array in java.
It seems like i could:
1) Encode in XML - This would be cpu intensive to decode in my experience.
2) build into SQLite database - seems like a lot of overhead for static access to data i only need array style access to in ram.
3) Build into binary blob and read in. (never done this in java, i miss void *)
4) Build a python script to take the CSV version of my data and spit out a java function that adds the values to my desired structure with hard coded values.
5) Store a string array via androids resource mechanism and compute the other 2 columns on application load. In my case the computation would require a lot of calls to Math.log, Math.pow and Math.floor which i'd rather not have to do for load time and battery usage reasons.
I mostly work in low power embedded applications in C and as such #4 is what i'm used to doing in these situations.
It just seems like it should be far easier to gain access to static data structures in java/android.
Perhaps I'm just being too battery usage conscious and in my single case i imagine the answer is that it doesn't matter much, but if every application took that stance it could begin to matter.
What approaches do people usually take in this situation? Anything I missed?