开发者

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 开发者_StackOverflow社区with database but maybe there is another solution? Thanks for all advice and tip.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜