I need to write some application which will have a couple threads and these threads will be work with local database. I afraid that these threads will be compete among themselves for database. Is there any simple solution to solve this problem? I read that I can use content provider becouse then will be only one connection with database but maybe there is another solution? Thanks for all advice and tip.
Asked
Active
Viewed 147 times
2
-
This should help : http://stackoverflow.com/questions/2493331/what-is-best-practice-with-sqlite-and-android – Ravi Vyas Jul 16 '11 at 18:43
1 Answers
5
Use one DataBase Helper class and create a single instance which can be accessed by both threads.
Make all the methods in DataBase Helper class as synchronized to avoid race conditions.

PravinCG
- 7,688
- 3
- 30
- 55