I am try to use Save INI to write APP Version to textfile when I run the app for first time
so when I upgrade from Market and APP Version number and Version number in the file is not the same I copy new Database
but when I run the app from Basic4android to my Mobile
FirstTime don't work it upgrade the text file each time I run the app from basic4android to my Mobile
B4X:
File.MakeDir(File.DirRootExternal,"islenskapp")
Dim Writer As TextWriter
Writer.Initialize(File.OpenOutput(File.DirDefaultExternal,"islenskapp.txt",True))
If FirstTime Then
SaveINI ' write Verion of the app to text file when I run the app for FirstTime
End If
LoadINI ' to check if version on the app are new and copy database and write new version number to textfile
'FirstTime' does not mean the app is running for the first time.
It means the app is loaded into memory (i.e. the process is created) for the first time. On subsequent loads, the process will already be in memory so FirstTime is not triggered.
Independently of whether it is the very first time you run your app, a good way would be to check everytime your app starts, whther the file containing the app version and other info, exists. For this, simply use 'file.exists'. If it is found, load data, if not, create it (or recreate it in case of an accidental deletion by user for e.g.) and then proceed to neccessary checks.
I would personally use a file to store the information. There are a few good link on the topic on this forum.
E.g. I personally use a file for storing external DB connection strings for monitoring MySQL DBs. Use 'If File.Exists(file location) Then blah blah blah', if there is no file then create one and store your data in it.