### Check for Updates

This is a possibility to check if there is a new version for an app.
Prerequisite
On the webserver store a textfile holding the latest version of the app.
Example content which is only one line informat YYYYMMDD:
20141216
On the local device store a textfile holding the current version of the app.
Example content which is only one line informat YYYYMMDD:
20141215
B4J Code
' Define the constants for the remote and local file
Dim Const CAPPVERLOC As String = "myapp.ver"
Dim Const CAPPVERREM As String = "http://YOURURL/" & CAPPVER
'
' SUBS TO CHECK FOR UPDATES
'
' Init and start the download of the remote textfile containing the version. Wait for job to be done.
`Sub CheckUpdate
Dim j As HttpJob
j.Initialize("j", Me)
j.Download(CAPPVERREM)
End Sub`
' Handle downloadjob done.
' With example message.
`Sub JobDone(Job As HttpJob)
' Job successfully completed
If Job.Success Then
' Get the versions
Dim RemoteVersion As String = Job.GetString
Dim LocalVersion As String = FUtils.FileToString(CAPPVERLOC)
' And compare
If LocalVersion < RemoteVersion Then
MsgDlg.MessageDialog("There is a new version " & RemoteVersion & " available." & _
"

" & CAPPVUPDURL & " this version and

copy the jar file to your app folder.

" & _
"Your current version is " & LocalVersion & ".")
End If
Else
MsgDlg.MessageDialog("

# Error reading latest version

#

" & Job.ErrorMessage)
End If
Job.Release
End Sub

`
' Example assigning to a button
' Private mnuToolsCheckUpdate As MenuItem
`Sub mnuToolsCheckUpdate_Action
CheckUpdate
End Sub`

Changed: , Category: Internet, File: T6C203M1487.htm, ID: 1487