Stored text file is overwritten with Null values...

DevBaby

Active Member
Licensed User
Longtime User
I have a stored text file (DirInternal) along with my app to hold the user’s information and game settings.

When I open the physical keyboard on my test device (Samsung Transform), the program closes and then tries to run “Activity_Create” again, but then fails. The error occurs because I am now reloading panels etc. and I get an initialized error (even with checking for Firstime variable). I can only seem to fix this by calling ExitApplication on my Activity_Pause. The App will close when the keyboard is opened and then the user will have to launch the app via the icon. But the app loads with no errors.

I did not like this fix so I took the ExitApplication out of Activity_Pause. However, now I notice that when the error occrrs (from opening the physical keyboard), the values in my user text file (saved in DirInternal) all reset to null.

When the program reloads after the error, the app shows either null, blanks or zeros for what used to represent text values and numbers. I then have to start a new game to reset the default values in the text file.

I am confused as to why this happens. I don’t call any save or load file procedures to /from the file at the point of the error in (Activity_Create). Furthermore, I used to get errors when I mistakenly tried to save a Null value to the user file. How can the file actually get Null values given that I can’t pass them in code. I save over 80 text lines (representing fields). All of these values automatically get rewritten due to the error.
 

mc73

Well-Known Member
Licensed User
Longtime User
Not easy to understand what goes wrong without seeing the actual code, but If this were my app, I would firstly look for any part of the code that places a fresh copy of your file from dir.assets (if you initially load it this way). Usually this runs in activity_create. Secondly I would search for the area in which I'm closing the file, and whether it is still open (the file) whenever this keyboard error occurs (such behavior could lead to a corrupted file, at least so I suppose).
 
Upvote 0

DevBaby

Active Member
Licensed User
Longtime User
Thanks to you both. This seems reasonable given that I am saving the file in my Activity_Pause...and then the App crashes on the immediate call of Activity_Create.

The file may not be finished saving before the crash occurs.

I guess my next goal to fix the crash that starts it all.
 
Upvote 0
Top