Hello team.
I initialize sqlite at starter service. Everything works fine. Where should we call SQL.close? Because i call sql.close at Main activity_pause if user closed and throws me an error if i close app and reopen imediately. Error is about: reopen a closed database.
Thank you for your time.
Thank you for your answer. But SQL is initialized from starter service.
As i see at log, odd times entry point is Starter service(does not crash), even times entry point is main activity and after that starts starter service(app crashes because SQL is not initiliazed).
Is there any bug with starter service?
No. There is no bug but the starter service is just to start some things. I prefer not to use it. Use another service than the starter service. E.g. I have several services for db handling, encryption, communication, etc.
So start and stop the - let's call it "db service" by your own code. Then you have no side effects and all under control.
Closing the db intentionally is a good practice. Check if it's initialized and if not reopen it.
As i see at log, odd times entry point is Starter service(does not crash), even times entry point is main activity and after that starts starter service(app crashes because SQL is not initiliazed).
Is there any bug with starter service?
I consider it a bad suggestion as well. Especially in the general case.
Android apps are different than desktop apps. They don't have a clear or well defined closing event. You can make your app more complex than it should be by closing the database in Activity_Pause (of each activity) and then open it again. Nothing good will come out of this.