Closed Fertogo closed 8 years ago
It looms from here that the number of totalWorkouts
was stored in key 0.
If this key exists I should delete all possible keys that could exist for the old version. That should be all keys [0,21]
and [337,344]
//Menu data
int totalworkouts = atoi(readFromStorage(0));
NUM_FIRST_MENU_ITEMS = totalworkouts;
for (int i = 0; i<totalworkouts; i++) { //Populate workout_names array
char * temp = readFromStorage(i+1);
//workout_names[i] = temp; // This does not work because of issues with pointers. (Every element becomes the last)
workout_names[i]= malloc(sizeof(char)*(strlen(temp)+1)); // Save workout titles
strcpy(workout_names[i], temp);
}
From there I can save the current version in any unused key (except 0!).
Some flag saved to persistent storage on the Pebble to make data migrations much easier.
Also, I'll need to make sure to clear all memory if an app was running an older version.