Need advice or recommendations about data storage (properties)

Former Member
Former Member
I'd like to get some advice from more experienced Connect IQ developers concerning data storage.

Let's assume I would like to store 18 GPS coordinates as one set of data (if you think of the position of 18 greens on a golf course, that's a good guess). The app needs only one value at a given time (the position of the green on the current hole).

Let's also assume that in a later stage I would like to keep more than one set of 18 coordinates (for different courses), e.g. 9 courses numbered 1-9. The user would select which set to use for a round, and the app would then load and store the corresponding positions.

Is there a particularly good or a particularly bad way how to define and handle a data structure? Is it better to keep 9 * 18 coordinates in 9 * 18 properties, or are 9 arrays of length 18 in 9 properties better (i.e. faster/more memory efficient)? Or 9 dictionaries? Or one property holding all 9 * 18 coordinates?

I would assume that it is a bad idea to load more than one coordinate at a time (e.g. a full course), which would point to 9 * 18 single properties. Am I wrong?

Last question, and I think I know the answer: is there a way how two apps could share the same set of properties? Think of a separate app to create and edit course data, in order to keep the actual score tracker lean.
  • I think the key here may be to abstract away the detail as to how the data is stored/arranged into a single class in your code. That way if you find out it can be done a better way you can change a few lines in one class and everything will continue to work.

    As for your actual question, I'm not sure which is 'better'. If you don't care to have names for each of the courses, I'd try to store the data as an array of arrays of coordinates (i.e., one array with 9 elements, each element being an array of 18 coordinates). I'm not sure about how the data store actually works, but I'm guessing it loads all of the persisted data in the entire data file into memory. If this is the case, I might just store all of it in one property. If you want to give names to each of the courses, I'd create a map of strings to arrays of 18 coordinates.

    Two apps cannot share the same properties. Eventually, Garmin is supposed to provide a mechanism to allow people to modify properties from Garmin Connect Mobile and Garmin Express, but nobody really knows how far off that is.

    Travis
  • Former Member
    Former Member over 10 years ago
    Keep in mind that objects are not a supported type for the object store. For locations, you would need to use the .toDegrees or .toRadians values (and convert to float I think) if you want to save them in the object store.

    Details on supported types are in the documentation.