Android Question Access to a cross-platform class for managing an internal SQLite database

GeoT

Active Member
Licensed User
Longtime User
Hello.

I've been researching, using AI, the best way to create and use a class for managing an internal SQLite database, but in a way that's cross-platform and accessible from the entire app (including a service).

The solution we've found is to create a code module within a B4XPages project that instantiates the class so it's accessible to the entire app.
Because if it were only for B4A, we could omit that code module and instantiate it from the Starter module, for example. I think.

Screenshot_20260217_122627_b4a_dbmanagerfromdbmodule_main.png
Screenshot_2026-02-18 135306.png


Is this the best or only way to do it?

Can this be corrected, improved, or extended in any way?

Can any more common methods be added or modified?

How can we then verify that it works correctly with the B4J and B4i code generated by the B4XPages project?

I've used a UNIQUE field as a reference.

It is only a reference example.

Thanks.
 

Attachments

  • DBManagerFromDBModule.zip
    21.6 KB · Views: 3
Last edited:

GeoT

Active Member
Licensed User
Longtime User
Hi walt61.
Yes, it would be easier, but it wouldn't be accessible from a standalone service that starts automatically, or if the app is in the background (paused) and the system has killed the process due to lack of memory, for example.
 
Upvote 0

GeoT

Active Member
Licensed User
Longtime User
As far as I know, Starter is a service.
It exists in B4A.
In B4J I believe it's optional.
And it doesn't exist in B4I.
 
Upvote 0

GeoT

Active Member
Licensed User
Longtime User
Hi, LucaMs.
The problem is that when the service wakes up on its own: when a service runs in the background (by a receiver, a timer, or the system), Android starts the service process, but does not start the graphical interface or the pages.
No?
But I'm not talking about the Starter service.
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
There are some database management classes and libraries on this forum.
I created MiniORMUtils library for cross platform apps.
In B4A, you don't need to initialize your database in Starter. You can initialize it in Main or B4XMainPage too.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
There is some confusion here, I think.
@GeoT wants the service process for db, so that no matter how the app starts/re-starts , the db is started.
Rest of us are advising on easiest way of senility db service, right ?

I do not use db still in b4x, so no idea about it so may be I am wrong here, but I think we are not following what GeoT is trying to state.
 
Upvote 0

GeoT

Active Member
Licensed User
Longtime User
Thanks, Aeric.
I haven't found all those database management classes and libraries on this forum yet.
Your creation uses a MiniORMUtils.v4 file that I can't find.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

GeoT

Active Member
Licensed User
Longtime User
AnandGupta is right.
I also want to access or start the database from the service without opening the interface.
Apart from the Starter.
That's why it uses the code module as an intermediary.

Forgive my ignorance. B4I doesn't have services, but what about B4J?
I program basically with B4A.

Thanks, Walt61.
How do I add the Starter in B4J?

Do I need to add the class module and code module to the B4J part of the project again?
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
Your creation uses a MiniORMUtils.v4 file that I can't find.
You are right. The latest version is now renamed to MiniORMUtils. I only keep the latest version attached in first post of the library page.
If you are trying the project template, you need to rereference the library or find the older version from my GitHub as pointed by DonManfred.

Edit: MiniORM project template updated to v4.10
 
Last edited:
Upvote 0

GeoT

Active Member
Licensed User
Longtime User
Thanks, walt61, for showing me how to add a Starter in B4J.
But for now, I'll stick with my current structure.
 
Upvote 0

GeoT

Active Member
Licensed User
Longtime User
I've edited the post 1 with a new version of the project attached.
What I didn't know is that B4J doesn't have services.

Thanks to studying aeric's code, the project now also works with B4J.
I've moved the DBModule and DBManager modules to make them common.
I've also unified more code and corrected errors and translations.

Regards.
 
Upvote 0
Top