sql information show in an widget

Fox

Active Member
Licensed User
Longtime User
Hello i want to play with the new Widget tool :). Is it possible that i can show an simple information about count's in an sql show in an widget?

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim rv As RemoteViews
   Dim ST As SQL
End Sub

Sub SetText
rv.SetText("Label1",ST.ExecQuerySingleResult("SELECT count(*) FROM database")
End Sub

OK Problem solved!

If anyone use it here is the code:

B4X:
'Service module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim rv As RemoteViews
   Dim ST As SQL
   Dim Cursor As Cursor

End Sub

Sub Service_Create
   'Set the widget to update every 60 minutes.
   rv = ConfigureHomeWidget("WidgetLayout", "rv", 60, "NameofWidget")
   ST.Initialize(File.DirDefaultExternal, "Database.sql", False)
End Sub

Sub Service_Start (StartingIntent As Intent)
   If rv.HandleWidgetEvents(StartingIntent) Then Return
End Sub

Sub Service_Destroy

End Sub

Sub rv_RequestUpdate
   SetText
   rv.UpdateWidget
End Sub

Sub SetText
rv.SetText("Label1", ST.ExecQuerySingleResult("SELECT count(*) FROM Database") & " Entries")
End Sub

Sub rv_Disabled
   StopService("")
End Sub
 
Last edited:
Top