B4J Question Concurrent access

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using a few SQLite databases in my app, and come across the tutorial on the Concurrent access to the databases. - https://www.b4x.com/android/forum/t...ent-access-to-sqlite-databases.39904/#content

I have a code module and in that code mode I have Dimmed the SQLite database in Process_Globals.

I am Initializing the database once from a sub in this code module when my B4J app first runs.

I then have a few subs that write to this database and a few subs that will select items from this database.

I never run the code:

B4X:
SQLite.Close

So my database is always open. (is this OK, or should I be closing the connection to the database after I read/write it?)

Do I need to use the following code when the B4J app creates the database for the first time or after it creates the tables, or is it OK to run the following code after I create the tables and load a few items to the database?
B4X:
SQLite.ExecNonQuery("PRAGMA journal_mode = wal")

I already have my database created, but never used the above code yet and not sure if I need to delete the database and create it again and run the above code before creating the tables.

Do I also need to run the above code each time I open the database or only when it's first created ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
(is this OK, or should I be closing the connection to the database after I read/write it?)
It is OK.

Do I also need to run the above code each time I open the database or only when it's first created ?
It is only needed once though it will not do any harm to call it each time.

You can also check that it is actually in wal mode with:
B4X:
Log(SQLite.ExecQuerySingleResult("PRAGMA journal_mode"))
 
Upvote 0
Top