Maybe I'm missing something but my question is: can I access the database from different points of my code each one using its own DatabaseHelper instance? Or is it better to have a unique global static DatabaseHelper accessible from everywhere (threads, activities, ...)? What is the best practice in this case?
Asked
Active
Viewed 347 times
1 Answers
2
It is better to have a single instance if you are using multiple threads, as thread synchronization will be applied automatically. Whether that single instance is a singleton or wrapped in a ContentProvider
is up to you.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
Found this: http://stackoverflow.com/questions/6905524/using-singleton-design-pattern-for-sqlitedatabase. Maybe I don't need a ContentProvider in my case. Thanks! – Seraphim's Nov 26 '12 at 09:49