How do you refresh the database?

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

In one activity I inserted rows in a database then I went to another activity that uses the same database and found that it did not reflect the new rows of data.

If I exit the app and start it up again then you can see the new rows in the database.

How can I refresh so other activities can see it so I don't have to exit the app and go back in?

Thanks.
 

rleiman

Well-Known Member
Licensed User
Longtime User
Hi NJDude,

I'm not using transactions and am closing cursors.

I did however, find that if I initialise the database every time the activity is created then it's refreshed as in this code:

B4X:
Sub Activity_Create(FirstTime As Boolean)

   ' This LoadLayout is required to show the views on the layout file.
   '------------------------------------------------------------------
   Activity.LoadLayout("Visits")

   Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "islamicbackground.jpg"))

   PanelOverlay.Left = 0
   PanelOverlay.Top = 0
   PanelOverlay.Width = 100%x
   PanelOverlay.Height = 100%y

   TabHostVisits.AddTab2("Current Manifest", PanelCurrentManifest)
   TabHostVisits.AddTab2("New Manifest", PanelNewManifest)

   TabHostVisits.CurrentTab = 0 ' Go the tab page 1.

   ' Make the database file available for use.
   '------------------------------------------
   If FirstTime Then
      'SQL.Initialize(File.DirRootExternal, "DawahDoors.db", True)
'      SQL.Initialize(File.DirInternal, "DawahDoors.db", True)
   End If

   SQL.Initialize(File.DirInternal, "DawahDoors.db", True)

   PopulateSpinners
End Sub
 
Upvote 0

eps

Expert
Licensed User
Longtime User
something like this : SQL1.EndTransaction should work, as it should commit the information to the database. If you haven't used databases before you need to read up on them : Atomic Commit In SQLite

Records are created, but are pending until a commit is performed, then you will see them.

See here as well, Basic4android - SQL

You will need a few statements, in addition to EndTransaction to make that work..
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi eps,

Thanks for the reply.

I'm familar with databases. In pl/sql I would use:

B4X:
commit;

So I will look at your links to see what the commit statement in SQLite looks like.

Truly,
Emad
 
Upvote 0
Top