Data Storage and Persistence
Posted: Wed Aug 05, 2015 10:04 pm
I'm doing my first mobile app - a physics educational app for my students, my school, and whomever. I've read all I've could about data storage and persistence for mobile; its been enough to leave me confused. I have three challenges - one on which I've succeeded, one on which I'm failing, and one I have't tackled yet. I need help on the latter two.
Challenge #1 (success): I've successfully been able to write to a .txt file and retrieve information from session to session; this includes such as student name, ID, teacher name, teacher email, progress records, etc. I write/read the info on start-up and whenever necessary; it's working just like the docs say it should in the IDE, the simulators and on Android and iOS devices.
Challenge #2 (currently unsuccessful): Using nearly identical methods, I've tried to save the user state within the app to a file and then read that state and restore the state of the app at the time of "shut down" or when the user leaves the app and returns. So I have what seems to be called a "splash stack" or "launcher stack" that uses an on openStack handler on the first card to read from a .txt file and determine which stack and which card on the stack that the user was on when s/he left the stack. The method works in the IDE and restores the state of the app. However, it does not work on the iOS simulator or on an iOS device. The on openStack handler is executing, reading from the .txt file, and even determining the target stack and target card to which it should navigate. I'm using the close command to close the splash stack and the go to card targetCard of stack targetStack but the app stays on the first card of the Splash stack.
Challenge #3 (not attempted): The meat and potatoes of my app are assignments that consist of questions that the student must answer. There's as many as 40 questions appearing on their separate cards and grouped in as many as 10 groups of 4 questions. There is quite a bit of scripting taking place to determine which questions have been delivered (its random, requiring 1-2 correct answers from each group), which groups have been completed, which groups have been flagged by user to be included in a special review exercise, etc. Data is stored (transparent to the user) on the second card of the stack; there's a lot of data stored there. If the user leaves the app or quits in the middle of an assignment, it will be quite a task to save the state of the app. So I'm considering saving a copy of the stack to the documents folder when the assignment starts up and then just saving that stack on shutdown. On returning to the app, my splash stack can read from the usual .txt file and then open the stack from the documents folder. From what I've read, I can't tell if this is permitted on mobile devices. (And of course, I have to get #2 working before I can execute this plan ... or any other plan).
I'm having a related issue with all this such as, on shutDown handlers do not seem to be catching the message in the simulators and the devices when placed in stack scripts; I'm only getting them to work on card scripts. Thus, I'm writing state information to .txt files when navigating to a new stack or a new card within a stack.
I appreciate any help I can get as I am a real beginner. Thanks.
Challenge #1 (success): I've successfully been able to write to a .txt file and retrieve information from session to session; this includes such as student name, ID, teacher name, teacher email, progress records, etc. I write/read the info on start-up and whenever necessary; it's working just like the docs say it should in the IDE, the simulators and on Android and iOS devices.
Challenge #2 (currently unsuccessful): Using nearly identical methods, I've tried to save the user state within the app to a file and then read that state and restore the state of the app at the time of "shut down" or when the user leaves the app and returns. So I have what seems to be called a "splash stack" or "launcher stack" that uses an on openStack handler on the first card to read from a .txt file and determine which stack and which card on the stack that the user was on when s/he left the stack. The method works in the IDE and restores the state of the app. However, it does not work on the iOS simulator or on an iOS device. The on openStack handler is executing, reading from the .txt file, and even determining the target stack and target card to which it should navigate. I'm using the close command to close the splash stack and the go to card targetCard of stack targetStack but the app stays on the first card of the Splash stack.
Challenge #3 (not attempted): The meat and potatoes of my app are assignments that consist of questions that the student must answer. There's as many as 40 questions appearing on their separate cards and grouped in as many as 10 groups of 4 questions. There is quite a bit of scripting taking place to determine which questions have been delivered (its random, requiring 1-2 correct answers from each group), which groups have been completed, which groups have been flagged by user to be included in a special review exercise, etc. Data is stored (transparent to the user) on the second card of the stack; there's a lot of data stored there. If the user leaves the app or quits in the middle of an assignment, it will be quite a task to save the state of the app. So I'm considering saving a copy of the stack to the documents folder when the assignment starts up and then just saving that stack on shutdown. On returning to the app, my splash stack can read from the usual .txt file and then open the stack from the documents folder. From what I've read, I can't tell if this is permitted on mobile devices. (And of course, I have to get #2 working before I can execute this plan ... or any other plan).
I'm having a related issue with all this such as, on shutDown handlers do not seem to be catching the message in the simulators and the devices when placed in stack scripts; I'm only getting them to work on card scripts. Thus, I'm writing state information to .txt files when navigating to a new stack or a new card within a stack.
I appreciate any help I can get as I am a real beginner. Thanks.