klemens
klemens

Reputation: 413

Android, threads and databases

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

Answers (1)

PravinCG
PravinCG

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

Related Questions