Local Variables not working on phone but do on test
I have a simple quiz (2 questions), where a right and wrong answer is displayed on each page in a radio button. A local variable is assigned to the options with either a value of 1 or 0 being assigned to the local variable.
Question 1
Correct: (Variable name: t1, Value: 1) or Wrong: (Variable name: t1, Value: 0)
Question 2
Correct: (Variable name: t2, Value: 1) or Wrong: (Variable name: t2, Value: 0)
I then have a results page where I have some JavaScript to calculate the sum of the local variables and display the results in a couple of labels.
var sumValue = parseInt(localStorage.getItem('t1')) + parseInt(localStorage.getItem('t2'));
Appery('result').text(''+sumValue);
if (sumValue == 0) {
Appery('message').text('0 correct answers');
}
if (sumValue == 1 ) {
Appery('message').text('1 Correct Answer');
}
if (sumValue == 2) {
Appery('message').text('2 Correct Answers');
}
In TEST mode, the quiz works perfectly - the correct local variables are being assigned and the correct total scores are being displayed on the results page.
However, when I export the APK file and load it on my phone (HTC One x Plus Android Version 4.2.2) the results page always shows 0 score despite selecting the correct questions.
Please can you help, as I used the same technique for another app about 6 months ago which worked fine - so it seems that something has changed.