B
B
BitNeBolt2020-11-15 23:28:09
Android
BitNeBolt, 2020-11-15 23:28:09

Is it worth it to work with SQLite this way?

There are several databases, each with its own Dbhelper. In order to work with them, I created a class in which all methods are static and synchronized, there is a reference to the context of the entire application (set in the application class, getApplicationContext()).

Then, in order to get a list of objects from the database, the required method is called (in a separate thread), Dbhelper objects are created in it and the database is obtained for reading, after all operations the objects are closed.

What are the disadvantages of this? In practice, it works well (seemingly).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2020-11-16
@BitNeBolt

Static in Android is bad, whether it's convenient for you or not. Learn it like a mantra that you don't have to do that, and that's it.
Use D.I.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question