Reputation: 413
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.
Upvotes: 2
Views: 150
Reputation: 7708
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.
Upvotes: 5