I have looked at your app. You are making things very hard for yourself by having so much repetitive code and I spent several hours trying to simplify it. I made some good progress, reducing your project to just two activities (Main and one other handling all of the quiz levels) plus a class module to manage the data. But eventually I decided that I could not, at this late stage, handle the keyboard layouts in a way that I knew would be reliable, so I retreated to a very simple fix.
You can remove all references to "activityState". There are only two values that your KVS needs to remember - the level at which to restart the quiz, and the score so far.
In your Main activity you need these two code blocks ...
In Main.ActivityCreate ...
If FirstTime Then
kvs.Initialize(xui.DefaultFolder, "appState")
If (kvs.ListKeys.Size = 0) Then
kvs.Put("startAt", 1)
kvs.Put("score", 100)
End If
End If
and at the and of the activity ...
Private Sub Buttoninfo_Click
Dim start As Int
start = kvs.Get("startAt")
Select start
Case 2 : StartActivity(Level2)
Case 3 : StartActivity(Level3)
Case 4 : StartActivity(Level4)
Case 5 : StartActivity(Level5)
... etc etc
Case Else
StartActivity(Level1)
End Select
End Sub
In every "Levelx" module you need to have these two subroutines at the start ...
Sub Activity_Resume
numeroPellicole.Text = Main.kvs.Get("score") ' Retrieve the score
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Main.kvs.Put("score", numeroPellicole.Text) ' Remember the score
End Sub
... and in the "levelup_click" routine, replacing the "??" with the number of the next quiz level ...
... ...
... ...
mediaplayer4.Initialize
mediaplayer4.Load(File.DirAssets,"giusto.wav")
mediaplayer4.Play
Oscar.x = y1 + 10 ' Moved from after "StartActivity ..."
' Add the next two lines ...
Main.kvs.Put("startAt", ??) 'Update next level number
Main.kvs.Put("score", numeroPellicole.Text) ' Remember the score
StartActivity(Level??) ' Next level activity name
... ...
... ...
If this is not clear then come back to me. Good luck.